Next: , Previous: , Up: Reference manual   [Contents][Index]


7.10 Package FL.MATLISP

This package provides a Common Lisp version of full matrices with elements being numbers of a given type. Those classes are automatically generated when needed. It provides also part of the BLAS and LAPACK operations for those matrices. The corresponding methods are automatically compiled for the given matrix classes. The interface is very similar to the library Matlisp (Matlisp), which provides a CLOS interface to the Fortran BLAS and LAPACK routines.

Variable: *MZEROP-THRESHOLD*

Threshold below which a matrix is considered to be zero.

Variable: *PRINT-MATRIX*

Maximum number of columns and/or rows to print. NIL: no elements, T: all elements.

Variable: *PRINT-MATRIX-ELEMENT-FORMAT*

Format of matrix element field to be printed. A useful format is "~10,2,2E" for debugging purposes.

Variable: *PRINT-TENSOR*

Maximum number of columns and/or rows to print. Set this to NIL to print no cells (same as *PRINT-ARRAY* set to NIL). Set this to T to print all cells of the tensor.

Class: <MATRIX>

General matrix class.

Superclasses: <VECTOR>

Class: <SPARSE-MATRIX>

Abstract class for sparse matrices.

Superclasses: <MATRIX>

Class: <SPARSE-TENSOR>

A general sparse tensor class which is implemented as a sparse vector containing full-or sparse tensor entries.

Superclasses: TENSOR

Direct slots:

Class: <SPARSE-VECTOR>

Abstract class for sparse vectors.

Superclasses: <VECTOR>

Direct slots:

Class: <SUBMATRIX>

Describes an ordered submatrix of a matrix. Only a restricted set of operations is allowed for these matrices and element access is slow. They are indexed with ordinary integers.

Superclasses: <MATRIX>

Direct slots:

Class: <VECTOR>

General vector class.

Function: ACCESS-TYPE MAT &KEY SUGGEST REQUIRE

If suggest and require are NIL, returns which of :row or :column is prefered for mat. Otherwise determine if the order in suggest or require is acceptable without serious performance hit.

Function: ADD-SVEC-TO-LOCAL-BLOCK SVEC LOCAL-VEC &OPTIONAL KEYS RANGES

Copies a local block in matlisp format into a <ht-sparse-vector>.

Function: AREA-OF-SPAN MAT

Computes the volume spanned by the columns of mat.

Function: AXPY ALPHA X Y

Returns alpha X + Y. Uses AXPY! and COPY.

Function: AXPY! ALPHA X Y

Y <- alpha*X + Y

Function: BLOCKS VEC

Returns a dictionary mapping keys to entries for vec.

Function: COL-KEYS MAT

All column keys for a matrix.

Function: COMBINED-PROJECTION P1 P2

Returns a projection to the range of the given projections.

Function: COMPRESSED->MATLISP CM

Converts a compressed matrix into matlisp format.

Function: COMPRESSED-MATRIX TYPE

Construct a compressed sparse matrix with entries of type.

Class: COMPRESSED-MATRIX

A compressed sparse matrix. This is an abstract class which is made concrete by mixing it with a store-vector containing the entries.

Superclasses: <MATRIX>

Direct slots:

Class: COMPRESSED-PATTERN

A compressed sparse pattern. Note: we use int32 vectors for starts and indices, such that they do not have to be copied for a call to the alien sparse solvers.

Direct slots:

Function: COPY X

Returns a deep copy of X.

Function: COPY! X Y

Y <- X

Function: DET MAT

Returns the determinant of the square matrix mat.

Function: DET-FROM-LR LR PIVOT

This routine computes the determinant using a given LR decomposition.

Function: DIAG VEC

Returns a diagonal matrix with diagonal entries from vec.

Function: DIAGONAL A

Extracts the diagonal from matrix A as a vector.

Function: DIAGONAL-SPARSE-TENSOR VALUES &OPTIONAL NCOMPS

