8.0.0.3. Linear Algebra |
(packages/libnum/linalgebra.lsh) |

This provides such things as linear system solving, matrix inverse, eigenvalues of symmetric matrices, and singular value decomposition for real and complex matrices. Most functions have two version, a "high-level" version (generally a macro) which allocates and returns results and does not touch the input arguments, and "low-level" version which writes results into pre-allcoated arguments and which may overwrite the content of input arguments. The low-level versions avoid allocation and copy that may be unnecessary. They are identified with the

8.0.0.3.0. eigenvalues, eigenvectors |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.0.0. (eigen-symm m) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvalues of symmetric real matrix

8.0.0.3.0.1. (eigen-symmv m eigenvec) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvalues of symmetric real matrix

8.0.0.3.0.2. (eigen-herm m) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvalues of Hermitian complex matrix

8.0.0.3.0.3. (eigen-hermv m eigenvec) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvalues of Hermitian complex matrix

8.0.0.3.1. matrix decompositions (SVD, LU cholesky, QR, tridigonal, householder). |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.1.0. SVD: singular value decomposition |
(packages/libnum/linalgebra.lsh) |

[from the GSL manual]: A general rectangular

8.0.0.3.1.0.0. (svd A V S) |
(packages/libnum/linalgebra.lsh) |

[from the GSL manual]: This function factorizes the

(setq a [[1 2][3 4][5 6]]) (setq v (double-matrix 2 2)) (setq s (double-matrix 2)) (svd a v s)

8.0.0.3.1.1. LU decomposition |
(packages/libnum/linalgebra.lsh) |

[from the GSL manual] A general square matrix A has an LU decomposition into upper and lower triangular matrices,

The following functions factorize the square matrix **
a **into the LU decomposition **PA = LU **
. On output the diagonal and upper triangular part of the argument **
lu **contain the matrix U, and the lower triangular part
(excluding the diagonal) contains L. The diagonal elements of L are
unity, and are not stored. The permutation matrix P is encoded in the
permutation argument **p **, which is an
idx1 of int. The j-th column of the matrix P is given by the k-th column
of the identity matrix, where **k = pj **
the j-th element of the permutation vector. The sign of the permutation
is returned as an int. It has the value **(-1)^q **
, where **q **is the number of
interchanges in the permutation. The algorithm used in the decomposition
is Gaussian Elimination with partial pivoting (Golub & Van Loan, Matrix
Computations, Algorithm 3.4.1).

8.0.0.3.1.1.0. (lu-decomp a p lu) |
(packages/libnum/linalgebra.lsh) |

Compute LU decomposition of real square matrix

8.0.0.3.1.1.1. (lu-decomp-complex a p lu) |
(packages/libnum/linalgebra.lsh) |

Compute LU decomposition of real square matrix

8.0.0.3.1.2. Cholesky decomposition |
(packages/libnum/linalgebra.lsh) |

[from the GSL manual] A symmetric, positive definite square matrix

8.0.0.3.1.2.0. (cholesky-decomp A) |
(packages/libnum/linalgebra.lsh) |

This function factorizes the positive-definite square matrix

8.0.0.3.2. solution of linear systems. |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.2.0. (solve-sv a b) |
(packages/libnum/linalgebra.lsh) |

This function solves a (possibly non-square) system

8.0.0.3.2.1. (solve-hh a b) |
(packages/libnum/linalgebra.lsh) |

This function solves the system A x = b using the Householder transformations. The solution is returned.

8.0.0.3.2.2. (solve-lu a b) |
(packages/libnum/linalgebra.lsh) |

This function solves the system A x = b using the LU decomposition. The solution is returned.

8.0.0.3.2.3. (solve-lu-complex a b) |
(packages/libnum/linalgebra.lsh) |

This function solves the complex system A x = b using the LU decomposition. The solution is returned.

8.0.0.3.3. matrix inverse |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.3.0. (inverse-lu a) |
(packages/libnum/linalgebra.lsh) |

return the inverse of square matrix

8.0.0.3.3.1. (inverse-lu-complex a) |
(packages/libnum/linalgebra.lsh) |

return the inverse of square complex matrix

8.0.0.3.4. matrix determinant |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.4.0. (determinant-lu a) |
(packages/libnum/linalgebra.lsh) |

return the determinant of square matrix

8.0.0.3.4.1. (determinant-lu-complex a) |
(packages/libnum/linalgebra.lsh) |

return the determinant of square complex matrix

8.0.0.3.4.2. (log-determinant-lu a) |
(packages/libnum/linalgebra.lsh) |

return the log of the determinant of square matrix

8.0.0.3.4.3. (log-determinant-lu-complex a) |
(packages/libnum/linalgebra.lsh) |

return the log of the determinant of square complex matrix

8.0.0.3.4.4. (sign-determinant-lu a) |
(packages/libnum/linalgebra.lsh) |

return the sign of the determinant of square matrix

8.0.0.3.4.5. (sign-determinant-lu-complex a) |
(packages/libnum/linalgebra.lsh) |

return the log of the determinant of square complex matrix

8.0.0.3.5. low-level functions |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.5.0. eigenvalues, eigenvectors |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.5.0.0. (eigen-symm-inplace m eigenval) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvalues of symmetric real matrix

8.0.0.3.5.0.1. (eigen-symmv-inplace m eigenvec eigenval) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvectors and eigenvalues of symmetric matrix

8.0.0.3.5.0.2. (eigen-herm-inplace m eigenvec eigenval) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvalues of Hermitian complex matrix

8.0.0.3.5.0.3. (eigen-hermv-inplace m eigenvec eigenval) |
(packages/libnum/linalgebra.lsh) |

Compute eigenvalues and eigenvectors of Hermitian complex matrix

