ConicBundle
Classes | Typedefs | Enumerations | Functions | Variables
CH_Matrix_Classes Namespace Reference

Matrix Classes and Linear Algebra. See Matrix Classes (namespace CH_Matrix_Classes) for a quick introduction. More...

Classes

class  Indexmatrix
 Matrix class for integral values of type Integer More...
 
class  IterativeSolverObject
 Abstract interface to iterative methods for solving Ax=b given by an IterativeSystemObject. More...
 
class  IterativeSystemObject
 Abstract base class for supplying the system for an iterative solver. More...
 
class  LanczMaxEig
 A Lanczos method allowing spectral transformation by Chebycheff polynomials and premature termination. More...
 
class  Lanczos
 Abstract interface to Lanzcos methods for computing a few extremal eigenvalues given via a Lanczosmatrix. More...
 
class  Lanczosmatrix
 Abstract base class for supplying the input matrix for Lanzcosmethods. More...
 
class  Lanczpol
 A Lanczos method allowing spectral transformation by Chebycheff polynomials and premature termination. More...
 
struct  mat_greater_index
 "greater"-routine for sorting indices of value arrays by std::sort More...
 
struct  mat_less_index
 "less"-routine for sorting indices of value arrays by std::sort More...
 
class  Matrix
 Matrix class for real values of type Real More...
 
class  MatrixError
 Such an object is generated and passed to MEmessage(), whenever an error occurs. It holds some output information on the error. More...
 
class  MEdim
 Such an object is generated and passed to MEmessage() whenever matrix dimensions do not agree for a desired operation. More...
 
class  Memarray
 A simple memory manager for frequent allocation and deallocation of arrays of roughly the same size. More...
 
class  Memarrayuser
 All derived classes share a common Memarray memory manager, which is generated with the first user and destructed when the last user is destructed. More...
 
class  MEmem
 Such an object is generated and passed to MEmessage() whenever a memory allocation fails. More...
 
class  MErange
 Such an object is generated and passed to MEmessage() whenever some index is out of range. More...
 
class  MinRes
 MinRes method for solving Ax=b with symmetric (indefinite) matrix A and positive definite preconditioner M1 where the preconditioned system is A'x'=b' with A'=M1^{-.5}AM1^{-.5}, x'=M1^{.5}*x and b'=M1^{-.5}b. System matrix and preconditioner are provided by a CH_Matrix_Classes::IterativeSystemObject. More...
 
class  PCG
 Preconditioned Conjugate Gradient method for solving Ax=b with (symmetric) positive definite matrix A and positive definite preconditioner M1 where the preconditioned system is A'x'=b' with A'=M1^{-.5}AM1^{-.5}, x'=M1^{.5}*x and b'=M1^{-.5}b. System matrix and preconditioner are provided by a CH_Matrix_Classes::IterativeSystemObject. More...
 
class  Psqmr
 PSQMR method for solving Ax=b with symmetric matrix A and symmetric preconditioner M=M1*M2 (M1 and M2 regular) where the preconditioned system is A'x'=b' with A'=M1^{-1}AM2^{-1}, x'=M2*x and b'=M1^{-1}b. System matrix and preconditioners are provided by a CH_Matrix_Classes::IterativeSystemObject. More...
 
class  Range
 allows to specify a range of integral values via (from, to, step) meaning {j=from+i*step:j in[from,to],i in {0,1,2,...}} More...
 
class  Realrange
 allows to specify a range of real values via (from, to, step,tol) meaning {x=from+i*step:x in(from-tol,to+tol),i in {0,1,2,...}} More...
 
class  Sparsemat
 Matrix class of sparse matrices with real values of type Real More...
 
class  Sparsesym
 Matrix class of symmetric matrices with real values of type Real More...
 
class  Symmatrix
 Matrix class of symmetric matrices with real values of type Real More...
 

Typedefs

typedef int Integer
 all integer numbers in calculations and indexing are of this type
 
typedef double Real
 all real numbers in calculations are of this type
 

Enumerations

enum  Mtype {
  MTglobalfun, MTindexmatrix, MTmatrix, MTsymmetric,
  MTsparse, MTsparsesym
}
 serves for specifying the source (matrix class or function) of the error More...
 
enum  MEcode {
  ME_unspec, ME_range, ME_mem, ME_dim,
  ME_num, ME_warning
}
 serves for specifying the error type. More...
 

Functions

template<class Val >
void mat_xea (Integer len, Val *x, const Val a)
 Set x[i]=a for len elements of the array x. More...
 
template<class Val >
void mat_xea (Integer len, Val *x, const Integer incx, const Val a)
 Set x[i]=a for len elements of the array x incremented by incx. More...
 
template<class Val >
void mat_xey (Integer len, Val *x, const Val *y)
 Copy an array of length len to destination x from source y. More...
 
template<class Val >
void mat_xey (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy)
 Copy an array of length len to destination x (increment incx) from source y (increment incy). More...
 