Constructs a sparse tensor of rank 2 where values are the diagonal entries. If ncomps is given then the tensor dimension is nxn with each diagonal entry being values.

Function: DISPLAY MATRIX &KEY (STREAM T) ORDER COL-ORDER ROW-ORDER &ALLOW-OTHER-KEYS

Formats the contents of matrix in rectangular form.

Macro: DOCOLS (KEY MAT) &BODY BODY

Syntax:

(docols (key mat) ...)
Macro: DOROWS (KEY MAT) &BODY BODY

Syntax:

(dorows (key mat) ...)
Function: DOT X Y

Returns the dot product of X and Y.

Function: DOT-ABS X Y

Returns the dot product between |X| and |Y|.

Macro: DOTENSOR (ARGS TENSOR &KEY DEPTH) &BODY BODY

Usage: (dotensor (entry tensor :depth 1) ...) (dotensor ((index1 ... . entry) tensor :depth 1) ...) (dotensor ((index1 ...) tensor :depth 1) ...)

Function: DOUBLE-VEC &REST COMPS

Returns a double-vec with the entries in comps.

Type: DOUBLE-VEC

Uniform double-float vector.

Macro: DOVEC (LOOP-VARS VEC &OPTIONAL RESULT) &BODY BODY

Loops on indices and entries of a vector, matrix or tensor. Examples:

  (dovec (entry vec) ...)
  (dovec ((entry key1 ...) vec) ...)
Function: ELEMENT-TYPE VECTOR

Type of the elements of the vector/matrix.

Function: ENSURE-MATLISP OBJ &OPTIONAL TYPE

Tries to coerce obj into Matlisp format.

Function: ENTRIES OBJECT

List of entries.

Function: ENTRY-ALLOWED-P TENSOR &REST INDICES

Tests if an entry is allowed at this position.

Function: EXTEND-BY-IDENTITY MAT EXTEND &KEY IGNORE (COPY T)

Extends A such that the keys in extend which are not in ignore are mapped to identity.

Function: EXTRACT-IF TEST SVEC &ALLOW-OTHER-KEYS

Extract a subvector or submatrix from a sparse vector/matrix.

Function: EXTRACT-VALUE-BLOCKS SOBJ KEYS &OPTIONAL COL-KEYS

Extract a vector or array of value blocks from sobj.

Function: EYE N &OPTIONAL (M N) (TYPE (QUOTE DOUBLE-FLOAT))

Returns the nxn identity matrix. The value is freshly allocated.

Function: FILL! X S

Fills X with element s.

Function: FILL-RANDOM! X S

Fills X with random values (obtained by (random s)).

Function: FOR-EACH-COL-KEY FUNC MAT

Loop through column keys.

Function: FOR-EACH-ENTRY FUNC VEC

Calls func on all entries of vec.

Function: FOR-EACH-ENTRY-AND-KEY FUNC OBJECT

Calls func on all entries of the collection object and their corresponding keys.

Function: FOR-EACH-ENTRY-AND-VECTOR-INDEX FUNC VEC

Calls func on all entries of vec and their corresponding vector indices. The index used should be unserstood by vref.

Function: FOR-EACH-ENTRY-IN-COL FUNC MAT COL-KEY

Loop through entries in column col.

Function: FOR-EACH-ENTRY-IN-ROW FUNC MAT ROW-KEY

Loop through col-keys in row.

Function: FOR-EACH-KEY FUNC VEC

Calls func on all indices/keys of vec.

Function: FOR-EACH-KEY-AND-ENTRY-IN-COL FUNC MAT COL-KEY

Loop through row-keys and entries in col.

Function: FOR-EACH-KEY-AND-ENTRY-IN-ROW FUNC MAT ROW-KEY

Loop through col-keys and entries in row.

Function: FOR-EACH-KEY-IN-COL FUNC MAT COL-KEY

Loop through row-keys in column col.

Function: FOR-EACH-KEY-IN-ROW FUNC MAT ROW-KEY

