Matrices.mesa
Last Edited by: Arnon, March 5, 1986 10:49:31 am PST
DIRECTORY
Rope USING [ROPE],
Basics,
IO USING [STREAM],
AlgebraClasses;
Square matrices over a ring (yielding a ring) or a field (yielding an algebra).
Matrices: CEDAR DEFINITIONS
~ BEGIN OPEN AC: AlgebraClasses;
Matrix Representation
Matrix: TYPE = REF MatrixRec;
MatrixRec: TYPE = RECORD[
size: NAT ← 0,
rows: RowSeq ← NIL
];
RowSeq: TYPE = REF RowSeqRec;
RowSeqRec: TYPE = RECORD[SEQUENCE rowsPlusOne: [1..100] OF Row];
Row: TYPE = REF RowRec;
RowRec: TYPE = RECORD[SEQUENCE columnsPlusOne: [1..100] OF REF];
Column: TYPE = REF ColumnRec;
ColumnRec: TYPE = RECORD[SEQUENCE rowsPlusOne: [1..100] OF REF];
Classes for Matrix Rings and Matrix Algebras
matrixRingClass: AC.StructureClass; -- Class record for all matrix rings, i.e. matrices over a ring which is not a field.
matrixAlgebraClass: AC.StructureClass; -- Class record for matrix algebras which are not division algebras
Instance Data for Matrix Rings and Matrix Algebras
MatrixStructureData: TYPE = REF MatrixStructureDataRec;
MatrixStructureDataRec: TYPE = RECORD [
elementStructure: AC.Structure,
size: NAT
];
Operations unique to Matrix Rings and Matrix Algebras
DiagonalMatrixConstructorOp: TYPE = PROC [element: REF, size: NAT, elementStructure: AC.Structure] RETURNS [out: Matrix];
MatrixOps: TYPE = REF MatrixOpsRec; -- prop key is $MatrixRing.
MatrixOpsRec: TYPE = RECORD [
diagonalMatrix: DiagonalMatrixConstructorOp,
transpose: AC.UnaryOp,
determinant: AC.StructuredToGroundOp
];
Matrix Ring and Matrix Algebra Constructors
MakeMatrixRing: PROC [elementStructure: AC.Structure, size: NAT] RETURNS [matrixRing: AC.Structure];
A particular matrixRing is defined by its elementStructure and its size. elementStructure can be a ring, field (although MakeMatrixAlgebra should be used in this case), or algebra.
MakeMatrixAlgebra: PROC [elementField: AC.Structure, size: NAT] RETURNS [matrixAlgebra: AC.Structure];
Extract Matrix Operations from Class Property Lists
IsMatrixRing: PROC [structure: AC.Structure] RETURNS [BOOL];
Transpose: PROC [structure: AC.Structure] RETURNS [AC.UnaryOp];
Extract the transpose op from a $MatrixRing.
Determinant: PROC [structure: AC.Structure] RETURNS [AC.StructuredToGroundOp];
Extract the determinant op from a $MatrixRing.
Constructors
DiagMatrix: DiagonalMatrixConstructorOp;
Conversion and IO
ReadMatrix: PROC [in: IO.STREAM, size: NAT, elementStructure: AC.Structure] RETURNS [matrix: Matrix];
MatrixFromRope: PROC [in: Rope.ROPE, size: NAT, elementStructure: AC.Structure] RETURNS [out: Matrix];
MatrixToRope: PROC [in: Matrix, elementStructure: AC.Structure] RETURNS [out: Rope.ROPE];
WriteMatrix: PROC [in: Matrix, elementStructure: AC.Structure, out: IO.STREAM];
Arithmetic
Add: PROC [in1, in2: Matrix, elementStructure: AC.Structure] RETURNS [out: Matrix];
Negate: PROC [in: Matrix, elementStructure: AC.Structure] RETURNS [out: Matrix];
Subtract: PROC [in1, in2: Matrix, elementStructure: AC.Structure] RETURNS [Matrix];
Multiply: PROC [in1, in2: Matrix, elementStructure: AC.Structure] RETURNS [out: Matrix];
Invert: PROC [in: Matrix, elementField: AC.Structure] RETURNS [out: Matrix];
Divide: PROC [in1, in2: Matrix, elementField: AC.Structure] RETURNS [out: Matrix];
ScalarMultiply: PROC [scalar: REF, inMatrix: Matrix, elementField: AC.Structure] RETURNS [outMatrix: Matrix];
Matrix Operations
Equal: PROC [in1, in2: Matrix, elementStructure: AC.Structure] RETURNS [BOOL];
Transp: PROC [in: Matrix] RETURNS [out: Matrix];
Det: PROC [in: Matrix, elementStructure: AC.Structure] RETURNS [value: REF];
END.