The module MATRIX


linalg/MATRIX.H
It contains generic implementations on matrices, that can be used to build new linear algebra classes. The following signatures or definitions must at least be available for the type R:
      typedef typename size_type;    //type of the indices.
      typedef typename value_type;   //type of the coefficients.

      size_type  R::nbrow();
      size_type  R::nbcol();
      value_type R::operator()(size_type i, size_type j);
template < class R>  inline ostream & MATRIX::Print(ostream & os,const R & m)
Output function for general matrices. It is called by the output operator < <  of the classes of matrices.

template< class R>  inline istream & MATRIX::Read(istream & is, R & M)
Input function for general matrices. The input format is of the form m n c00 c0 ... where m is the number of rows, n is the number of columns and the coefficients are read row by row.

template< class R,class I>  inline void MATRIX::reserve(R & a, I m, I n)
Reserve in a the place to store a m× n matrix.

template< class R,class I, class C>  inline void MATRIX::reserve(R & a, I m, I n, const C & c)
Reserve in a the place to store a m× n matrix and set all its entries to c.

template < class R1, class R2>  inline void MATRIX::setequalto(R1 & r, const R2 & m)
Assignement of a dense matrix to another one, not necessarily of the same type.

template< class R>  inline typename R::value_type MATRIX::trace(const R & M)
Trace of a matrix.

template< class R,class S>  inline void MATRIX::plus(R & a, const S & b )
Inplace addition of matrices.

template< class R,class S>  inline void MATRIX::plus(R & a, const S & b, const S & c)
Addition of matrices of the same size. The required space should be allocated for a.

template< class R,class S>  inline void MATRIX::minus(R & a, const S & b )
Inplace substraction of matrices of the same size. The required space should be allocated for a.

template< class R>  inline void MATRIX::minus(R & a, const R & b, const R & c)
Substraction of matrices of the same size. The required space should be allocated for a.

template< class R,class S,class T>  inline void MATRIX::mult(R & a, const S & b, const T & c)
Multiplication of matrices. The required place should be allocated in a.

template< class R,class S>  inline void MATRIX::mult(R & a, const S & b)
Inplace multiplication of matrices.

template< class V,class M,class T>  inline void MATRIX::mult_vect(V & a, const M & b, const T & v)
Multiplication by a vector. The vector a should be first initialised with the correct size and zero entries.

template < class R>  void MATRIX::transpose(R & M)
Inplace transposition.



The module LINALG


linalg/LINALG.C

template< class Vect, class Mat>  void LINALG::svdx(Vect & S, const Mat & A, Mat & Us, Mat & V)
Singular value decomposition of the matrix A. The singular values are output in S. In output, the matrix Us is the product of an orthogonal matrix by the diagnonal matrix of singular values, V is an orthogonal matrix and we have A = Us * Transpose(V). The matrix A is not modified but copied first in Us. If A is an m× n matrix, Us is m× m and V is n × n.

The necessary memory space
must be allocated in S and V, before calling this function: S should be of size Max(A.nbrow(),A.nbcol()) and V of size (A.nbcol(),A.nbcol()). The matrix Us need not be preallocated, for it is assigned to a copy of A (Us=A).

It requires the functions or operators
Norm, sqrt, +,-,*,/, < = for the coefficient field.

template < class R>  typename R::value_type LINALG::triang(Bareiss m,R & M)
Bareiss method. The operations are performed inplace. The output value is the last element on the diagonal. If the matrix is invertible, it's its determinant. Triang, BareissDet, Bareiss

template< class R>  typename R::size_type LINALG::rank(const R & M)
Rank. Based on svd computations. Rank, SVD