Loop through col-keys in row.

Function: FOR-EACH-ROW-KEY FUNC MAT

Loop through row keys.

Function: FULL-COMPRESSED-PATTERN NROWS NCOLS &OPTIONAL (ORIENTATION COLUMN)

Returns a full compressed pattern.

Function: FULL-TENSOR TYPE

Construct a full tensor with entries of type.

Class: FULL-TENSOR

Mixin for full tensors.

Superclasses: TENSOR

Direct slots:

Function: GEMM ALPHA X Y BETA Z &OPTIONAL (JOB NN)

Rewriting of GEMM in terms of GEMM!.

Function: GEMM! ALPHA X Y BETA Z &OPTIONAL (JOB NN)

Dispatches on the optional job argument (member :nn :tn :nt :tt) and calls the corresponding generic function, e.g. GEMM-NN!.

Function: GEMM-NN! A X Y B Z

General matrix-matrix multiplication: Z <- alpha * X * Y + beta * Z

Function: GEMM-NT! A X Y B Z

General matrix-matrix multiplication: Z <- alpha * X * Y' + beta * Z

Function: GEMM-TN! A X Y B Z

General matrix-matrix multiplication: Z <- alpha * X' * Y + beta * Z

Function: GEMM-TT! A X Y B Z

General matrix-matrix multiplication: Z <- alpha * X' * Y' + beta * Z

Function: GESV A B

Rewriting for GESV in terms of GESV!.

Function: GESV! A B

Solves a linear system A X = B for X.

Function: GETRF X &OPTIONAL IPIV

Rewriting for GETRF in terms of GETRF!.

Function: GETRF! A &OPTIONAL IPIV

Computes the PA=LU decomposition of A which is stored again in A. ipiv can be a pre-allocated vector which the routine fills with the indices for column pivoting, or NIL which implies that the routine allocates such a vector itself. If ipiv is :none, no pivoting is done. Returns A as the first value, the pivot vector as a second value, and a boolean as the third value indicating that the decomposition succeeded.

Function: GETRS LU B &OPTIONAL IPIV

Rewriting for GETRS in terms of GETRS!.

Function: GETRS! LU B &OPTIONAL IPIV

Solves the PA=LU decomposition specified by LU and ipiv for the rhs b. The result is stored in b.

Function: GGEV A B &OPTIONAL JOB

Syntax: (GGEV A B [job])

Purpose: Computes the generalized eigenvalues and left/right eigenvectors of A - s B.

1. (GGEV A B :N) => lambda

Computes the generalized eigenvalues of A - s B.

2. (GGEV A B :V) => lambda, V, W

Computes generalized eigenvalues and eigenvectors of (A - sB).

A*V = B*V*diag(lambda), \ W'*A = diag(lambda)*W'*B

with V and W orthogonal (unitary).

Remark: The symmetric/hermitian counterpart of this routine is hegv.

Function: HEGV A B &OPTIONAL JOB

Syntax: (HEGV A B [job])

Purpose: Computes the generalized eigenvalues and left/right eigenvectors of A - s B for Hermitian matrices A and B.

1. (HEGV A B :N) => lambda

Computes the generalized eigenvalues of A - s B.

2. (HEGV A B :V) => lambda, V

Computes generalized eigenvalues and eigenvectors of (A - sB).

A*V = B*V*diag(lambda), \ W'*A = diag(lambda)*W'*B

with V and W orthogonal (unitary).

Remark: The non-symmetric counterpart of this routine is ggev.

Function: IN-PATTERN-P TENSOR &REST INDICES

Returns T, if the indices are in the nonzero pattern.

Function: INDEX-RANGE-DISJOINT-P MAT1 MAT2

Checks if the range of indices of two sparse matrices is disjoint.

Function: INT-VEC &REST COMPS

Returns a int-vec with the entries in comps.

Type: INT-VEC

Uniform int vector.

Function: JOIN ORIENTATION &REST MATRICES

