The rbmat.cpl and cbmat.cpl libraries add matrix algebra to CPL. The same functions and operators are defined in both, for real and complex numbers respectively, and therefore their result type is indicated as just number in what follows. Wherever a square matrix is expected, a banded matrix in compact rectangular form may also be used; the latter is recognized from its dimensions not being equal, and is defined as having the value zero of its second index as the diagonal. Most of the following functions have an equivalent infix form that allows matrix operations to be specified in the usual algebraic notation.
The operands of matrix operations undergo automatic (cpl)realignment.`
SUBROUTINE MatEqu(POINTER TO ARRAY(∗,∗) OF number c; number a)
Assigns the scalar (REAL or COMPLEX) value <a> to the diagonal elements of matrix <c>, and zeros all the non-diagonal elements.
Equivalent infix notation: c = a
SUBROUTINE LeftLUDiv(POINTER TO ARRAY(∗) OF number x; ARRAY(∗,∗) OF number A; ARRAY(∗) OF number t)
Computes the left-hand division of vector <t> by the previously LU-decomposed matrix <A>, that is A^-1∗t. A must have been preventively treated with either LUdecomp or PLU.
Equivalent infix notation: A \ t
SUBROUTINE RightLUDiv(ARRAY(∗) OF number x^,t; ARRAY(∗,∗) OF number A)
Computes the right-hand division of vector <t> by the previously LU-decomposed matrix <A>, that is t∗A^-1. A must have been preventively treated with either LUdecomp or PLU.
Equivalent infix notation: t / A
Page: (matrix)Lanczos, Next: PLU, Prev: RightLUDiv, Up: TopIndex SUBROUTINE Lanczos(POINTER TO ARRAY(∗) OF number x
SUBROUTINE[ARRAY(∗) OF number v2^,v1] A,AT
ARRAY(∗) OF number y1; REAL eps) SUBROUTINE Lanczos(POINTER TO ARRAY(∗) OF number x
ARRAY(∗,∗) OF number M
ARRAY(∗) OF number y1; REAL eps)
POINTER TO INVMAT FUNCTION PLU(ARRAY(∗,∗) OF number m)
Computes the LU decomposition of (necessarily square) matrix A with pivoting. Returns an appropriate INVMAT compound variable containing the LU decomposition of A, which can be passed to either LeftLUDiv or RightLUDiv and must be explicitly freed by FREE:(cpl)NEW. once no longer needed.
Page: (matrix)INVERT, Next: DET, Prev: PLU, Up: TopIndex
SUBROUTINE INVERT(ARRAY(∗,∗) OF number mat^, RESULT^)
Returns the inverse of square matrix <mat> in matrix <RESULT>. Uses PLU internally.
SUBROUTINE INVERT(number m^(∗,∗))
Computes the inverse of square matrix <mat> in place. Uses PLU internally.
Returns the determinant of square matrix <mat>. Uses PLU internally.
Page: (matrix)infix notation, Prev: DET, Up: TopIndex
Infix vector and matrix operations
and their equivalent (cpl)Einstein convention notation: (In the following examples small letters denote 1D arrays, capital letters 2D arrays. Actual, capitalized or not, names are at the user's discretion.)
x ∗ y = x($i)∗y($i)
x | y = CONJG[x($i)]∗y($i)
y = A ∗ x => y($i) = A($i,$j)∗x($j)
y = A | x => y($i) = CONJG[A($i,$j)]∗x($j)
y = x ∗ A => y($j) = x($i)∗A($i,$j)
y = x | A => y($j) = CONJG[x($i)]∗A($i,$j)
C = A ∗ B => C($i,$j) = A($i,$k)∗B($k,$j)
C = A | B => C($i,$j) = CONJG[A($i,$k)]∗B($k,$j)
x = A \ y => LeftLUDiv(x,A,y)
x = y / A => RightLUDiv(x,y,A)
C = A \ B => C(∗,$j) = A\B(∗,$j)
C = B / A => C($i,∗)=B($i,∗)/A
(The last four expressions only make sense if A has been obtained from LUdecomp or PLU; LUdecomp applies to both square and banded matrices.)
The above product operations can also be combined with linear-space (cpl)ARRAY operations already provided outside the rbmat and cbmat packages.
For more general, or higher-dimensional, index contractions, or just for added clarity, you can always use the (cpl)Einstein convention directly.