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.
Maximum number of columns and/or rows to print. NIL: no elements, T: all elements.
Format of matrix element field to be printed. A useful format is "~10,2,2E" for debugging purposes.
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.
A general sparse tensor class which is implemented as a sparse vector containing full-or sparse tensor entries.
Superclasses: TENSOR
Direct slots:
- RANK: Tensor rank.
- INDICES: The (nonzero) indices of the first slot.
- ENTRIES: The (nonzero) entries of the first slot.
Abstract class for sparse vectors.
Superclasses: <VECTOR>
Direct slots:
- MULTIPLICITY: Multiplicity of the sparse vector. A multiplicity different from 1 is used when handling multiple right-hand sides and solutions simultaneously.
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:
- MATRIX: The "supermatrix".
- ROW-KEYS: The row indices of the submatrix.
- COL-KEYS: The column indices of the submatrix.
If suggest and require are NIL, returns which of
:rowor:columnis prefered for mat. Otherwise determine if the order in suggest or require is acceptable without serious performance hit.
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:
- PATTERN: A compressed pattern.
A compressed sparse pattern. Note: we use int32 vectors for
startsandindices, such that they do not have to be copied for a call to the alien sparse solvers.Direct slots:
- SIZES: Vector of matrix sizes, at the moment only length 2 is allowed here. The first is the dimension which is not compressed, the second is the dimension which gets compressed.
- ORIENTATION: Denotes if rows or columns are compressed.
- STARTS: Vector with start indices of compressed columns/rows.
- INDICES: Vector with compressed row/column indices.
- OFFSETS: Vector of offsets. This is only non-nil, if the pattern supports identification.
This routine computes the determinant using a given LR decomposition.
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.
Usage: (dotensor (entry tensor :depth 1) ...) (dotensor ((index1 ... . entry) tensor :depth 1) ...) (dotensor ((index1 ...) tensor :depth 1) ...)
Loops on indices and entries of a vector, matrix or tensor. Examples:
(dovec (entry vec) ...) (dovec ((entry key1 ...) vec) ...)
Extends A such that the keys in extend which are not in ignore are mapped to identity.
Extract a subvector or submatrix from a sparse vector/matrix.
Returns the nxn identity matrix. The value is freshly allocated.
Calls func on all entries of the collection object and their corresponding keys.
Calls func on all entries of vec and their corresponding vector indices. The index used should be unserstood by
vref.
Superclasses: TENSOR
Direct slots:
- DIMENSIONS: The dimensions of the tensor.
- OFFSET0: An initial offset into the store-vector which defaults to 0.
- OFFSETS: The offsets for the different dimensions. This is internal information computed at tensor construction time.
Dispatches on the optional job argument (member :nn :tn :nt :tt) and calls the corresponding generic function, e.g. GEMM-NN!.
General matrix-matrix multiplication: Z <- alpha * X' * Y' + beta * Z
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.
Solves the PA=LU decomposition specified by LU and ipiv for the rhs b. The result is stored in b.
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.
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.
Checks if the range of indices of two sparse matrices is disjoint.
Joins matrices either horizontally or vertically depending on orientation. Due to the call to
zerosthis is not yet a generic function.
Compute an instance for storing the join of orientation applied to matrix and matrices.
Returns NIL, if svec cannot extend automatically when being accessed. Otherwise returns a function mapping keys to vector block sizes.
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.
Generates a sparse matrix for a 1-dimensional Laplace problem discretized with the 3-point stencil on a structured mesh.
Adds increment to result which should be a symbol. If its value is nil then result is set to increment.
Generates a real matrix as specified by its arguments. If two arguments are provided, they should be numbers which are interpreted as rows and columns. If only one argument is provided, it should be either a number meaning the rows and columns of a square matrix or a nested list or vector structure defining the contents matrix.
Generates an instance of a tensor with DOUBLE-FLOAT entries and the given dimensions.
Extract a submatrix of size nrows times ncols out of x starting from position from-row/from-col.
Extract matrix X out of matrix Y from the position given by ROW-OFFSET and COL-OFFSET.
Returns T, if mat is the identity, i.e. if the elementwise difference to the identity is not larger than threshold.
Inject matrix X in matrix Y at the position given by ROW-OFFSET and COL-OFFSET.
Returns a random nxn or (if m is provided) nxm matrix. The value is freshly allocated.
Returns T if each entry of x is smaller or equal than threshold.
Returns nxn or (if m is provided) nxm ones. The value is freshly allocated.
Checks if index range and index domain of some matrix are disjoint.
Can be used for obtainint a diagonal modification to get ILU_mod.
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.
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.
Transforms all or a part of svec corresponding to the keys in keys and maybe the ranges in 'ranges' to a matlisp matrix.
Defines the programmatic class
standard-matrixfor element type type as extensions of the programmatic classstore-vector.
Superclasses: <MATRIX>
Direct slots:
- NROWS: Number of rows in the matrix
- NCOLS: Number of columns in the matrix
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 functionscalar-type.Superclasses: <VECTOR>
Direct slots:
- STORE: The vector entries.
Applies func to each index of tensor up to depth. job can be :entry, :index, or :both.
Returns a freshly created copy of the i-th carthesian unit vector in dimension dim.