Joins matrices either horizontally or vertically depending on orientation. Due to the call to zeros this is not yet a generic function.

Function: JOIN-HORIZONTAL! RESULT &REST MATRICES

Joins matrices horizontally into result.

Function: JOIN-INSTANCE ORIENTATION MATRIX &REST MATRICES

Compute an instance for storing the join of orientation applied to matrix and matrices.

Function: JOIN-VERTICAL! RESULT &REST MATRICES

Joins matrices vertically into result.

Function: KEY->SIZE SVEC

Returns NIL, if svec cannot extend automatically when being accessed. Otherwise returns a function mapping keys to vector block sizes.

Function: KEYS DIC

Returns a list of all keys of dic.

Function: KEYS-OF-COLUMN MAT KEY

All row keys in the given column for a matrix.

Function: KEYS-OF-ROW MAT KEY

All column keys in the given row for a matrix.

Function: L2-NORM X

Returns the 2-norm of x.

Function: LAPLACE-FULL-MATRIX N &OPTIONAL (DIM 1)

Generates the matrix for a dim-dimensional Laplace problem discretized with the 2*dim+1-point stencil on a structured mesh with Dirichlet boundary conditions.

Function: LAPLACE-SPARSE-MATRIX N

Generates a sparse matrix for a 1-dimensional Laplace problem discretized with the 3-point stencil on a structured mesh.

Function: LINF-NORM X

Returns the maximum norm of x.

Function: LP-NORM X P

Returns the p-norm of x.

Function: M* X Y

Multiply X by Y.

Function: M*-NT X Y

Multiply X by Y^t.

Function: M*-PRODUCT-INSTANCE X Y

Allocates an instance for the product of X and Y.

Function: M*-TN X Y

Multiply X^t by Y.

Function: M*-TN-PRODUCT-INSTANCE X Y

Allocates an instance for the product of X^t and Y.

Function: M+ X Y

Returns X + Y.

Function: M+! X Y

Y <- X + Y

Function: M- X Y

Returns X-Y. Uses AXPY.

Function: M-! X Y

Y - X -> Y. Uses AXPY!.

Macro: M-INCF RESULT INCREMENT

Adds increment to result which should be a symbol. If its value is nil then result is set to increment.

Function: M.* X Y

Returns X .* Y. Uses M.*! and COPY.

Function: M/ X

Returns the inverse of X.

Function: MAKE-DOUBLE-VEC DIM &OPTIONAL (INIT 0.0)

Returns a double-vec of length dim and initial value init.

Function: MAKE-REAL-MATRIX &REST ARGS

Generates a real matrix as specified by its arguments.

Function: MAKE-REAL-TENSOR DIMENSIONS

Generates an instance of a tensor with DOUBLE-FLOAT entries and the given dimensions.

Function: MAKE-REAL-VECTOR DIM &OPTIONAL (VALUE 0.0)

Generates a real matrix of dimension dim x 1.

Function: MAT-DIFF X Y

Prints a list of differences between X and Y.

Function: MATRIX-BLOCK SMAT ROW-KEY COL-KEY

Low-level block lookup for a sparse block matrix.

Function: MATRIX-COLUMN MAT COL-KEY

Returns a dictionary mapping row-key to entry.

Function: MATRIX-ROW MAT ROW-KEY

Returns a dictionary mapping col-key to entry.

Function: MATRIX-SLICE X &KEY FROM-ROW FROM-COL NROWS NCOLS (NCOLS (- (NCOLS MAT) FROM-COL)) (NROWS (- (NROWS MAT) FROM-ROW)) (FROM-COL 0) (FROM-ROW 0)

Extract a submatrix of size nrows times ncols out of x starting from position from-row/from-col.

Function: MATRIX-TRANSPOSE-INSTANCE X

Returns a zero matrix for storing the transpose of X.

Function: MEQUALP X Y

Returns T if X and Y have equal entries, otherwise NIL.

