VectorsImpl.mesa
Last Edited by: Arnon, July 19, 1985 2:54:46 pm PDT
DIRECTORY
Rope,
IO,
MathExpr,
MathConstructors,
AlgebraClasses,
Structures,
Ints,
Vectors;
VectorsImpl: CEDAR PROGRAM
IMPORTS Rope, IO, MathConstructors, Structures, AlgebraClasses, Ints
EXPORTS Vectors =
BEGIN OPEN AC: AlgebraClasses, Vectors;
Errors and Types
SyntaxError: PUBLIC ERROR [reason: ATOM] = CODE;
BadCoordinateStructure: PUBLIC ERROR [coordinateStructure: AC.Object] = CODE;
TypeError: PUBLIC ERROR [message: ATOM ← $Unspecified] = CODE;
Method: TYPE = AC.Method;
Object: TYPE = AC.Object;
Vector Structure Ops
MakeVectorStructure: PUBLIC AC.VectorStructureConstructor ~ {
vectorStructureData: VectorStructureData ← NEW[VectorStructureDataRec ← [
row: row,
coordinateStructure: coordinateStructure,
dimension: dimension
] ];
method: Method ← AC.LookupMethodInStructure[$category, coordinateStructure];
category: REF AC.Category ← NARROW[method.value];
SELECT category^ FROM
set => vectorStructure ← AC.MakeStructure[
name: NIL,
class: vectorsClass,
instanceData: vectorStructureData
];
group => vectorStructure ← AC.MakeStructure[
name: NIL,
class: vectorsOverGroupClass,
instanceData: vectorStructureData
];
ring, algebra => vectorStructure ← AC.MakeStructure[
name: NIL,
class: vectorsOverRingClass,
instanceData: vectorStructureData
];
field, divisionAlgebra => vectorStructure ← AC.MakeStructure[
name: NIL,
class: vectorsOverFieldClass,
instanceData: vectorStructureData
];
ENDCASE => ERROR BadCoordinateStructure[coordinateStructure];
vectorStructure.name ← ShortPrintName[vectorStructure];
IF AC.LookupStructure[vectorStructure.name] = NIL THEN AC.InstallStructure[vectorStructure];
};
PrintName: PUBLIC AC.ToRopeOp = {
data: VectorStructureData ← NARROW[in.data];
shortPrintNameMethod: Method ← AC.LookupMethodInStructure[$shortPrintName, data.coordinateStructure];
RETURN[Rope.Concat[
"Vectors over ",
NARROW[AC.ApplyNoLkpNoRecastRef[shortPrintNameMethod,LIST[data.coordinateStructure] ] ]
] ];
};
ShortPrintName: PUBLIC AC.ToRopeOp = {
data: VectorStructureData ← NARROW[in.data];
shortPrintNameMethod: Method ← AC.LookupMethodInStructure[$shortPrintName, data.coordinateStructure];
RETURN[Rope.Cat[
"Vec(",
NARROW[AC.ApplyNoLkpNoRecastRef[shortPrintNameMethod,LIST[data.coordinateStructure] ] ],
")"
] ];
};
CoordinateStructure: PUBLIC AC.UnaryOp = {
data: VectorStructureData ← NARROW[arg.data];
RETURN[data.coordinateStructure];
};
Dimension: PUBLIC AC.StructureRankOp = {
data: VectorStructureData ← NARROW[structure.data];
RETURN[data.dimension];
};
IsVectorStructure: PUBLIC AC.UnaryPredicate = {
RETURN[ISTYPE[arg.data, VectorStructureData] ];
};
Conversion and IO
Recast: PUBLIC AC.BinaryOp = {
Args are a StructureElement and a Structure
thisVectorStructure: Object ← secondArg;
thisVectorStructureData: VectorStructureData ← NARROW[thisVectorStructure.data];
thisStructureCoordinateStructure: Object ← thisVectorStructureData.coordinateStructure;
thisStructureDimension: NAT ← thisVectorStructureData.dimension;
canRecastMethod: Method ← AC.LookupMethodInStructure[$canRecast, thisStructureCoordinateStructure];
recastMethod: Method ← AC.LookupMethodInStructure[$recast, thisStructureCoordinateStructure];
flag: BOOL;
IF AC.StructureEqual[firstArg.class, secondArg] THEN RETURN[firstArg]; -- nothing to do
See if can recast firstArg into thisStructureCoordinateStructure
flag ← AC.ApplyPredNoLkpNoRecast[canRecastMethod,LIST[firstArg.class, thisStructureCoordinateStructure] ];
IF flag THEN {
recastElement: Object ← AC.ApplyNoLkpNoRecastObject[recastMethod, LIST[firstArg, thisStructureCoordinateStructure] ];
RETURN[ ImbedScalar[recastElement, thisVectorStructure] ];
};
If firstArg is a Vector, check if can recast its coordinateStructure into thisStructureCoordinateStructure, and if has right dimension; if so, recast all its elements.
IF AC.LookupMethodInStructure[$vectorStructure, firstArg.class]#NIL THEN {
inputVectorStructure: Object ← firstArg.class;
inputVectorStructureData: VectorStructureData ← NARROW[inputVectorStructure.data];
inputStructureCoordinateStructure: Object ← inputVectorStructureData.coordinateStructure;
inputStructureDimension: NAT ← inputVectorStructureData.dimension;
argData: VectorData ← NARROW[firstArg.data];
resultData: VectorData;
IF thisStructureDimension#inputStructureDimension THEN RETURN[NIL];
flag ← AC.ApplyPredNoLkpNoRecast[canRecastMethod,LIST[inputStructureCoordinateStructure, thisStructureCoordinateStructure] ];
IF NOT flag THEN RETURN[NIL]; -- give up
resultData ← NEW[VectorDataRec[argData.dimensionPlus1 - 1] ];
FOR i:NAT IN [1..argData.dimensionPlus1) DO
resultData[i] ← AC.ApplyNoLkpNoRecastObject[recastMethod, LIST[argData[i], thisStructureCoordinateStructure] ];
ENDLOOP;
RETURN[ NEW[AC.ObjectRec ← [
flavor: StructureElement,
class: thisVectorStructure,
data: resultData
] ] ];
};
Can't do it
RETURN[NIL];
};
CanRecast: PUBLIC AC.BinaryPredicate = {
Args are either [Structure, Structure] or [StructureElement, Structure]
thisVectorStructure: Object ← secondArg;
thisVectorStructureData: VectorStructureData ← NARROW[thisVectorStructure.data];
thisStructureCoordinateStructure: Object ← thisVectorStructureData.coordinateStructure;
thisStructureDimension: NAT ← thisVectorStructureData.dimension;
canRecastMethod: Method ← AC.LookupMethodInStructure[$canRecast, thisStructureCoordinateStructure];
flag: BOOL;
firstArgStructure: Object ← IF firstArg.flavor = StructureElement THEN firstArg.class ELSE IF firstArg.flavor = Structure THEN firstArg ELSE ERROR;
IF AC.StructureEqual[firstArgStructure, thisVectorStructure] THEN RETURN[TRUE];
flag ← AC.ApplyPredNoLkpNoRecast[canRecastMethod,LIST[firstArgStructure, thisStructureCoordinateStructure] ];
IF flag THEN RETURN[TRUE];
IF AC.LookupMethodInStructure[$vectorStructure, firstArgStructure]#NIL THEN {
inputVectorStructure: Object ← firstArgStructure;
inputVectorStructureData: VectorStructureData ← NARROW[inputVectorStructure.data];
inputStructureCoordinateStructure: Object ← inputVectorStructureData.coordinateStructure;
inputStructureDimension: NAT ← inputVectorStructureData.dimension;
IF thisStructureDimension#inputStructureDimension THEN RETURN[FALSE];
flag ← AC.ApplyPredNoLkpNoRecast[canRecastMethod,LIST[inputStructureCoordinateStructure, thisStructureCoordinateStructure] ];
RETURN[flag];
};
RETURN[FALSE];
};
ToExpr: PUBLIC AC.ToExprOp = {
vectorData: VectorData ← NARROW[in.data];
vectorStructureData: VectorStructureData ← NARROW[in.class.data];
size: CARDINAL ← vectorData.dimensionPlus1 - 1;
outColumn: LIST OF MathExpr.EXPRNIL;
method: Method ← AC.LookupMethodInStructure[$toExpr, vectorStructureData.coordinateStructure];
FOR j:NAT DECREASING IN [1..size] DO
outColumn ← CONS[NARROW[AC.ApplyNoLkpNoRecastRef[method, LIST[vectorData[j]] ]] , outColumn];
ENDLOOP;
out ← MathConstructors.MakeVector[size, outColumn, vectorStructureData.row]; -- row (not column) vector
};
LegalFirstChar: PUBLIC AC.LegalFirstCharOp = {
SELECT char FROM
'[ => RETURN[TRUE];
ENDCASE;
RETURN[FALSE];
};
Read: PUBLIC AC.ReadOp ~ {
structureData: VectorStructureData ← NARROW[structure.data];
coordinateStructure: AC.Object ← structureData.coordinateStructure;
readMethod: AC.Method ← AC.LookupMethodInStructure[$read, coordinateStructure];
puncChar: CHAR;
nextElement: AC.Object;
length: NAT ← 0;
list, listTail: LIST OF AC.Object ← NIL;
outData: VectorData;
[]← in.SkipWhitespace[];
puncChar ← in.GetChar[];
[]← in.SkipWhitespace[];
IF puncChar # '[ THEN ERROR SyntaxError[$LeftParenExpected];
[]← in.SkipWhitespace[];
puncChar ← in.PeekChar[];
IF puncChar = '] THEN puncChar ← in.GetChar[];
WHILE puncChar # '] DO
nextElement ← AC.ApplyReadMethod[readMethod, in, coordinateStructure];
length ← length + 1;
[]← in.SkipWhitespace[];
IF list=NIL THEN list ← listTail ←LIST[nextElement] ELSE
{ listTail.rest ← LIST[nextElement]; listTail ← listTail.rest };
puncChar ← in.GetChar[];
[]← in.SkipWhitespace[];
IF puncChar # '] THEN
IF puncChar # ', THEN ERROR SyntaxError[$CommaExpected];
ENDLOOP;
outData ← NEW[VectorDataRec[length] ];
FOR i:NAT IN [1..length] DO
outData[i] ← list.first;
list ← list.rest;
ENDLOOP;
out ← NEW[AC.ObjectRec ← [flavor: StructureElement, class: structure, data: outData] ];
};
FromRope: PUBLIC AC.FromRopeOp ~ {
out ← Read[IO.RIS[in], structure];
};
ToRope: PUBLIC AC.ToRopeOp ~ {
vectorStructureData: VectorStructureData ← NARROW[in.class.data];
coordinateStructure: AC.Object ← vectorStructureData.coordinateStructure;
toRopeMethod: AC.Method ← AC.LookupMethodInStructure[$toRope, coordinateStructure];
inData: VectorData ← NARROW[in.data];
out ← "[ ";
FOR i:NAT IN [1..inData.dimensionPlus1) DO
out ← Rope.Concat[ out, NARROW[AC.ApplyNoLkpNoRecastRef[toRopeMethod, LIST[inData[i] ] ] ] ];
IF i < inData.dimensionPlus1-1 THEN out ← Rope.Concat[out,", "];
ENDLOOP;
out ← Rope.Concat[ out, " ]" ];
};
Write: PUBLIC AC.WriteOp ~ {
stream.PutRope[ ToRope[in] ]
};
Constructor
ImbedScalar: PUBLIC AC.UnaryImbedOp ~ {
Assumes scalar is an element of coordinateStructure
dimension: NAT ← Dimension[structure];
resultData: VectorData ← NEW[VectorDataRec[dimension] ];
FOR i:NAT IN [1..dimension] DO
resultData[i] ← in;
ENDLOOP;
RETURN[ NEW[AC.ObjectRec ← [
flavor: StructureElement,
class: structure,
data: resultData
] ] ];
};
MakeVector: PUBLIC AC.ListImbedOp ~ {
Attempts to recast supplied elements into coordinateStructure.
If data = NIL then returns empty vector.
structureData: VectorStructureData ← NARROW[structure.data];
coordinateStructure: AC.Object ← structureData.coordinateStructure;
dimension: NAT ← structureData.dimension;
recastMethod: Method ← AC.LookupMethodInStructure[$recast, coordinateStructure];
length: NAT ← 0;
ptr: LIST OF AC.Object ← data;
outData: VectorData;
WHILE ptr#NIL DO length ← length + 1; ptr ← ptr.rest ENDLOOP;
IF length#dimension THEN ERROR TypeError[$BadDimension];
outData ← NEW[VectorDataRec[dimension] ];
FOR i:NAT IN [1..dimension] DO
outData[i] ← AC.ApplyNoLkpNoRecastObject[recastMethod, LIST[data.first, coordinateStructure] ];
IF outData[i] = NIL THEN TypeError[];
data ← data.rest;
ENDLOOP;
out ← NEW[AC.ObjectRec ← [flavor: StructureElement, class: structure, data: outData] ];
};
Selection
Coordinate: PUBLIC AC.BinaryOp ~ {
firstData: VectorData ← NARROW[firstArg.data];
index: INT ← Ints.ToINT[secondArg];
IF index<1 OR firstData.dimensionPlus1-1<index THEN RETURN[NIL];
RETURN[firstData[index] ];
};
Arithmetic
Zero: PUBLIC AC.NullaryOp ~ {
coordinateStructure: Object ← CoordinateStructure[structure];
zero: Object ← AC.ApplyLkpNoRecastObject[$zero, coordinateStructure, LIST[coordinateStructure] ];
RETURN[ImbedScalar[zero, structure] ];
};
One: PUBLIC AC.NullaryOp ~ {
coordinateStructure: Object ← CoordinateStructure[structure];
one: Object ← AC.ApplyLkpNoRecastObject[$one, coordinateStructure, LIST[coordinateStructure] ];
RETURN[ImbedScalar[one, structure] ];
};
Add: PUBLIC AC.BinaryOp ~ {
coordinateStructure: Object ← CoordinateStructure[firstArg.class];
sumMethod: Method ← AC.LookupMethodInStructure[$sum, coordinateStructure];
IF sumMethod=NIL THEN ERROR TypeError[$MethodNotFound];
RETURN[ MapBinaryElementOp[firstArg, secondArg, sumMethod] ];
};
Negate: PUBLIC AC.UnaryOp ~ {
coordinateStructure: Object ← CoordinateStructure[arg.class];
negationMethod: Method ← AC.LookupMethodInStructure[$negation, coordinateStructure];
IF negationMethod=NIL THEN ERROR TypeError[$MethodNotFound];
RETURN[ MapUnaryElementOp[arg, negationMethod] ];
};
Subtract: PUBLIC AC.BinaryOp ~ {
coordinateStructure: Object ← CoordinateStructure[firstArg.class];
differenceMethod: Method ← AC.LookupMethodInStructure[$difference, coordinateStructure];
IF differenceMethod=NIL THEN ERROR TypeError[$MethodNotFound];
RETURN[ MapBinaryElementOp[firstArg, secondArg, differenceMethod] ];
};
ScalarMultiply: PUBLIC AC.BinaryOp ~ {
firstArg is scalar, secondArg is vector
secondData: VectorData ← NARROW[secondArg.data];
vectorStructureData: VectorStructureData ← NARROW[secondArg.class.data];
coordinateStructure: Object ← vectorStructureData.coordinateStructure;
dimension: NAT ← vectorStructureData.dimension;
productMethod: Method ← AC.LookupMethodInStructure[$product, coordinateStructure];
resultData: VectorData;
resultData ← NEW[VectorDataRec[dimension] ];
FOR i:NAT IN [1..dimension] DO
resultData[i] ← AC.ApplyNoLkpNoRecastObject[productMethod, LIST[firstArg, secondData[i] ] ];
ENDLOOP;
result ← NEW[AC.ObjectRec ← [flavor: StructureElement, class: secondArg.class, data: resultData] ];
};
ComponentWiseMultiply: PUBLIC AC.BinaryOp;
ComponentWisePower: PUBLIC AC.BinaryOp;
ComponentWiseInvert: PUBLIC AC.UnaryOp;
ComponentWiseDivide: PUBLIC AC.BinaryOp;
Comparison
Equal: PUBLIC AC.BinaryPredicate ~ {
firstArgData: VectorData ← NARROW[firstArg.data];
secondArgData: VectorData ← NARROW[secondArg.data];
vectorStructureData: VectorStructureData ← NARROW[firstArg.class.data];
coordinateEqualsMethod: Method ← AC.LookupMethodInStructure[$eqFormula, vectorStructureData.coordinateStructure];
IF firstArgData.dimensionPlus1 # secondArgData.dimensionPlus1 THEN RETURN[FALSE];
FOR j: NAT IN [1..firstArgData.dimensionPlus1) DO
IF NOT AC.ApplyPredNoLkpNoRecast[coordinateEqualsMethod, LIST[firstArgData[j], secondArgData[j] ] ] THEN RETURN[FALSE];
ENDLOOP;
RETURN[TRUE];
};
Operations
MapUnaryElementOp: PUBLIC 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.
vectorData: VectorData ← NARROW[firstArg.data];
method: Method ← NARROW[secondArg];
newCoordinateStructure, newVecStructure: AC.Object ← NIL;
dimension: NAT ← Dimension[firstArg.class];
newData: VectorData ← NEW[VectorDataRec[dimension] ];
FOR i:INT IN [1..dimension] DO
newData[i] ← AC.ApplyNoLkpNoRecastObject[method, LIST[vectorData[i] ] ];
IF newData[i]# NIL THEN newCoordinateStructure ← newData[i].class;
ENDLOOP;
IF newCoordinateStructure = NIL THEN RETURN[firstArg]; -- map has trivial result
newVecStructure ← MakeVectorStructure[newCoordinateStructure, dimension];
RETURN[ NEW[AC.ObjectRec ← [
flavor: StructureElement,
class: newVecStructure,
data: newData
] ] ];
};
MapBinaryElementOp: PUBLIC 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.
firstData: VectorData ← NARROW[firstArg.data];
secondData: VectorData ← NARROW[secondArg.data];
method: Method ← NARROW[thirdArg];
newCoordinateStructure, newVecStructure: AC.Object ← NIL;
dimension: NAT ← Dimension[firstArg.class];
coordinateStructure: Object ← CoordinateStructure[firstArg.class];
newData: VectorData ← NEW[VectorDataRec[dimension] ];
FOR i:INT IN [1..dimension] DO
newData[i] ← AC.ApplyNoLkpRecastObject[method, coordinateStructure, LIST[firstData[i], secondData[i] ] ]; -- do recast
IF newData[i]# NIL THEN newCoordinateStructure ← newData[i].class;
ENDLOOP;
IF newCoordinateStructure = NIL THEN RETURN[firstArg]; -- map has trivial result
newVecStructure ← MakeVectorStructure[newCoordinateStructure, dimension];
RETURN[ NEW[AC.ObjectRec ← [
flavor: StructureElement,
class: newVecStructure,
data: newData
] ] ];
};
Standard Desired Arg Structures
ObjectAndIntDesired: PUBLIC AC.UnaryToListOp ~ {
RETURN[ LIST[arg, Ints.Ints] ]; -- arg assumed to be a Vector Structure
};
VectorAndCoordinateDesired: PUBLIC AC.UnaryToListOp ~ {
thisVectorStructureData: VectorStructureData ← NARROW[arg.data];
coordinateStructure: Object ← thisVectorStructureData.coordinateStructure;
RETURN[ LIST[arg, coordinateStructure] ]; -- arg assumed to be a Vector Structure
};
CoordinateAndVectorDesired: PUBLIC AC.UnaryToListOp ~ {
thisVectorStructureData: VectorStructureData ← NARROW[arg.data];
coordinateStructure: Object ← thisVectorStructureData.coordinateStructure;
RETURN[ LIST[coordinateStructure, arg] ]; -- arg assumed to be a Vector Structure
};
VectorIntAndCoordinateDesired: PUBLIC AC.UnaryToListOp ~ {
thisVectorStructureData: VectorStructureData ← NARROW[arg.data];
coordinateStructure: Object ← thisVectorStructureData.coordinateStructure;
RETURN[ LIST[arg, Ints.Ints, coordinateStructure] ]; -- arg assumed to be a Vector Structure
};
Start Code
vectorsClass: AC.Object ← AC.MakeClass["VectorsClass", NIL, NIL];
vectorsOverGroupClass: AC.Object ← AC.MakeClass["VectorsOverGroupClass", vectorsClass, NIL];
subclass[vectorsClass]
vectorsOverRingClass: AC.Object ← AC.MakeClass["VectorsOverRingClass", vectorsOverGroupClass, NIL];
subclass[vectorsOverGroupClass]
vectorsOverFieldClass: AC.Object ← AC.MakeClass["VectorsOverFieldClass", vectorsOverRingClass, NIL];
subclass[vectorsOverRingClass]
setCategoryMethod: Method ← AC.MakeMethod[Value, FALSE, NEW[AC.Category ← set], NIL, NIL];
groupCategoryMethod: Method ← AC.MakeMethod[Value, FALSE, NEW[AC.Category ← group], NIL, NIL];
ringCategoryMethod: Method ← AC.MakeMethod[Value, FALSE, NEW[AC.Category ← ring], NIL, NIL];
fieldCategoryMethod: Method ← AC.MakeMethod[Value, FALSE, NEW[AC.Category ← field], NIL, NIL];
vectorSpaceCategoryMethod: Method ← AC.MakeMethod[Value, FALSE, NEW[AC.Category ← vectorSpace], NIL, NIL];
vectorStructureMethod: Method ← AC.MakeMethod[Value, FALSE, NIL, NIL, "vectorStructure"];
matrixStructureMethod: Method ← AC.MakeMethod[Value, FALSE, NIL, NIL, "matrixStructure"];
shortPrintNameMethod: Method ← AC.MakeMethod[ToRopeOp, FALSE, NEW[AC.ToRopeOp ← ShortPrintName], NIL, "shortPrintName"];
recastMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Recast], NIL, "recast"];
canRecastMethod: Method ← AC.MakeMethod[BinaryPredicate, TRUE, NEW[AC.BinaryPredicate ← CanRecast], NIL, "canRecast"];
toExprMethod: Method ← AC.MakeMethod[ToExprOp, FALSE, NEW[AC.ToExprOp ← ToExpr], NEW[AC.UnaryToListOp ← AC.DefaultDesiredArgStructures], "toExpr"];
legalFirstCharMethod: Method ← AC.MakeMethod[LegalFirstCharOp, FALSE, NEW[AC.LegalFirstCharOp ← LegalFirstChar], NIL, "legalFirstChar"];
readMethod: Method ← AC.MakeMethod[ReadOp, FALSE, NEW[AC.ReadOp ← Read], NIL, "read"];
fromRopeMethod: Method ← AC.MakeMethod[FromRopeOp, TRUE, NEW[AC.FromRopeOp ← FromRope], NIL, "fromRope"];
toRopeMethod: Method ← AC.MakeMethod[ToRopeOp, FALSE, NEW[AC.ToRopeOp ← ToRope], NIL, "toRope"];
parenMethod: Method ← AC.MakeMethod[UnaryOp, FALSE, NEW[AC.UnaryOp ← AC.Copy], NIL, "paren"];
imbedScalarMethod: Method ← AC.MakeMethod[UnaryImbedOp, FALSE, NEW[AC.UnaryImbedOp ← ImbedScalar], NIL, "imbedScalar"];
vectorMethod: Method ← AC.MakeMethod[ListImbedOp, FALSE, NEW[AC.ListImbedOp ← MakeVector], NIL, "vector"];
coordinateMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Coordinate], NEW[AC.UnaryToListOp ← ObjectAndIntDesired], "coordinate"];
zeroMethod: Method ← AC.MakeMethod[NullaryOp, FALSE, NEW[AC.NullaryOp ← Zero], NIL, "zero"];
oneMethod: Method ← AC.MakeMethod[NullaryOp, FALSE, NEW[AC.NullaryOp ← One], NIL, "one"];
sumMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Add], NEW[AC.UnaryToListOp ← AC.DefaultDesiredArgStructures], "sum"];
negationMethod: Method ← AC.MakeMethod[UnaryOp, TRUE, NEW[AC.UnaryOp ← Negate], NEW[AC.UnaryToListOp ← AC.DefaultDesiredArgStructures], "negation"];
differenceMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← Subtract], NEW[AC.UnaryToListOp ← AC.DefaultDesiredArgStructures], "difference"];
scalarProductMethod: Method ← AC.MakeMethod[BinaryOp, TRUE, NEW[AC.BinaryOp ← ScalarMultiply], NEW[AC.UnaryToListOp ← CoordinateAndVectorDesired], "scalarProduct"];
equalMethod: Method ← AC.MakeMethod[BinaryPredicate, TRUE, NEW[AC.BinaryPredicate ← Equal], NEW[AC.UnaryToListOp ← AC.DefaultDesiredArgStructures], "equals"];
mapUnaryElementOpMethod: Method ← AC.MakeMethod[BinaryMixedOp, TRUE, NEW[AC.BinaryMixedOp ← MapUnaryElementOp], NIL, "mapUnary"]; -- should nave non-NIL DesiredArgStructures
mapBinaryElementOpMethod: Method ← AC.MakeMethod[TernaryMixedOp, TRUE, NEW[AC.TernaryMixedOp ← MapBinaryElementOp], NIL, "mapBinary"]; -- should nave non-NIL DesiredArgStructures
makeVectorStructureMethod: Method ← AC.MakeMethod[VectorStructureConstructor, FALSE, NEW[AC.VectorStructureConstructor ← MakeVectorStructure], NIL, "makeVectorStructure"];
AC.AddMethodToClass[$category, setCategoryMethod, vectorsClass];
AC.AddMethodToClass[$vectorStructure, vectorStructureMethod, vectorsClass];
AC.AddMethodToClass[$matrixStructure, matrixStructureMethod, vectorsClass];
AC.AddMethodToClass[$shortPrintName, shortPrintNameMethod, vectorsClass];
AC.AddMethodToClass[$recast, recastMethod, vectorsClass];
AC.AddMethodToClass[$canRecast, canRecastMethod, vectorsClass];
AC.AddMethodToClass[$toExpr, toExprMethod, vectorsClass];
AC.AddMethodToClass[$legalFirstChar, legalFirstCharMethod, vectorsClass];
AC.AddMethodToClass[$read, readMethod, vectorsClass];
AC.AddMethodToClass[$fromRope, fromRopeMethod, vectorsClass];
AC.AddMethodToClass[$toRope, toRopeMethod, vectorsClass];
AC.AddMethodToClass[$paren, parenMethod, vectorsClass];
AC.AddMethodToClass[$vector, vectorMethod, vectorsClass];
AC.AddMethodToClass[$coordinate, coordinateMethod, vectorsClass];
AC.AddMethodToClass[$eqFormula, equalMethod, vectorsClass];
AC.AddMethodToClass[$mapUnary, mapUnaryElementOpMethod, vectorsClass];
AC.AddMethodToClass[$mapBinary, mapBinaryElementOpMethod, vectorsClass];
AC.AddMethodToClass[$category, groupCategoryMethod, vectorsOverGroupClass];
AC.AddMethodToClass[$zero, zeroMethod, vectorsOverGroupClass];
AC.AddMethodToClass[$sum, sumMethod, vectorsOverGroupClass];
AC.AddMethodToClass[$negation, negationMethod, vectorsOverGroupClass];
AC.AddMethodToClass[$difference, differenceMethod, vectorsOverGroupClass];
AC.AddMethodToClass[$category, ringCategoryMethod, vectorsOverRingClass];
AC.AddMethodToClass[$category, fieldCategoryMethod, vectorsOverFieldClass];
AC.AddMethodToClass[$category, vectorSpaceCategoryMethod, vectorsOverFieldClass];
AC.AddMethodToClass[$makeVectorStructure, makeVectorStructureMethod, Structures.StructuresClass];
END.