Vectors.mesa
Last Edited by: Arnon, May 3, 1986 3:53:47 pm PDT
External direct product constructor on some baseStructure.
baseStructure is arbitrary; whatever operations are available in it are available in the product structure as component-wise operations. Elements of the baseStructure are "scalars".
If baseStructure is a ring or field, the vector structure is a finite-dimensional vector space over a field, or finite-dimensional module over a ring.
DIRECTORY
Rope,
IO,
AlgebraClasses;
Vectors: CEDAR DEFINITIONS
~ BEGIN OPEN Rope, AC: AlgebraClasses;
Vector Representation
Vector: TYPE = AC.Object;
VectorData: TYPE = REF VectorDataRec;
VectorDataRec: TYPE = RECORD [
SEQUENCE dimensionPlus1:[1..65534] OF AC.Object
];
An empty vector is represented with non-NIL data field consisting of a VectorDataRec of length 0.
Instance Data for Vector Structures
VectorStructureData: TYPE = REF VectorStructureDataRec;
VectorStructureDataRec: TYPE = RECORD [
row: BOOLTRUE,
coordinateStructure: AC.Object,
dimension: NAT
];
Vector Structure Ops
MakeVectorStructure: AC.VectorStructureConstructor;
PrintName: AC.ToRopeOp;
ShortPrintName: AC.ToRopeOp;
CoordinateStructure: AC.UnaryOp;
Dimension: AC.StructureRankOp;
IsVectorStructure: AC.UnaryPredicate;
Characteristic: AC.StructureRankOp;
Characteristic of coordinateStructure
Conversion and IO
Recast: AC.BinaryOp;
CanRecast: AC.BinaryPredicate;
ToExpr: AC.ToExprOp;
LegalFirstChar: AC.LegalFirstCharOp;
Read: AC.ReadOp;
FromRope: AC.FromRopeOp;
ToRope: AC.ToRopeOp;
Write: AC.WriteOp;
Constructors
ImbedScalar: AC.UnaryImbedOp;
The scalar a becomes the vector <a, a, ... >
MakeVector: AC.ListImbedOp;
Attempts to recast supplied elements into coordinateStructure.
If data = NIL then returns an empty vector.
Selection
Coordinate: AC.BinaryOp;
firstArg is a Vector, secondArg is an Ints.Int specifying position to select. Returns NIL if can't do.
Arithmetic
Zero: AC.NullaryOp;
One: AC.NullaryOp;
Add: AC.BinaryOp;
Negate: AC.UnaryOp;
Subtract: AC.BinaryOp;
ScalarMultiply: AC.BinaryOp;
firstArg is scalar, secondArg is matrix
ComponentWiseMultiply: AC.BinaryOp;
ComponentWisePower: AC.BinaryOp;
ComponentWiseInvert: AC.UnaryOp;
ComponentWiseDivide: AC.BinaryOp;
Comparison
Equal: AC.BinaryPredicate;
Other Operations
MapUnaryElementOp: AC.BinaryMixedOp;
firstArg is a Vector, secondArg is a unary Method (e.g. UnaryOp, UnaryPredicate) on its coordinateStructure, result is Vector of results of applications of the unary operation to the elements of firstArg.
MapBinaryElementOp: AC.TernaryMixedOp;
firstArg and secondArg are Vectors over the same coordinateStructure, and of the same length. thirdArg is a binary Method (e.g. BinaryOp, BinaryPredicate) on coordinateStructure. The result is a Vector of the results of the application of the binary operation to corresponding pairs of elements of firstArg and secondArg.
END.