Function: MEXTRACT! X Y ROW-OFFSET COL-OFFSET

Extract matrix X out of matrix Y from the position given by ROW-OFFSET and COL-OFFSET.

Function: MIDENTITY-P NUMBER &OPTIONAL THRESHOLD

Returns T, if mat is the identity, i.e. if the elementwise difference to the identity is not larger than threshold.

Function: MINJECT! X Y ROW-OFFSET COL-OFFSET

Inject matrix X in matrix Y at the position given by ROW-OFFSET and COL-OFFSET.

Function: MRANDOM N &OPTIONAL M (TYPE (QUOTE DOUBLE-FLOAT)) (RANGE 1.0)

Returns a random nxn or (if m is provided) nxm matrix. The value is freshly allocated.

Function: MREF A I J

Returns the matrix element A[i,j].

Function: MSQUARE-P MAT

Returns T, iff mat is square.

Function: MSYMMETRIC-P MAT &KEY THRESHOLD OUTPUT (THRESHOLD 0.0)

Returns T, if mat is symmetric up to a accuracy in THRESHOLD. If output is T, the differences to symmetry are reported.

Function: MULTIPLICITY VEC

We allow multiple vectors, for solving linear problems in parallel.

Function: MZEROP X &OPTIONAL THRESHOLD

Returns T if each entry of x is smaller or equal than threshold.

Function: NCOLS MAT

Number of matrix columns.

Function: NORM X &OPTIONAL P

Returns the p-norm of x.

Function: NORMALIZE X &OPTIONAL (P 2)

Scales x to have p-norm equal to 1.

Function: NORMALIZE! X &OPTIONAL (P 2)

Scales x destructively to have p-norm equal to 1.

Function: NR-OF-ENTRIES VECTOR

Total number of (block) entries for vectors.

Function: NROWS MAT

Number of matrix rows.

Function: NUMBER-OF-NONZERO-ENTRIES PATTERN

Number of nonzero entries of a sparse matrix pattern.

Function: ONES N &OPTIONAL (M N) (TYPE (QUOTE DOUBLE-FLOAT))

Returns nxn or (if m is provided) nxm ones. The value is freshly allocated.

Function: RANGE-AND-DOMAIN-DISJOINT-P MAT

Checks if index range and index domain of some matrix are disjoint.

Function: RANK TENSOR

Rank of a tensor.

Function: REMOVE-COLUMN SMAT COL-KEY

Removes a column of smat.

Function: REMOVE-KEY SOBJ &REST INDICES

Remove the entry for key from the sparse object.

Function: REMOVE-ROW SMAT ROW-KEY

Removes a row of smat.

Function: ROW-KEYS MAT

All row keys for a matrix.

Function: ROW<-ID A KEY

Set the row of matrix A defined by KEY to identity

Function: SCAL ALPHA X

Returns alpha * X. Uses SCAL! and COPY.

Function: SCAL! ALPHA X

X <- alpha X

Function: SCALAR-TYPE VECTOR

Type of the scalars for the vector class.

Function: SET-SVEC-TO-LOCAL-BLOCK SVEC LOCAL-VEC &OPTIONAL KEYS RANGES

Copies a local block in matlisp format into a <sparse-vector>.

Function: SHIFT-DIAGONAL-INVERTER ETA

Can be used for obtainint a diagonal modification to get ILU_mod.

Function: SHOW MATRIX &KEY (STREAM T) KEYS (ZEROS T) &ALLOW-OTHER-KEYS

Shows the contents of matrix in a readable form.

Function: SLICE TENSOR FIXED

Slices tensor. fixed determines which indices are fixed.

Function: SPARSE-LDU A &KEY ORDERING INCOMPLETE (OMEGA 0.0) DIAGONAL-INVERTER &ALLOW-OTHER-KEYS

Sparse LDU decomposition

Function: SPARSE-M* A B &KEY JOB SPARSITY (SPARSITY A) (JOB NN)