8.0.0.3.5.1. matrix decompositions |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.5.1.0. (svd-inplace A V S) |
(packages/libnum/linalgebra.lsh) |

[from the GSL manual]: This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T. On output the matrix A is replaced by U. The diagonal elements of the singular value matrix S are stored in the vector S. The singular values are non-negative and form a non-increasing sequence from S_1 to S_N. The matrix V contains the elements of V in untransposed form. To form the product U S V^T it is necessary to take the transpose of V. This routine uses the Golub-Reinsch SVD algorithm. Content of matrix

(setq a [[1 2][3 4][5 6]]) (setq v (double-matrix 2 2)) (setq s (double-matrix 2)) (svd-inplace a v s)

8.0.0.3.5.1.1. (lu-decomp-inplace a p signum) |
(packages/libnum/linalgebra.lsh) |

Compute LU decomposition of real square matrix

8.0.0.3.5.1.2. (lu-decomp-complex-inplace a p signum) |
(packages/libnum/linalgebra.lsh) |

Compute LU decomposition of real square matrix

8.0.0.3.5.1.3. (cholesky-decomp-inplace a) |
(packages/libnum/linalgebra.lsh) |

computes the Cholesky decomposition of symmetrix positive definite matrix

8.0.0.3.5.2. solution of linear systems. |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.5.2.0. (solve-sv-inplace a b x) |
(packages/libnum/linalgebra.lsh) |

[adapted from the GSL manual]: This function solves the linear system A*x=b using singular value decomposition. the result vector is written in

8.0.0.3.5.2.1. (solve-hh-inplace a b) |
(packages/libnum/linalgebra.lsh) |

This function solves the system A x = b in-place using Householder transformations. On input

(setq a [[1 2][3 4]]) = [[ 1.00 2.00 ] [ 3.00 4.00 ]] ? (setq b [4 4]) = [ 4.00 4.00 ] ? (solve-hh a b) = 0 ? b = [-4.00 4.00 ]

8.0.0.3.5.2.2. (solve-lu-inplace a b) |
(packages/libnum/linalgebra.lsh) |

This function solves the system A*x=b using LU decomposition. the result is put in

8.0.0.3.5.2.3. (solve-lu-complex-inplace a b) |
(packages/libnum/linalgebra.lsh) |

This function solves the complex system A*x=b using LU decomposition. the result is put in

8.0.0.3.5.2.4. matrix inverse |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.5.2.5. (inverse-lu-inplace a i) |
(packages/libnum/linalgebra.lsh) |

This function computes the inverse of a matrix

8.0.0.3.5.2.6. (inverse-lu-complex-inplace a i) |
(packages/libnum/linalgebra.lsh) |

This function computes the inverse of a matrix

8.0.0.3.5.2.7. matrix determinant |
(packages/libnum/linalgebra.lsh) |

8.0.0.3.5.2.7.0. (determinant-lu-inplace a) |
(packages/libnum/linalgebra.lsh) |

compute the determinant of a matrix

8.0.0.3.5.2.7.1. (determinant-lu-complex-inplace a) |
(packages/libnum/linalgebra.lsh) |

compute the determinant of a matrix

8.0.0.3.5.2.7.2. (log-determinant-lu-inplace a) |
(packages/libnum/linalgebra.lsh) |

compute the log of the absolute value of the determinant of real matrix

8.0.0.3.5.2.7.3. (log-determinant-lu-complex-inplace a) |
(packages/libnum/linalgebra.lsh) |

compute the log of the absolute value of the determinant of real matrix

8.0.0.3.5.2.7.4. (sign-determinant-lu-inplace a) |
(packages/libnum/linalgebra.lsh) |

compute the log of the absolute value of the determinant of real matrix

8.0.0.3.5.2.7.5. (sign-determinant-lu-complex-inplace a) |
(packages/libnum/linalgebra.lsh) |

compute the log of the absolute value of the determinant of real matrix

8.0.0.3.6. interfacing other GSL linear algebra functions to Lush |
(packages/libnum/linalgebra.lsh) |

A simple set of macros is provided to allow calling GSL functions that manipulate vectors and matrices from Lush. GSL accesses vectors and matrice data through a set of access structures that are similar to Lush's IDX but slightly different. Before calling a GSL function from Lush, one must create these structures. Here is a simple example of how to call GSL's linear system solver using householder decomposition:

(de solve-hh-inplace (a b) ((-idx2- (-double-)) a) ((-idx1- (-double-)) b) (let ((ret 0)) ((-int-) ret) #{{ gsl_matrix ga; gsl_vector gb; IDX2GSL_MATRIX($a,ga,double); IDX2GSL_VECTOR($b,gb,double); $ret = gsl_linalg_HH_svx(&ga,&gb); }#} ret))The macros

8.0.0.3.6.0. IDX2GSL_VECTOR(idx1,gslvector,type) |
(packages/libnum/linalgebra.lsh) |

a C macro that converts a Lush IDX structure

8.0.0.3.6.1. IDX2GSL_MATRIX(idx2,gslmatrix,type) |
(packages/libnum/linalgebra.lsh) |

a C macro that converts a Lush IDX structure

8.0.0.3.6.2. IDX2GSL_VECTOR_COMPLEX(idx2,gslvectorcomplex,type) |
(packages/libnum/linalgebra.lsh) |

a C macro that converts a Lush IDX structure

8.0.0.3.6.3. IDX2GSL_MATRIX_COMPLEX(idx3,gslmatrixcomplex,type) |
(packages/libnum/linalgebra.lsh) |

a C macro that converts a Lush IDX structure

8.0.0.3.6.4. IDX2GSL_PERMUTATION(idx1,gslpermutation) |
(packages/libnum/linalgebra.lsh) |

a C macro that converts a Lush IDX structure