scid.linalg

This module contains functions related to linear algebra.

For the time being these functions are just a user-friendly interface to the corresponding LAPACK functions. Hence, one can only use matrices and vectors where the elements are of FORTRAN-compatible types, namely:
    float
    double
    cfloat
    cdouble
Specifically, real- and creal-valued matrices/vectors cannot be used.

Note:
Some of the functions in this module come in two forms with the same function signature, but where the name of one ends with an underscore. An example is
    solve(a, b)
    solve_(a, b)
The difference between these is that, for performance reasons, the underscore-suffixed functions use some or all of the input matrices/vectors as a workspace, and one can't expect them to contain the same values after the function returns. The functions without an underscore suffix simply copy the input data and calls the high-performance function using the copied data as input.

Authors:
Lars Tandle Kyllingstad

License:
Boost License 1.0

Real[] solve (MatrixViewA, Real)(const MatrixViewA a, const Real[] b, Real[] buffer = null);
Real[] solve_ (MatrixViewA, Real)(MatrixViewA a, Real[] b);
MatrixViewB solve (MatrixViewA, MatrixViewB)(const MatrixViewA a, const MatrixViewB b);
MatrixViewB solve_ (MatrixViewA, MatrixViewB)(MatrixViewA a, MatrixViewB b);
Solve one or more systems of n linear equations in n variables.

The set of equations is given on the form AX=B, where A is an n-by-n matrix and X and B are either vectors of length n (one system of n equations in n variables) or n-by-m matrices (m systems of n equations in n variables). Given A and B as input, this function returns X.

Examples:
Solving a system of equations:
    MatrixView!double a = ...
    double[] b = ...
    double[] x = solve(a, b);
Solving several systems of equations:
    MatrixView!double a = ...
    MatrixView!double b = ...
    MatrixView!double x = solve(a, b);


DetType!(MatrixView!(T,stor)) det (T, Storage stor)(const MatrixView!(T,stor) m);
DetType!(MatrixView!(T,stor)) det_ (T, Storage stor)(MatrixView!(T,stor) m);
Calculate the determinant of a square matrix.

The type of the return value depends on the element type of the matrix. For float or double matrices the determinant is of type real, and for cfloat or cdouble matrices the determinant is of type creal. The reason for choosing the widest type is that determinants are often very big numbers, and therefore tend to overflow.

Examples:
    import scid.matrix;
    ...
    auto m = matrix!double(2, 2);
    m[0,0] = 1.0;  m[0,1] = 2.0;
    m[1,0] = 3.0;  m[1,1] = 4.0;

    auto d = det(m);
    writeln(d);   // Prints "-2"


EigenvalueType!(ElementT)[] eigenvalues (ElementT)(MatrixView!(ElementT) m);
ComplexT[] eigenvalues (ElementT, ComplexT)(MatrixView!(ElementT) m, ComplexT[] buffer);
EigenvalueType!(ElementT)[] eigenvalues_ (ElementT)(MatrixView!(ElementT) m);
ComplexT[] eigenvalues_ (ElementT, ComplexT)(MatrixView!(ElementT) m, ComplexT[] buffer);
Calculate the eigenvalues of a general dense square matrix.

If some eigenvalues cannot be calculated, the algorithm throws an EigenvalueException containing an array of the ones that have been calculated.

Params:
m An n-by-n symmetric matrix.
buffer (optional) A buffer for the returned values, must have length >= n and type Complex!T[].

Examples:
    auto m = matrix!double(3, 3);
    ...
    auto e = eigenvalues(m);


T[] eigenvalues (T, Storage stor, Triangle tri)(MatrixView!(T,stor,tri) m, T[] buffer = null);
Calculate the eigenvalues of a triangular matrix. Note that this is a trivial operation - the function just returns the diagonal entries of the matrix.

Params:
m An n-by-n triangular matrix.
buffer (optional) A buffer for the returned values, must have length >= n.

T[] eigenvalues (T, Storage stor, Triangle tri)(MatrixView!(T,stor,tri) m, T[] buffer = null);
T[] eigenvalues_ (T, Storage stor, Triangle tri)(MatrixView!(T,stor,tri) m, T[] buffer = null);
Calculate the eigenvalues of a symmetric matrix.

Params:
m An n-by-n symmetric matrix.
buffer (optional) A buffer for the returned values, must have length >= n.

class EigenvalueException (T): Exception;
This exception is thrown when the eigenvalue() function fails to compute all eigenvalues. The ones that have been computed are stored in the member variable eigenvalues.

T eigenvalues ;
The computed eigenvalues .

void invert (T, Storage stor)(MatrixView!(T,stor) m);
Calculate the inverse of a matrix.

Currently only defined for general real matrices.

Page was generated with on Sat Jun 25 02:35:10 2011