Sparse matrix-matrix or matrix-vector multiplication. Usually, m* should be used. But in situations, where A or B are very sparse, the complexity of this routine is much lower.

Function: SPARSE-MATRIX->CCS A &KEY KEYS ROW-KEYS COL-KEYS RANGES ROW-RANGES COL-RANGES

Converts the sparse matrix A to CCS format. row-keys and col-keys may denote a submatrix, col-ranges and row-ranges may be used for extracting even subblocks of the entries. This is a rather difficult routine, which might suggest switching to CCS completely.

Function: SPARSE-MATRIX->MATLISP MAT &KEY KEYS ROW-KEYS COL-KEYS RANGES ROW-RANGES COL-RANGES &ALLOW-OTHER-KEYS

Converts sparse matrices into matlisp format.

Function: SPARSE-TENSOR CONTENTS

Constructor for sparse-tensor.

Function: SPARSE-VECTOR->MATLISP SVEC &OPTIONAL KEYS RANGES

Transforms all or a part of svec corresponding to the keys in keys and maybe the ranges in ’ranges’ to a matlisp matrix.

Function: STANDARD-MATRIX TYPE

Defines the programmatic class standard-matrix for element type type as extensions of the programmatic class store-vector.

Class: STANDARD-MATRIX

Mixin for dense matrices.

Superclasses: <MATRIX>

Direct slots:

Function: STANDARD-MATRIX-P OBJ

Tests if obj is a standard-matrix.

Class: STORE-VECTOR

This mixin yields vector behaviour for a class containing a store. The store is a unifom array with elements of a certain type which can be determined by the funtion element-type. It often is but does not have to be equal to the type of scalars for this vector which can be obtained by calling the function scalar-type.

Superclasses: <VECTOR>

Direct slots:

Function: SUBMATRIX MAT &KEY ROW-INDICES COL-INDICES

General extraction of submatrices specified by non-adjacent lists of row- and column indices.

Function: T* TENSOR1 TENSOR2 CONTRACTION-PAIRS

Contracts TENSOR1 and TENSOR2 along the pairs of indices specified by CONTRACTION-PAIRS.

Class: TENSOR

Tensor superclass.

Function: TENSOR-FOR-EACH FUNC TENSOR &KEY JOB DEPTH (JOB BOTH) &ALLOW-OTHER-KEYS

Applies func to each index of tensor up to depth. job can be :entry, :index, or :both.

Function: TENSOR-MAP FUNC TENSOR

Maps tensor with func to a tensor of the same type.

Function: TENSOR-REF TENSOR &REST INDICES

Reader for a tensor entry.

Function: TOTAL-ENTRIES VECTOR

Total number of entries for block vectors.

Function: TOTAL-NROWS MAT

Total number of rows for a matrix (works also for block matrices).

Function: TRANSPOSE X

Transpose the matrix x.

Function: TRANSPOSE! X Y

Sets Y to the transpose of X.

Function: TRANSPOSED-PATTERN PATTERN

Transpose a sparse matrix pattern.

Function: UINT-VEC &REST COMPS

Returns a uint-vec with the entries in comps.

Type: UINT-VEC

Uniform uint vector.

Function: UNIT-VECTOR DIM I

Returns a freshly created copy of the i-th carthesian unit vector in dimension dim.

Function: VECTOR-BLOCK SVEC KEY

Low-level key lookup. Returns NIL if there is no block at this position.

Function: VECTOR-SLICE X OFFSET SIZE

Extract a subvector of size size out of x starting from position offset.

Function: VLENGTH VEC

Length of vector.

Function: VREF X I

Reader for x_i.

Function: X<-0 X

X <- 0 X. Uses SCAL!.

Function: ZEROS N &OPTIONAL (M N) (TYPE (QUOTE DOUBLE-FLOAT))

Returns nxn or (if m is provided) nxm zeros. The value is freshly allocated.


Next: , Previous: , Up: Reference manual   [Contents][Index]