CPL
Page: (matrix)Top, Next: (graphics), Prev: (fft), Up: (cpl)Library

Matrix Operations

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.
Page: (matrix)MatEqu, Next: DotProduct, Prev: Top, Up: Top

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
Page: (matrix)DotProduct, Next: LeftMult, Prev: MatEqu, Up: Top

number FUNCTION DotProduct(ARRAY(∗) OF number a,b)

Computes the sum of products of the elements of <a> and <b>. Equivalent infix notation: a ∗ b

COMPLEX FUNCTION DotProduct2(ARRAY(∗) OF COMPLEX a,b)

Computes CONJG(a)∗b Equivalent infix notation: a | b
Page: (matrix)LeftMult, Next: RightMult, Prev: DotProduct, Up: Top

SUBROUTINE LeftMult(ARRAY(∗) OF number c^; ARRAY(∗,∗) OF number A; ARRAY(∗) OF number b)

Computes the left-hand product of matrix <A> by vector <b>, that is c(i)=SUM A(i,j)∗b(j) FOR ALL j Equivalent infix notation: A ∗ b
Page: (matrix)RightMult, Next: LUdecomp, Prev: LeftMult, Up: Top

SUBROUTINE RightMult(ARRAY(∗) OF number c^,a; ARRAY(∗,∗) OF number B)

Computes the right-hand product of vector <a> by matrix <B>, that is c(j)=SUM a(i)∗B(i,j) FOR ALL i Equivalent infix notation: a ∗ B

SUBROUTINE RightMult2(ARRAY(∗) OF COMPLEX c^,a; ARRAY(∗,∗) OF COMPLEX B)

Computes CONJG(a)∗B Equivalent infix notation: a | B
Page: (matrix)LUdecomp, Next: LeftLUDiv, Prev: RightMult, Up: Top

SUBROUTINE LUdecomp(POINTER TO ARRAY(∗,∗) OF number A)

Computes the LU decomposition of (square or banded) matrix A in place.

FUNCTION LU(A)

Returns the LU decomposition of A, which remains untouched.
Page: (matrix)LeftLUDiv, Next: RightLUDiv, Prev: LUdecomp, Up: Top

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
Page: (matrix)RightLUDiv, Next: Lanczos, Prev: LeftLUDiv, Up: Top

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: Top
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)
Page: (matrix)PLU, Next: INVERT, Prev: Lanczos, Up: Top

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: Top

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.
Page: (matrix)DET, Prev: INVERT, Up: Top

number FUNCTION DET(ARRAY(∗,∗) OF number mat)

Returns the determinant of square matrix <mat>. Uses PLU internally.