template<class Val >
void mat_xmey (Integer len, Val *x, const Val *y)
 Set x[i]=-y[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_xmey (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy)
 Set x[i]=-y[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
void mat_xemx (Integer len, Val *x)
 Set x[i]=-x[i] for an array of length len. More...
 
template<class Val >
void mat_xemx (Integer len, Val *x, const Integer incx)
 Set x[i]=-x[i] for len elements of an array incremented by incx. More...
 
template<class Val >
void mat_xemy (Integer len, Val *x, const Val *y)
 Set x[i]=-y[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_xemy (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy)
 Set x[i]=-y[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
void mat_xeya (Integer len, Val *x, const Val *y, const Val a)
 Set x[i]=a*y[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_xeya (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy, const Val a)
 Set x[i]=a*y[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
void mat_xpey (Integer len, Val *x, const Val *y)
 Set x[i]+=y[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_xpey (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy)
 Set x[i]+=y[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
void mat_xhadey (Integer len, Val *x, const Val *y)
 Set x[i]*=y[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_xinvhadey (Integer len, Val *x, const Val *y)
 Set x[i]/=y[i] for len elements of the arrays x and y, no zero checking! More...
 
template<class Val >
void mat_xhadey (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy)
 Set x[i]*=y[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
void mat_xinvhadey (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy)
 Set x[i]/=y[i] for len elements of the arrays x and y incremented by incx and incy, respectively, no zero checking! More...
 
template<class Val >
void mat_xpeya (Integer len, Val *x, const Val *y, const Val a)
 Set x[i]+=a*y[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_xpeya (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy, const Val a)
 Set x[i]+=a*y[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
void mat_xbpeya (Integer len, Val *x, const Val *y, const Val a, const Val b)
 Set x[i]=a*y[i]+b*x[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_xbpeya (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy, const Val a, const Val b)
 Set x[i]=a*y[i]+b*x[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
void mat_xpea (Integer len, Val *x, const Val a)
 Set x[i]+=a for len elements of the array x. More...
 
template<class Val >
void mat_xpea (Integer len, Val *x, const Integer incx, const Val a)
 Set x[i]+=a for len elements of the array x incremented by incx. More...
 
template<class Val >
void mat_xmultea (Integer len, Val *x, const Val a)
 Set x[i]*=a for len elements of the array x. More...
 
template<class Val >
void mat_xmultea (Integer len, Val *x, const Integer incx, const Val a)
 Set x[i]*=a for len elements of the array x incremented by incx. More...
 
template<class Val >
void mat_xdivea (Integer len, Val *x, const Val a)
 Set x[i]/=a for len elements of the array x. More...
 
template<class Val >
void mat_xdivea (Integer len, Val *x, const Integer incx, const Val a)
 Set x[i]/=a for len elements of the array x incremented by incx. More...
 
template<class Val >
void mat_xmodea (Integer len, Val *x, const Val a)
 Set x[i]%=a for len elements of the array x. More...
 
template<class Val >
void mat_xmodea (Integer len, Val *x, const Integer incx, const Val a)
 Set x[i]%=a for len elements of the array x incremented by incx. More...
 
template<class Val >
void mat_xeypz (Integer len, Val *x, const Val *y, const Val *z)
 Set x[i]=y[i]+z[i] for len elements of the arrays x, y and z. More...
 
template<class Val >
void mat_xeypz (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy, const Val *z, const Integer incz)
 Set x[i]=y[i]+z[i] for len elements of the arrays x, y and z incremented by incx, incy, and incz, respectively. More...
 
template<class Val >
void mat_xeymz (Integer len, Val *x, const Val *y, const Val *z)
 Set x[i]=y[i]-z[i] for len elements of the arrays x, y and z. More...
 
template<class Val >
void mat_xeymz (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy, const Val *z, const Integer incz)
 Set x[i]=y[i]-z[i] for len elements of the arrays x, y and z incremented by incx, incy, and incz, respectively. More...
 
template<class Val >
void mat_xeyapzb (Integer len, Val *x, const Val *y, const Val *z, const Val a, const Val b)
 Set x[i]=a*y[i]+b*z[i] for len elements of the arrays x, y and z. More...
 
template<class Val >
void mat_xeyapzb (Integer len, Val *x, const Integer incx, const Val *y, const Integer incy, const Val *z, const Integer incz, const Val a, const Val b)
 Set x[i]=a*y[i]+b*z[i] for len elements of the arrays x, y and z incremented by incx, incy, and incz, respectively. More...
 
template<class Val >
Val mat_ip (Integer len, const Val *x, const Val *y, const Val *d=0)
 return sum(x[i]*y[i]) summing over len elements of the arrays x and y. More...
 
template<class Val >
Val mat_ip (Integer len, const Val *x, const Integer incx, const Val *y, const Integer incy, const Val *d=0, const Integer incd=1)
 return sum(x[i]*y[i]) summing over len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
template<class Val >
Val mat_ip_dense_sparse (const Integer lenx, const Val *x, Integer leny, const Val *yval, const Integer *yind, const Val *d=0)
 return sum(x[yind[j]]*yval[j]) summing over elements of the dense array x and a sparse array representation of y. More...
 
template<class Val >
Val mat_ip_sparse_sparse (const Integer lenx, const Val *xval, const Integer *xind, const Integer leny, const Val *yval, const Integer *yind, const Val *d)
 return sum(xval[i]*yval[j] for i,j with xind[i]==yind[j]) summing over elements of the sparse array representations of x and y. More...
 
template<class Val >
Val mat_ip (Integer len, const Val *x)
 return sum(x[i]*x[i]) summing over len elements of the array x. More...
 
template<class Val >
Val mat_ip (Integer len, const Val *x, const Integer incx)
 return sum(x[i]*x[i]) summing over len elements of the array x incremented by incx. More...
 
template<class Val >
Val mat_sum (Integer len, const Val *x)
 returns sum(x[i]) over len elements of the array x. More...
 
template<class Val >
Val mat_sum (Integer len, const Val *x, const Integer incx)
 returns sum(x[i]) over len elements of the array x incremented by incx. More...
 
template<class Val >
bool mat_equal (Integer len, const Val *x, const Val *y)
 returns true if the elements of the arrays x and y are exactly equal. More...
 
template<class Val >
void mat_swap (Integer len, Val *x, Val *y)
 swap values x[i] and y[i] for len elements of the arrays x and y. More...
 
template<class Val >
void mat_swap (Integer len, Val *x, const Integer incx, Val *y, const Integer incy)
 swap values x[i] and y[i] for len elements of the arrays x and y incremented by incx and incy, respectively. More...
 
int MEmessage (const MatrixError &)
 displays an error message and terminates via abort() or returns 1 in case of warnings.
 
template<class Mat1 , class Mat2 >
void chk_mult (const Mat1 &, const Mat2 &, int=0, int=0)
 CONICBUNDLE_DEBUG being undefined, the template function is removed. Otherwise it would check, whether matrices x and y can be multiplied.
 
template<class T >
int mem_provide (Memarray &memarray, long provide, long in_use, long &avail, T *&store)
 provide sufficient memory for an existing array, reallocating and copying the old information upon need, returns 0 upon success, !=0 upon failure. More...
 
template<class T >
int mem_provide_init0 (Memarray &memarray, long provide, long &avail, T *&store)
 provide sufficient memory for an existing array, reallocating and copying the old information and initializing the new entries to 0, returns 0 upon success, !=0 upon failure. More...
 
double abs (double d)
 absolute value of a double
 
int abs (int d)
 absolute value of an int
 
long abs (long d)
 absolute value of a long
 
double max (double a, double b)
 maximum value of two double variables
 
double min (double a, double b)
 minimum value of two double variables
 
int max (int a, int b)
 maximum value of two int variables
 
int min (int a, int b)
 minimum value of two int variables
 
long max (long a, long b)
 maximum value of two long vriables
 
long min (long a, long b)
 minimum value of two long variables
 
void swap (double &a, double &b)
 swaps two double variables
 
void swap (long &a, long &b)
 swaps two long variables
 
void swap (int &a, int &b)
 swpas two int variables
 
void swap (bool &a, bool &b)
 swpas two bool variables
 
int sqr (int a)
 return a*a for int a
 
long sqr (long a)
 return a*a for long a
 
double sqr (double a)
 return a*a for double a
 
double sqrt (int a)
 return sqrt for int a
 
double sqrt (long a)
 return sqrt for long a
 
int sign (int a)
 return the signum of an int a (1 for a>0,-1 for a<0,0 for a==0)
 
long sign (long a)
 return the signum of a long a (1 for a>0,-1 for a<0,0 for a==0)
 
double sign (double a)
 return the signum of a double a (1. for a>0.,-1. for a<0.,0. for a==0.)
 
double sign (double a, double tol)
 return the signum of a double a with tolerance (1. for a>tol,-1. for a<-tol,0. otherwise)
 
double d_sign (double a, double b)
 return a if a and b have the same sign, return -a otherwise
 
Indexmatrix diag (const Indexmatrix &A)
 returns a column vector v consisting of the elements v(i)=A(i,i), 0<=i<min(row dimension,column dimension)
 
void swap (Indexmatrix &A, Indexmatrix &B)
 swap the content of the two matrices A and B (involves no copying)
 
Indexmatrixxbpeya (Indexmatrix &x, const Indexmatrix &y, Integer alpha=1, Integer beta=0, int ytrans=0)
 returns x= alpha*y+beta*x, where y may be transposed (ytrans=1); if beta==0. then x is initialized to the correct size More...
 
Indexmatrixxeyapzb (Indexmatrix &x, const Indexmatrix &y, const Indexmatrix &z, Integer alpha=1, Integer beta=1)
 returns x= alpha*y+beta*z; x is initialized to the correct size; alpha and beta have default value 1 More...
 
Indexmatrixgenmult (const Indexmatrix &A, const Indexmatrix &B, Indexmatrix &C, Integer alpha=1, Integer beta=0, int atrans=0, int btrans=0)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0 then C is initialized to the correct size
 
Indexmatrix transpose (const Indexmatrix &A)
 returns an Indexmatrix that is the transpose of A
 
Indexmatrix abs (const Indexmatrix &A)
 returns an Indexmatrix B with entries B(i,j)=abs(A(i,j))
 
Integer trace (const Indexmatrix &A)
 returns the sum of the diagonal elements A(i,i) over all i
 
Indexmatrix sumrows (const Indexmatrix &A)
 returns a row vector holding the sum over all rows, i.e., (1 1 ... 1)*A
 
Indexmatrix sumcols (const Indexmatrix &A)
 returns a column vector holding the sum over all columns, i.e., A*(1 1 ... 1)^T
 
Integer sum (const Indexmatrix &A)
 returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
 
Indexmatrix operator< (const Indexmatrix &A, const Indexmatrix &B)
 returns a matrix having elements (i,j)=Integer(A(i,j)<B(i,j)) for all i,j
 
Indexmatrix operator<= (const Indexmatrix &A, const Indexmatrix &B)
 returns a matrix having elements (i,j)=Integer(A(i,j)<=B(i,j)) for all i,j
 
Indexmatrix operator== (const Indexmatrix &A, const Indexmatrix &B)
 returns a matrix having elements (i,j)=Integer(A(i,j)==B(i,j)) for all i,j
 
Indexmatrix operator!= (const Indexmatrix &A, const Indexmatrix &B)
 returns a matrix having elements (i,j)=Integer(A(i,j)!=B(i,j)) for all i,j
 
Indexmatrix operator< (const Indexmatrix &A, Integer d)
 returns a matrix having elements (i,j)=Integer(A(i,j)<d) for all i,j
 
Indexmatrix operator> (const Indexmatrix &A, Integer d)
 returns a matrix having elements (i,j)=Integer(A(i,j)>d) for all i,j
 
Indexmatrix operator<= (const Indexmatrix &A, Integer d)
 returns a matrix having elements (i,j)=Integer(A(i,j)<=d) for all i,j
 
Indexmatrix operator>= (const Indexmatrix &A, Integer d)
 returns a matrix having elements (i,j)=Integer(A(i,j)>=d) for all i,j
 
Indexmatrix operator== (const Indexmatrix &A, Integer d)
 returns a matrix having elements (i,j)=Integer(A(i,j)==d) for all i,j
 
Indexmatrix operator!= (const Indexmatrix &A, Integer d)
 returns a matrix having elements (i,j)=Integer(A(i,j)!=d) for all i,j
 
Indexmatrix minrows (const Indexmatrix &A)
 returns a row vector holding in each column the minimum over all rows in this column
 
Indexmatrix mincols (const Indexmatrix &A)
 returns a column vector holding in each row the minimum over all columns in this row
 
Integer min (const Indexmatrix &A, Integer *iindex=0, Integer *jindex=0)
 returns the minimum value over all elements of the matrix
 
Indexmatrix maxrows (const Indexmatrix &A)
 returns a row vector holding in each column the maximum over all rows in this column
 
Indexmatrix maxcols (const Indexmatrix &A)
 returns a column vector holding in each row the maximum over all columns in this row
 
Integer max (const Indexmatrix &A, Integer *iindex=0, Integer *jindex=0)
 returns the maximum value over all elements of the matrix
 
Indexmatrix sortindex (const Indexmatrix &vec, bool nondecreasing=true)
 returns an Indexmatrix ind so that vec(ind(0))<=vec(ind(1))<=...<=vec(ind(vec.dim()-1)) (vec may be rectangular, set nondecreasing=false for opposite order)
 
void sortindex (const Indexmatrix &vec, Indexmatrix &ind, bool nondecreasing=true)
 sets ind so that vec(ind(0))<=vec(ind(1))<=...<=vec(ind(vec.dim()-1)) (vec may be rectangular, set nondecreasing=false for opposite order)
 
std::ostream & operator<< (std::ostream &o, const Indexmatrix &A)
 output format (all Integer values): nr nc \n A(1,1) A(1,2) ... A(1,nc) \n A(2,1) ... A(nr,nc) \n
 
std::istream & operator>> (std::istream &i, Indexmatrix &A)
 input format (all Integer values): nr nc \n A(1,1) A(1,2) ... A(1,nc) \n A(2,1) ... A(nr,nc) \n
 
Matrix diag (const Matrix &A)
 returns a column vector v consisting of the elements v(i)=(*this)(i,i), 0<=i<min(row dimension,column dimension)
 
Matrixxbpeya (Matrix &x, const Matrix &y, Real alpha=1., Real beta=0., int ytrans=0)
 returns x= alpha*y+beta*x, where y may be transposed (ytrans=1); if beta==0. then x is initialized to the correct size
 
Matrixxeyapzb (Matrix &x, const Matrix &y, const Matrix &z, Real alpha=1., Real beta=1.)
 returns x= alpha*y+beta*z; x is initialized to the correct size
 
Matrixgenmult (const Matrix &A, const Matrix &B, Matrix &C, Real alpha=1., Real beta=0., int atrans=0, int btrans=0)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size
 
Matrix transpose (const Matrix &A)
 returns a transposed matrix of A
 
std::vector< double > & assign (std::vector< double > &vec, const Matrix &A)
 interpret A as a vector and copy it to a std::vector<double> which is also returned
 
Matrixgenmult (const Symmatrix &A, const Matrix &B, Matrix &C, Real alpha, Real beta, int btrans)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size More...
 
Matrixgenmult (const Matrix &A, const Symmatrix &B, Matrix &C, Real alpha, Real beta, int atrans)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size More...
 
Matrixgenmult (const Sparsesym &A, const Matrix &B, Matrix &C, Real alpha, Real beta, int btrans)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size More...
 
Matrixgenmult (const Matrix &A, const Sparsesym &B, Matrix &C, Real alpha, Real beta, int atrans)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size More...
 
Matrixgenmult (const Sparsemat &A, const Matrix &B, Matrix &C, Real alpha, Real beta, int atrans, int btrans)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size
 
Matrixgenmult (const Matrix &A, const Sparsemat &B, Matrix &C, Real alpha, Real beta, int atrans, int btrans)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size
 
Matrix abs (const Matrix &A)
 returns a matrix with elements (i,j)=abs((*this)(i,j)) for all i,j
 
Real trace (const Matrix &A)
 =sum(diag(A)) More...
 
Real normDsquared (const Matrix &A, const Matrix &d, int atrans=0, int dinv=0)
 returns trace(A^TDA)=|A|^2_D with D=Diag(d). A may be transposed, D may be inverted but there is no check for division by zero
 
Matrix sumrows (const Matrix &A)
 returns a row vector holding the sum over all rows, i.e., (1 1 ... 1)*A
 
Matrix sumcols (const Matrix &A)
 returns a column vector holding the sum over all columns, i.e., A*(1 1 ... 1)^T
 
Real sum (const Matrix &A)
 returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
 
Matrix house (const Matrix &x, Integer i=0, Integer j=0, Real tol=1e-10)
 returns the Householder vector of size A.rowdim() for the subcolumn A(i:A.rowdim(),j)
 
int rowhouse (Matrix &A, const Matrix &v, Integer i=0, Integer j=0)
 Housholder pre-multiplication of A with Householder vector v; the first nonzero of v is index i, the multplication is applied to all columns of A with index >=j; always returns 0.
 
int colhouse (Matrix &A, const Matrix &v, Integer i=0, Integer j=0)
 Housholder post-multiplication of A with Householder vector v; the first nonzero of v is index i, the multplication is applied to all rows of A with index >=j; always returns 0.
 
Matrix operator< (const Matrix &A, const Matrix &B)
 returns a matrix having elements (i,j)=Real(A(i,j)<B(i,j)) for all i,j
 
Matrix operator<= (const Matrix &A, const Matrix &B)
 returns a matrix having elements (i,j)=Real(A(i,j)<=B(i,j)) for all i,j
 
Matrix operator== (const Matrix &A, const Matrix &B)
 returns a matrix having elements (i,j)=Real(A(i,j)==B(i,j)) for all i,j
 
Matrix operator!= (const Matrix &A, const Matrix &B)
 returns a matrix having elements (i,j)=Real(A(i,j)!=B(i,j)) for all i,j
 
Matrix operator< (const Matrix &A, Real d)
 returns a matrix having elements (i,j)=Real(A(i,j)<d) for all i,j
 
Matrix operator> (const Matrix &A, Real d)
 returns a matrix having elements (i,j)=Real(A(i,j)>d) for all i,j
 
Matrix operator<= (const Matrix &A, Real d)
 returns a matrix having elements (i,j)=Real(A(i,j)<=d) for all i,j
 
Matrix operator>= (const Matrix &A, Real d)
 returns a matrix having elements (i,j)=Real(A(i,j)>=d) for all i,j
 
Matrix operator== (const Matrix &A, Real d)
 returns a matrix having elements (i,j)=Real(A(i,j)==d) for all i,j
 
Matrix operator!= (const Matrix &A, Real d)
 returns a matrix having elements (i,j)=Real(A(i,j)!=d) for all i,j
 
Matrix minrows (const Matrix &A)
 returns a row vector holding in each column the minimum over all rows in this column
 
Matrix mincols (const Matrix &A)
 returns a column vector holding in each row the minimum over all columns in this row
 
Real min (const Matrix &A, Integer *iindex=0, Integer *jindex=0)
 returns the minimum value over all elements of the matrix
 
Matrix maxrows (const Matrix &A)
 returns a row vector holding in each column the maximum over all rows in this column
 
Matrix maxcols (const Matrix &A)
 returns a column vector holding in each row the maximum over all columns in this row
 
Real max (const Matrix &A, Integer *iindex=0, Integer *jindex=0)
 returns the maximum value over all elements of the matrix
 
Indexmatrix sortindex (const Matrix &vec, bool nondecreasing=true)
 returns an Indexmatrix ind so that vec(ind(0))<=vec(ind(1))<=...<=vec(ind(vec.dim()-1)) (vec may be rectangular, set nondecreasing=false for opposite order)
 
void sortindex (const Matrix &vec, Indexmatrix &ind, bool nondecreasing=true)
 sets ind so that vec(ind(0))<=vec(ind(1))<=...<=vec(ind(vec.dim()-1)) (vec may be rectangular, set nondecreasing=false for opposite order)
 
std::ostream & operator<< (std::ostream &o, const Matrix &v)
 output format (nr and nc are Integer values, all others Real values):
nr nc \n A(1,1) A(1,2) ... A(1,nc) \n A(2,1) ... A(nr,nc) \n
 
std::istream & operator>> (std::istream &i, Matrix &v)
 input format (nr and nc are Integer values, all others Real values):
nr nc \n A(1,1) A(1,2) ... A(1,nc) \n A(2,1) ... A(nr,nc) \n
 
Real ip (const Matrix &A, const Matrix &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real colip (const Matrix &A, Integer j, const Matrix *scaling=0)
 returns the squared Frobenius norm of column j of A, i.e., the sum of A(i,j)*A(i,j) over all i with possibly (if scaling!=0) each term i multiplied by (*scaling)(i)
 
Real rowip (const Matrix &A, Integer i, const Matrix *scaling=0)
 returns the squared Frobenius norm of row i of A, i.e., the sum of A(i,j)*A(i,j) over all j with possibly (if scaling!=0) each term j multiplied by (*scaling)(j)
 
Matrix colsip (const Matrix &A)
 returns the column vector of the squared Frobenius norm of all columns j of A, i.e., the sum of A(i,j)*A(i,j) over all i for each j
 
Matrix rowsip (const Matrix &A)
 returns the row vector of the squared Frobenius norm of all rowd i of A, i.e., the sum of A(i,j)*A(i,j) over all j for each i
 
Real norm2 (const Matrix &A)
 returns the Frobenius norm of A, i.e., the square root of the sum of A(i,j)*A(i,j) over all i,j
 
Matrix operator* (const Matrix &A, const Matrix &B)
 returns Matrix equal to A*B
 
Matrix operator+ (const Matrix &A, const Matrix &B)
 returns Matrix equal to A+B
 
Matrix operator- (const Matrix &A, const Matrix &B)
 returns Matrix equal to A-B
 
Matrix operator% (const Matrix &A, const Matrix &B)
 ATTENTION: this is redefined as the Hadamard product, C(i,j)=A(i,j)*B(i,j) for all i,j.
 
Matrix operator/ (const Matrix &A, const Matrix &B)
 ATTENTION: this is redefined to act componentwise without checking for zeros, C(i,j)=A(i,j)/B(i,j) for all i,j.
 
Matrix operator* (const Matrix &A, Real d)
 returns Matrix equal to A*d
 
Matrix operator* (Real d, const Matrix &A)
 returns Matrix equal to d*A
 
Matrix operator/ (const Matrix &A, Real d)
 returns Matrix equal to A/d; ATTENTION: d is NOT checked for 0 More...
 
Matrix operator+ (const Matrix &A, Real d)
 returns (i,j)=A(i,j)+d for all i,j
 
Matrix operator+ (Real d, const Matrix &A)
 returns (i,j)=A(i,j)+d for all i,j
 
Matrix operator- (const Matrix &A, Real d)
 returns (i,j)=A(i,j)-d for all i,j
 
Matrix operator- (Real d, const Matrix &A)
 returns (i,j)=d-A(i,j) for all i,j
 
int QR_factor (const Matrix &A, Matrix &Q, Matrix &R, Real tol)
 computes a Householder QR factorization of A and outputs Q and R leaving A unchanged; always returns 0
 
int QR_factor (const Matrix &A, Matrix &Q, Matrix &R, Indexmatrix &piv, Real tol)
 computes a Householder QR factorization of A with pivating. It outputs Q, R, and the pivoting permuation in piv; returns the rank of A
 
Matrix triu (const Matrix &A, Integer i=0)
 retuns a matrix that keeps the upper triangle of A starting with diagonal d, i.e., (i,j)=A(i,j) for 0<=i<row dimension, max(0,i+d)<=j<column dimension, and sets (i,j)=0 otherwise
 
Matrix tril (const Matrix &A, Integer i=0)
 retuns a matrix that keeps the lower triangle of A starting with diagonal d, i.e., (i,j)=A(i,j) for 0<=i<row dimension, 0<=j<min(i+d+1,column dimension), and sets (i,j)=0 otherwise
 
Matrix concat_right (const Matrix &A, const Matrix &B)
 returns a new matrix [A, B], i.e., it concats matrices A and B rowwise; A or B may be a 0x0 matrix
 
Matrix concat_below (const Matrix &A, const Matrix &B)
 returns a bew matrix [A; B], i.e., it concats matrices A and B columnwise; A or B may be a 0x0 matrix
 
void swap (Matrix &A, Matrix &B)
 swap the content of the two matrices A and B (involves no copying)
 
Matrix rand (Integer rows, Integer cols, CH_Tools::GB_rand *random_generator=0)
 return a nr x nc matrix with (i,j) assigned a random number uniformly from [0,1] for all i,j
 
Matrix inv (const Matrix &A)
 returns a matrix with elements (i,j)=1./((*this)(i,j)) for all i,j; ATTENTION: no check for division by zero
 
Matrix sqrt (const Matrix &A)
 returns a matrix with elements (i,j)=sqrt((*this)(i,j)) for all i,j
 
Matrix sqr (const Matrix &A)
 returns a matrix with elements (i,j)=sqr((*this)(i,j)) for all i,j
 
Matrix sign (const Matrix &A, Real tol=1e-12)
 returns a matrix with elements (i,j)=sign((*this)(i,j)) for all i,j using sign(double,double)
 
Matrix floor (const Matrix &A)
 returns a matrix with elements (i,j)=floor((*this)(i,j)) for all i,j
 
Matrix ceil (const Matrix &A)
 returns a matrix with elements (i,j)=ceil((*this)(i,j)) for all i,j
 
Matrix rint (const Matrix &A)
 returns a matrix with elements (i,j)=rint((*this)(i,j)) for all i,j
 
Matrix round (const Matrix &A)
 returns a matrix with elements (i,j)=round((*this)(i,j)) for all i,j
 
Matrix operator> (const Matrix &A, const Matrix &B)
 returns a matrix having elements (i,j)=Real(A(i,j)>d) for all i,j More...
 
Matrix operator>= (const Matrix &A, const Matrix &B)
 returns a matrix having elements (i,j)=Real(A(i,j)>=d) for all i,j More...
 
Matrix operator< (Real d, const Matrix &A)
 returns a matrix having elements (i,j)=Real(d<A(i,j)) for all i,j
 
Matrix operator> (Real d, const Matrix &A)
 returns a matrix having elements (i,j)=Real(d>A(i,j)) for all i,j
 
Matrix operator<= (Real d, const Matrix &A)
 returns a matrix having elements (i,j)=Real(d<=A(i,j)) for all i,j
 
Matrix operator>= (Real d, const Matrix &A)
 returns a matrix having elements (i,j)=Real(d>=A(i,j)) for all i,j
 
Matrix operator== (Real d, const Matrix &A)
 returns a matrix having elements (i,j)=Real(d==A(i,j)) for all i,j
 
Matrix operator!= (Real d, const Matrix &A)
 returns a matrix having elements (i,j)=Real(d!=A(i,j)) for all i,j
 
bool equal (const Matrix &A, const Matrix &B)
 returns true if both matrices have the same size and the same elements
 
Indexmatrix find (const Matrix &A, Real tol=1e-10)
 returns an Indexmatrix ind so that A(ind(i)) 0<=i<ind.dim() runs through all nonzero elements with abs(A(j))>tol
 
Indexmatrix find_number (const Matrix &A, Real num=0., Real tol=1e-10)
 returns an Indexmatrix ind so that A(ind(i)) 0<=i<ind.dim() runs through all elements of A having value num, i.e., abs(A(j)-num)<tol
 
Matrix diag (const Symmatrix &A)
 returns a column vector v consisting of the elements v(i)=(*this)(i,i), 0<=i<row dimension
 
Symmatrix Diag (const Matrix &A)
 returns a symmetric diagonal matrix S of order A.dim() with vec(A) on the diagonal, i.e., S(i,i)=A(i) for all i and S(i,j)=0 for i!=j
 
Symmatrixrankadd (const Matrix &A, Symmatrix &C, Real alpha=1., Real beta=0., int trans=0)
 returns C=beta*C+alpha* A*A^T, where A may be transposed. If beta==0. then C is initiliazed to the correct size.
 
Symmatrixscaledrankadd (const Matrix &A, const Matrix &D, Symmatrix &C, Real alpha=1., Real beta=0., int trans=0)
 returns C=beta*C+alpha* A*D*A^T, where D is a vector representing a diagonal matrix and A may be transposed; if beta==0. then C is initialized to the correct size
 
Symmatrixrank2add (const Matrix &A, const Matrix &B, Symmatrix &C, Real alpha=1., Real beta=0., int trans=0)
 returns C=beta*C+alpha*(A*B^T+B*A^T)/2 [or for transposed (A^T*B+B^T*A)/2]. If beta==0. then C is initiliazed to the correct size.
 
Matrixgenmult (const Symmatrix &A, const Sparsemat &B, Matrix &C, Real alpha=1., Real beta=0., int btrans=0)
 returns C=beta*C+alpha*A*B, where B may be transposed; if beta==0. then C is initialized to the correct size
 
Matrixgenmult (const Sparsemat &A, const Symmatrix &B, Matrix &C, Real alpha=1., Real beta=0., int atrans=0)
 returns C=beta*C+alpha*A*B, where A may be transposed; if beta==0. then C is initialized to the correct size
 
Symmatrixrankadd (const Sparsemat &A, Symmatrix &C, Real alpha=1., Real beta=0., int trans=0)
 returns C=beta*C+alpha* A*A^T, where A may be transposed; if beta==0. then C is initialized to the correct size
 
Symmatrixscaledrankadd (const Sparsemat &A, const Matrix &D, Symmatrix &C, Real alpha=1., Real beta=0., int trans=0)
 returns C=beta*C+alpha* A*D*A^T, where D is a vector representing a diagonal matrix and A may be transposed; if beta==0. then C is initialized to the correct size
 
Symmatrixrank2add (const Sparsemat &A, const Matrix &B, Symmatrix &C, Real alpha=1., Real beta=0., int trans=0)
 returns C=beta*C+alpha*(A*B^T+B*A^T)/2 [or for transposed (A^T*B+B^T*A)/2]. If beta==0. then C is initiliazed to the correct size.
 
Symmatrix abs (const Symmatrix &A)
 returns a Symmatrix with elements abs(A(i,j))
 
Real trace (const Symmatrix &A)
 returns the sum of the diagonal elements A(i,i) over all i
 
Real ip (const Symmatrix &A, const Symmatrix &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real ip (const Matrix &A, const Symmatrix &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real ip (const Symmatrix &A, const Matrix &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Matrix sumrows (const Symmatrix &A)
 returns a row vector holding the sum over all rows, i.e., (1 1 ... 1)*A
 
Matrix sumcols (const Symmatrix &A)
 returns a column vector holding the sum over all columns, i.e., A*(1 1 ... 1)^T
 
Real sum (const Symmatrix &A)
 returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
 
void svec (const Symmatrix &A, Matrix &sv, Real a=1., bool add=false, Integer startindex_vec=-1, Integer startindex_A=0, Integer blockdim=-1)
 the symmetric vec operator stacks the lower triangle of A to a n*(n+1)/2 vector with the same norm2 as A; here it sets svec(A)=[a11,sqrt(2)a12,...,sqrt(2)a1n,a22,...,sqrt(2)a(n-1,n),ann]', multiplies it by a and sets or adds (if add==true) it to v starting from startindex_vec possibly restricted to the subblock of order blockdim (whenever >=0, else blockdim is set to A.rowdim()-startindex_A) starting from startindex_A (must be >=0); if add==false and startindex_vec<0 then vec is also reinitialzed to the appropriate size
 
void sveci (const Matrix &sv, Symmatrix &A, Real a=1., bool add=false, Integer startindex_vec=0, Integer startindex_A=-1, Integer blockdim=-1)
 the inverse operator to svec, extracts from v at startindex_vec (>=0) the symmetric matrix of blockdim adding its mutliple by a into A starting at startindex_A; if add==false and startindex_A<0 A is initialized to the size of blockdim; if the latter is also negative then v.dim()-startindex_vec must match an exact order and matrix A is initialized to this size. In all other cases the size of the symmetric matrix determines the missing parameters and vec.dim-startindex_vec
 
void skron (const Symmatrix &A, const Symmatrix &B, Symmatrix &S, Real alpha=1., bool add=false, Integer startindex_S=-1)
 def symmetric Kronecker product (A skron B)svec(C)=(BCA'+ACB')/2; sets S=alpha*(A skron B) or S*=... (if add==true) possibly shifted to the block starting at startindex_S; if add==false and startindex_S<0, S is initialzed to the correct size
 
void symscale (const Symmatrix &A, const Matrix &B, Symmatrix &S, Real alpha=1., Real beta=0., int btrans=0)
 sets S=beta*S+alpha*B'*A*B for symmatrix A and matrix B
 
Matrix minrows (const Symmatrix &A)
 returns a row vector holding in each column the minimum over all rows in this column
 
Matrix mincols (const Symmatrix &A)
 returns a column vector holding in each row the minimum over all columns in this row
 
Real min (const Symmatrix &A)
 returns the minimum value over all elements of the matrix
 
Matrix maxrows (const Symmatrix &A)
 returns a row vector holding in each column the maximum over all rows in this column
 
Matrix maxcols (const Symmatrix &A)
 returns a column vector holding in each row the maximum over all columns in this row
 
Real max (const Symmatrix &A)
 returns the maximum value over all elements of the matrix
 
std::ostream & operator<< (std::ostream &o, const Symmatrix &A)
 output format (nr and nc are Integer values, all others Real values):
nr nc \n A(1,1) A(1,2) ... A(1,nc) \n A(2,1) ... A(nr,nc) \n
 
std::istream & operator>> (std::istream &i, Symmatrix &A)
 input format (nr and nc are Integer values, all others Real values):
nr nc \n A(1,1) A(1,2) ... A(1,nc) \n A(2,1) ... A(nr,nc) \n
 
void swap (Symmatrix &A, Symmatrix &B)
 swap the content of the two matrices A and B (involves no copying)
 
Symmatrixxbpeya (Symmatrix &x, const Symmatrix &y, Real alpha=1., Real beta=0.)
 returns x= alpha*y+beta*x; if beta==0. then x is initialized to the correct size
 
Symmatrixxeyapzb (Symmatrix &x, const Symmatrix &y, const Symmatrix &z, Real alpha=1., Real beta=1.)
 returns x= alpha*y+beta*z; x is initialized to the correct size
 
Matrix operator* (const Symmatrix &A, const Symmatrix &B)
 returns a Matrix that equals A*B
 
Symmatrix operator% (const Symmatrix &A, const Symmatrix &B)
 returns a Matrix that equals AB (where % is overloaded as elementwise multiplication) More...
 
Symmatrix operator+ (const Symmatrix &A, const Symmatrix &B)
 returns a Matrix that equals A+B
 
Symmatrix operator- (const Symmatrix &A, const Symmatrix &B)
 returns a Matrix that equals A-B
 
Matrix operator* (const Symmatrix &A, const Matrix &B)
 returns a Matrix that equals A*B
 
Matrix operator* (const Matrix &A, const Symmatrix &B)
 returns a Matrix that equals A*B
 
Matrix operator+ (const Symmatrix &A, const Matrix &B)
 returns a Matrix that equals A+B
 
Matrix operator+ (const Matrix &A, const Symmatrix &B)
 returns a Matrix that equals A+B
 
Matrix operator- (const Symmatrix &A, const Matrix &B)
 returns a Matrix that equals A-B
 
Matrix operator- (const Matrix &A, const Symmatrix &B)
 returns a Matrix that equals A-B
 
Symmatrix operator* (const Symmatrix &A, Real d)
 returns a Symmatrix that equals A*d
 
Symmatrix operator* (Real d, const Symmatrix &A)
 returns a Symmatrix that equals A*d
 
Symmatrix operator/ (const Symmatrix &A, Real d)
 returns a Symmatrix that equals A/d; ATTENTION: no check against division by zero
 
Symmatrix operator+ (const Symmatrix &A, Real d)
 returns a Symmatrix that equals A+d (d is added to each element) More...
 
Symmatrix operator+ (Real d, const Symmatrix &A)
 returns a Symmatrix that equals A+d (d is added to each element) More...
 
Symmatrix operator- (const Symmatrix &A, Real d)
 returns a Symmatrix that equals A-d (d is subtracted from each element) More...
 
Symmatrix operator- (Real d, const Symmatrix &A)
 returns a Symmatrix that equals d-A (each element subtracted from d) More...
 
Matrix svec (const Symmatrix &A)
 the symmetric vec operator, stacks the lower triangle of A to a n*(n+1)/2 vector with the same norm2 as A; i.e., it returns svec(A)=[a11,sqrt(2)a12,...,sqrt(2)a1n,a22,...,sqrt(2)a(n-1,n),ann]'
 
Symmatrix skron (const Symmatrix &A, const Symmatrix &B, Real alpha=1., bool add=false, Integer startindex_S=-1)
 the symmetric Kronecker product, defined via (A skron B)svec(C)=(BCA'+ACB')/2; sets or adds (if add==true) the symmetric matrix a*(A skron B) into S starting at startindex_S; if add==false and startindex_S<0, S is initialzed to the correct size
 
Real norm2 (const Symmatrix &A)
 returns the Frobenius norm of A, i.e., the square root of the sum of A(i,j)*A(i,j) over all i,j
 
Symmatrix transpose (const Symmatrix &A)
 returns a copy of A (drop it or use a constructor instead) More...
 
void swap (Sparsemat &A, Sparsemat &B)
 swap the content of the two sparse matrices A and B (involves no copying)
 
Sparsematxbpeya (Sparsemat &x, const Sparsemat &y, Real alpha=1., Real beta=0., int ytrans=0)
 returns x= alpha*y+beta*x, where y may be transposed (ytrans=1); if beta==0. then x is initialized to the correct size
 
Matrixgenmult (const Sparsemat &A, const Sparsemat &B, Matrix &C, Real alpha=1., Real beta=0., int atrans=0, int btrans=0)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size
 
Sparsemat operator* (const Sparsemat &A, const Sparsemat &B)
 returns a Sparsemat equal to A*B
 
Matrixgenmult (const Sparsesym &A, const Sparsemat &B, Matrix &C, Real alpha=1., Real beta=0., int btrans=0)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size More...
 
Matrixgenmult (const Sparsemat &A, const Sparsesym &B, Matrix &C, Real alpha=1., Real beta=0., int atrans=0)
 returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size More...
 
Sparsemat abs (const Sparsemat &A)
 returns a Sparsmat with elements abs((*this)(i,j)) for all i,j
 
Real trace (const Sparsemat &A)
 returns the sum of the diagonal elements A(i,i) over all i
 
Real ip (const Sparsemat &A, const Sparsemat &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real ip (const Sparsemat &A, const Matrix &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real colip (const Sparsemat &A, Integer j, const Matrix *scaling=0)
 returns the squared Frobenius norm of col i of A, i.e., the sum of A(i,j)*A(i,j) over all i with possibly (if scaling!=0) each term i multiplied by (*scaling)(i)
 
Real rowip (const Sparsemat &A, Integer i, const Matrix *scaling=0)
 returns the squared Frobenius norm of row i of A, i.e., the sum of A(i,j)*A(i,j) over all j with possibly (if scaling!=0) each term j multiplied by (*scaling)(j)
 
Sparsemat colsip (const Sparsemat &A, const Matrix *colscaling=0)
 returns the row vector of the squared Frobenius norm of all columns j of A, i.e., the sum of A(i,j)*A(i,j) over all i for each j with possibly (if scaling!=0) each term i multiplied by (*scaling)(i) More...
 
Sparsemat rowsip (const Sparsemat &A, const Matrix *rowscaling=0)
 returns the column vector of the squared Frobenius norm of all rows i of A, i.e., the sum of A(i,j)*A(i,j) over all j for each i with possibly (if scaling!=0) each term j multiplied by (*scaling)(j) More...
 
Matrix sumrows (const Sparsemat &A)
 returns a row vector holding the sum over all rows, i.e., (1 1 ... 1)*A
 
Matrix sumcols (const Sparsemat &A)
 returns a column vector holding the sum over all columns, i.e., A*(1 1 ... 1)^T
 
std::ostream & operator<< (std::ostream &o, const Sparsemat &v)
 output format: nr nc nz \n i1 j1 val1\n i2 j2 val2\n ... inz jnz valnz\n
 
std::istream & operator>> (std::istream &i, Sparsemat &v)
 input format: nr nc nz \n i1 j1 val1\n i2 j2 val2\n ... inz jnz valnz\n
 
Sparsemat concat_right (const Sparsemat &A, const Sparsemat &B)
 returns a new sparse matrix [A, B], i.e., it concats matrices A and B rowwise; A or B may be a 0x0 matrix
 
Sparsemat concat_below (const Sparsemat &A, const Sparsemat &B)
 returns a new sparse matrix [A; B], i.e., it concats matrices A and B columnwise; A or B may be a 0x0 matrix
 
Real norm2 (const Sparsemat &A)
 returns the Frobenius norm of A, i.e., the square root of the sum of A(i,j)*A(i,j) over all i,j
 
Sparsemat operator+ (const Sparsemat &A, const Sparsemat &B)
 returns a Sparsemat equal to A+B
 
Sparsemat operator- (const Sparsemat &A, const Sparsemat &B)
 returns a Sparsemat equal to A-B
 
Sparsemat operator* (const Sparsemat &A, Real d)
 returns a Sparsemat equal to A*d
 
Sparsemat operator* (Real d, const Sparsemat &A)
 returns a Sparsemat equal to d*A
 
Sparsemat operator/ (const Sparsemat &A, Real d)
 returns a Sparsemat equal to A/d; ATTENTION: no check against division by zero More...
 
Matrix operator* (const Sparsemat &A, const Matrix &B)
 returns a Matrix equal to A*B
 
Matrix operator* (const Matrix &A, const Sparsemat &B)
 returns a Matrix equal to A*B
 
Matrix operator+ (const Sparsemat &A, const Matrix &B)
 returns a Matrix equal to A+B
 
Matrix operator+ (const Matrix &A, const Sparsemat &B)
 returns a Matrix equal to A+B
 
Matrix operator- (const Sparsemat &A, const Matrix &B)
 returns a Matrix equal to A-B
 
Matrix operator- (const Matrix &A, const Sparsemat &B)
 returns a Matrix equal to A-B
 
Real ip (const Matrix &A, const Sparsemat &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real sum (const Sparsemat &A)
 returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
 
Sparsemat transpose (const Sparsemat &A)
 returns a Sparsemat that is the transpose of A
 
Matrix diag (const Sparsesym &A)
 returns the diagonal of A as a dense Matrix vector
 
Sparsesym sparseDiag (const Matrix &A, Real tol=SPARSE_ZERO_TOL)
 forms a sparse symmetrix matrix having vector A on its diagonal
 
void swap (Sparsesym &A, Sparsesym &B)
 swap the content of the two sparse matrices A and B (involves no copying)
 
Sparsesymxeyapzb (Sparsesym &x, const Sparsesym &y, const Sparsesym &z, Real alpha=1., Real beta=1.)
 returns x= alpha*y+beta*z; x is initialized to the correct size
 
Sparsesymsupport_rankadd (const Matrix &A, Sparsesym &C, Real alpha=1., Real beta=0., int trans=0)
 returns C=beta*C+alpha*AA^T (or A^TA), but only on the current support of C
 
Real ip (const Symmatrix &A, const Sparsesym &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Sparsesym abs (const Sparsesym &A)
 returns a Sparsesym with elements abs((*this)(i,j)) for all i,j
 
Real trace (const Sparsesym &A)
 returns the sum of the diagonal elements A(i,i) over all i
 
Real ip (const Sparsesym &A, const Sparsesym &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real ip (const Matrix &A, const Sparsesym &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Real norm2 (const Sparsesym &A)
 returns the Frobenius norm of A, i.e., the square root of the sum of A(i,j)*A(i,j) over all i,j
 
Matrix sumrows (const Sparsesym &A)
 returns a row vector holding the sum over all rows, i.e., (1 1 ... 1)*A
 
Real sum (const Sparsesym &A)
 returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
 
std::ostream & operator<< (std::ostream &o, const Sparsesym &v)
 output format (lower triangle): nr nz \n i1 j1 val1\n i2 j2 val2\n ... inz jnz valnz\n
 
std::istream & operator>> (std::istream &i, Sparsesym &v)
 input format (lower triangle): nr nz \n i1 j1 val1\n i2 j2 val2\n ... inz jnz valnz\n
 
Sparsesymxbpeya (Sparsesym &x, const Sparsesym &y, Real alpha=1., Real beta=0.)
 returns x= alpha*y+beta*x; if beta==0. then x is initialized to the correct size
 
Sparsesym operator+ (const Sparsesym &A, const Sparsesym &B)
 returns a Sparsesym that equals A+B
 
Sparsesym operator- (const Sparsesym &A, const Sparsesym &B)
 returns a Sparsesym that equals A-B
 
Sparsesym operator* (const Sparsesym &A, Real d)
 returns a Sparsesym that equals A*d
 
Sparsesym operator* (Real d, const Sparsesym &A)
 returns a Sparsesym that equals A*d
 
Sparsesym operator/ (const Sparsesym &A, Real d)
 returns a Sparsesym that equals A/d; ATTENTION: no check for devision by zero More...
 
Matrix operator* (const Sparsesym &A, const Matrix &B)
 returns a Matrix that equals A*B
 
Matrix operator* (const Matrix &A, const Sparsesym &B)
 returns a Matrix that equals A*B
 
Matrix operator+ (const Matrix &A, const Sparsesym &B)
 returns a Matrix that equals A+B
 
Matrix operator+ (const Sparsesym &A, const Matrix &B)
 returns a Matrix that equals A+B
 
Matrix operator- (const Matrix &A, const Sparsesym &B)
 returns a Matrix that equals A-B
 
Matrix operator- (const Sparsesym &A, const Matrix &B)
 returns a Matrix that equals A-B
 
Real ip (const Sparsesym &A, const Matrix &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Sparsesym transpose (const Sparsesym &A)
 returns a copy of A (drop it or use a constructor instead) More...
 
Matrix sumcols (const Sparsesym &A)
 returns a column vector holding the sum over all columns, i.e., A*(1 1 ... 1)^T
 
Symmatrix operator+ (const Sparsesym &A, const Symmatrix &B)
 returns a Symmatrix that equals A+B
 
Symmatrix operator+ (const Symmatrix &A, const Sparsesym &B)
 returns a Symmatrix that equals A+B
 
Symmatrix operator- (const Sparsesym &A, const Symmatrix &B)
 returns a Symmatrix that equals A-B
 
Symmatrix operator- (const Symmatrix &A, const Sparsesym &B)
 returns a Symmatrix that equals A-B
 
Real ip (const Sparsesym &A, const Symmatrix &B)
 returns the usual inner product of A and B, i.e., the sum of A(i,j)*B(i,j) over all i,j
 
Matrix operator* (const Sparsesym &A, const Sparsemat &B)
 returns a Matrix that equals A*B
 
Matrix operator* (const Sparsemat &A, const Sparsesym &B)
 returns a Matrix that equals A*B
 
Matrix operator* (const Symmatrix &A, const Sparsemat &B)
 returns a Matrix that equals A*B
 
Matrix operator* (const Sparsemat &A, const Symmatrix &B)
 returns a Matrix that equals A*B
 
Equal (Members)
int equal (const Sparsemat &A, const Sparsemat &B, Real eqtol=1e-10)
 returns 1 if both matrices are identical, 0 otherwise
 
int equal (const Sparsesym &A, const Sparsesym &B, Real eqtol=1e-10)
 returns 1 if both matrices are identical, 0 otherwise
 

Variables

const Integer max_Integer = INT_MAX
 maximal attainable value by an Integer
 
const Integer min_Integer = INT_MIN
 minimal attainable value by an Integer
 
const Real max_Real = DBL_MAX
 maximal attainable value by a Real
 
const Real min_Real = -DBL_MAX
 minimal attainable value by a Real
 
const Real eps_Real = DBL_EPSILON
 machine epsilon for type Real
 
CH_Tools::GB_rand mat_randgen
 common random number generator for use when a random matrix is generated. More...
 
std::default_random_engine mat_std_randgen
 optional fast alternative random number generator from std
 
std::mt19937 mat_mt_randgen
 optional high quality alternative random number generator from std
 
std::mt19937_64 mat_mt64_randgen
 optional high quality alternative random number generator from std
 
std::ostream * materrout
 if not zero, this is the output stream for runtime error messages, by default it is set to &std::cout
 

Detailed Description

Matrix Classes and Linear Algebra. See Matrix Classes (namespace CH_Matrix_Classes) for a quick introduction.

Function Documentation

◆ colsip()

Sparsemat CH_Matrix_Classes::colsip ( const Sparsemat A,
const Matrix colscaling = 0 
)

returns the row vector of the squared Frobenius norm of all columns j of A, i.e., the sum of A(i,j)*A(i,j) over all i for each j with possibly (if scaling!=0) each term i multiplied by (*scaling)(i)

returns the column vector of the squared Frobenius norm of all columns j of A, i.e., the sum of A(i,j)*A(i,j) over all i for each j with possibly (if scaling~=0) each term i multiplied by (*scaling)(i)

◆ genmult() [1/6]

Matrix& CH_Matrix_Classes::genmult ( const Sparsesym A,
const Sparsemat B,
Matrix C,
Real  alpha = 1.,
Real  beta = 0.,
int  btrans = 0 
)

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size

returns C=beta*C+alpha*A*B, where B may be transposed; if beta==0. then C is initialized to the correct size

◆ genmult() [2/6]

Matrix& CH_Matrix_Classes::genmult ( const Sparsemat A,
const Sparsesym B,
Matrix C,
Real  alpha = 1.,
Real  beta = 0.,
int  atrans = 0 
)

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size

returns C=beta*C+alpha*A*B, where A may be transposed; if beta==0. then C is initialized to the correct size

◆ genmult() [3/6]

Matrix & CH_Matrix_Classes::genmult ( const Symmatrix A,
const Matrix B,
Matrix C,
Real  alpha,
Real  beta,
int  btrans 
)

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size

returns C=beta*C+alpha*A*B, where B may be transposed; C must not be equal to B; if beta==0. then C is initialized to the correct size

◆ genmult() [4/6]

Matrix & CH_Matrix_Classes::genmult ( const Matrix A,
const Symmatrix B,
Matrix C,
Real  alpha,
Real  beta,
int  atrans 
)

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size

returns C=beta*C+alpha*A*B, where A may be transposed; C must not be equal to A; if beta==0. then C is initialized to the correct size

◆ genmult() [5/6]

Matrix& CH_Matrix_Classes::genmult ( const Sparsesym A,
const Matrix B,
Matrix C,
Real  alpha,
Real  beta,
int  btrans 
)

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to B; if beta==0. then C is initialized to the correct size

◆ genmult() [6/6]

Matrix& CH_Matrix_Classes::genmult ( const Matrix A,
const Sparsesym B,
Matrix C,
Real  alpha,
Real  beta,
int  atrans 
)

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta==0. then C is initialized to the correct size

returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to B; if beta==0. then C is initialized to the correct size

◆ operator%()

Symmatrix CH_Matrix_Classes::operator% ( const Symmatrix A,
const Symmatrix B 
)
inline

returns a Matrix that equals AB (where % is overloaded as elementwise multiplication)

ATTENTION: this is redefined as the Hadamard product and sets (i,j)=A(i,j)*B(i,j) for all i<=j.

◆ operator+() [1/2]

Symmatrix CH_Matrix_Classes::operator+ ( const Symmatrix A,
Real  d 
)
inline

returns a Symmatrix that equals A+d (d is added to each element)

returns (i,j)=A(i,j)+d for all i<=j

◆ operator+() [2/2]

Symmatrix CH_Matrix_Classes::operator+ ( Real  d,
const Symmatrix A 
)
inline

returns a Symmatrix that equals A+d (d is added to each element)

returns (i,j)=A(i,j)+d for all i<=j

◆ operator-() [1/2]

Symmatrix CH_Matrix_Classes::operator- ( const Symmatrix A,
Real  d 
)
inline

returns a Symmatrix that equals A-d (d is subtracted from each element)

returns (i,j)=A(i,j)-d for all i<=j

◆ operator-() [2/2]

Symmatrix CH_Matrix_Classes::operator- ( Real  d,
const Symmatrix A 
)
inline

returns a Symmatrix that equals d-A (each element subtracted from d)

returns (i,j)=d-A(i,j) for all i<=j

Referenced by CH_Matrix_Classes::Symmatrix::get_store(), CH_Matrix_Classes::Symmatrix::operator%=(), and CH_Matrix_Classes::Symmatrix::transpose().

◆ operator/() [1/3]

Sparsesym CH_Matrix_Classes::operator/ ( const Sparsesym A,
Real  d 
)
inline

returns a Sparsesym that equals A/d; ATTENTION: no check for devision by zero

ATTENTION: d is NOT checked for 0.

References CH_Matrix_Classes::Sparsesym::Sparsesym().

◆ operator/() [2/3]

Sparsemat CH_Matrix_Classes::operator/ ( const Sparsemat A,
Real  d 
)
inline

returns a Sparsemat equal to A/d; ATTENTION: no check against division by zero

ATTENTION: d is NOT checked for 0.

References CH_Matrix_Classes::Sparsemat::Sparsemat().

◆ operator/() [3/3]

Matrix CH_Matrix_Classes::operator/ ( const Matrix A,
Real  d 
)
inline

returns Matrix equal to A/d; ATTENTION: d is NOT checked for 0

ATTENTION: d is NOT checked for 0.

References CH_Matrix_Classes::Matrix::Matrix().

◆ operator>()

Matrix CH_Matrix_Classes::operator> ( const Matrix A,
const Matrix B 
)
inline

returns a matrix having elements (i,j)=Real(A(i,j)>d) for all i,j

returns a matrix having elements (i,j)=Real(A(i,j)>B(i,j)) for all i,j

◆ operator>=()

Matrix CH_Matrix_Classes::operator>= ( const Matrix A,
const Matrix B 
)
inline

returns a matrix having elements (i,j)=Real(A(i,j)>=d) for all i,j

returns a matrix having elements (i,j)=Real(A(i,j)>=B(i,j)) for all i,j

◆ rowsip()

Sparsemat CH_Matrix_Classes::rowsip ( const Sparsemat A,
const Matrix rowscaling = 0 
)

returns the column vector of the squared Frobenius norm of all rows i of A, i.e., the sum of A(i,j)*A(i,j) over all j for each i with possibly (if scaling!=0) each term j multiplied by (*scaling)(j)

returns the row vector of the squared Frobenius norm of all rows i of A, i.e., the sum of A(i,j)*A(i,j) over all j for each i with possibly (if scaling~=0) each term j multiplied by (*scaling)(j)

◆ trace()

Real CH_Matrix_Classes::trace ( const Matrix A)

=sum(diag(A))

returns the sum of the diagonal elements A(i,i) over all i

◆ transpose() [1/2]

Sparsesym CH_Matrix_Classes::transpose ( const Sparsesym A)
inline

returns a copy of A (drop it or use a constructor instead)

(drop it or use a constructor instead)

References CH_Matrix_Classes::Sparsesym::Sparsesym().

◆ transpose() [2/2]

Symmatrix CH_Matrix_Classes::transpose ( const Symmatrix A)
inline

returns a copy of A (drop it or use a constructor instead)

(drop it or use a constructor instead)

References CH_Matrix_Classes::Symmatrix::Symmatrix().