3 #ifndef CH_MATRIX_CLASSES__SPARSSYM_HXX 4 #define CH_MATRIX_CLASSES__SPARSSYM_HXX 14 #ifndef CH_MATRIX_CLASSES__SPARSMAT_HXX 141 #if (CONICBUNDLE_DEBUG>=1) 520 void display(std::ostream& out,
564 Real alpha=1.,
Real beta=0.,
int trans=0);
606 #if (CONICBUNDLE_DEBUG>=1) 612 {
return xeya(A,d); }
648 {
return (*
this)(i%
nr,i/
nr); }
650 {
return (*
this)(i%
nr,i/
nr); }
656 if (beta==0.)
return x.
init(y,alpha);
759 {
return xpeya(A,-1.); }
831 {
return xpeya(A,-1.);}
bool is_init
flag whether memory is initialized, it is only used if CONICBUNDLE_DEBUG is defined ...
Definition: sparssym.hxx:110
#define chk_set_init(x, y)
CONICBUNDLE_DEBUG being undefined, the template function is removed. Otherwise it would allow to set ...
Definition: matop.hxx:1774
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
friend Sparsesym operator*(const Sparsesym &A, Real d)
returns a Sparsesym that equals A*d
Definition: sparssym.hxx:689
const Indexmatrix & get_colindex() const
returns the index vector of the column representation holding the row index for each element ...
Definition: sparssym.hxx:246
Matrix & xpeya(const Matrix &A, Real d=1.)
sets *this+=d*A and returns *this
Indexmatrix colinfo
k by 4 matrix, for nonzero columns: index (<0 for diagonal), # nonzeros, first index in colindex/colv...
Definition: sparssym.hxx:102
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
friend Sparsesym & xeyapzb(Sparsesym &x, const Sparsesym &y, const Sparsesym &z, Real alpha, Real beta)
returns x= alpha*y+beta*z; x is initialized to the correct size
Sparsemat sparsemult(const Matrix &A) const
compute (*this)*A and return the result in a Sparsemat
#define SPARSE_ZERO_TOL
if the absolute value of an element is below this value, it is considered zero
Definition: sparsmat.hxx:24
friend Matrix sumrows(const Sparsesym &A)
returns a row vector holding the sum over all rows, i.e., (1 1 ... 1)*A
Indexmatrix suppind
index of an element with respect to the principal submatrix spanned by the entire support ...
Definition: sparssym.hxx:105
friend Sparsesym & support_rankadd(const Matrix &A, Sparsesym &C, Real alpha, Real beta, int trans)
returns C=beta*C+alpha*AA^T (or A^TA), but only on the current support of C
const Indexmatrix & get_colinfo() const
returns information on nozero diagonal/columns, k by 4, listing: index (<0 for diagonal), # nonzeros, first index in colindex/colval, index in suppport submatrix
Definition: sparssym.hxx:243
Symmatrix & init(const Symmatrix &A, double d=1.)
initialize to *this=A*d
Definition: symmat.hxx:753
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
friend Sparsesym operator+(const Sparsesym &A, const Sparsesym &B)
returns a Sparsesym that equals A+B
Definition: sparssym.hxx:681
int contains_support(const Sparsesym &A) const
returns 1 if A is of the same dimension and the support of A is contained in the support of *this...
void init_to_zero()
initialize the matrix to a 0x0 matrix without storage
Definition: sparssym.hxx:601
friend void swap(Sparsesym &A, Sparsesym &B)
swap the content of the two sparse matrices A and B (involves no copying)
Matrix & init(const Matrix &A, Real d=1., int atrans=0)
initialize to *this=A*d where A may be transposed
Definition: matrix.hxx:1035
void dim(Integer &_nr, Integer &_nc) const
returns the number of rows in _nr and the number of columns in _nc
Definition: matrix.hxx:209
Mtype
serves for specifying the source (matrix class or function) of the error
Definition: matop.hxx:1585
friend Real sum(const Sparsesym &A)
returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
Sparsesym & support_xbpeya(const Sparsesym &y, Real alpha=1., Real beta=0.)
returns this= alpha*y+beta(*this) restricted to the curent support of *this; if beta==0, then *this is initialized to 0 on its support first
Integer rowdim() const
returns the row dimension
Definition: sparssym.hxx:212
Sparsesym & init(const Sparsesym &, Real d=1.)
initialize to *this=A*d
Definition: sparssym.hxx:611
Sparsemat()
empty matrix
Definition: sparsmat.hxx:692
void set_init(bool)
after external initialization, call matrix.set_init(true) (not needed if CONICBUNDLE_DEBUG is undefin...
Definition: sparssym.hxx:148
friend Matrix diag(const Sparsesym &A)
returns the diagonal of A as a dense Matrix vector
Matrix class of symmetric matrices with real values of type Real
Definition: symmat.hxx:43
Indexmatrix colindex
gives the rowindex of the element at position i, (sorted increasingly per column) ...
Definition: sparssym.hxx:103
friend 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 ...
void dim(Integer &r, Integer &c) const
returns the number of rows in _nr and the number of columns in _nc
Definition: sparssym.hxx:206
friend int equal(const Sparsesym &A, const Sparsesym &B, Real eqtol)
returns 1 if both matrices are identical, 0 otherwise
int check_support(Integer i, Integer j) const
returns 0 if (i,j) is not in the support, 1 otherwise
friend Sparsesym sparseDiag(const Matrix &A, Real tol)
forms a sparse symmetrix matrix having vector A on its diagonal
Symmatrix()
empty matrix
Definition: symmat.hxx:778
Sparsesym & operator/=(Real d)
ATTENTION: d is NOT checked for 0.
Definition: sparssym.hxx:668
error arises in a message of CH_Matrix_Classes::Sparsemat
Definition: matop.hxx:1590
Sparsemat & init(const Sparsemat &A, Real d=1.)
initialize to *this=A*d
Definition: sparsmat.hxx:674
friend Real trace(const Sparsesym &A)
returns the sum of the diagonal elements A(i,i) over all i
Mtype get_mtype() const
returns the type of the matrix, MTmatrix
Definition: sparssym.hxx:221
Integer nr
number rows = number columns
Definition: sparssym.hxx:99
Matrix colval
gives the value of the element at position i
Definition: sparssym.hxx:104
Real tol
>0, if abs(value)<tol, then value is taken to be zero
Definition: sparssym.hxx:108
Sparsesym & xeya(const Sparsesym &A, Real d=1.)
sets *this=d*A and returns *this
Mtype mtype
used for MatrixError templates (runtime type information was not yet existing)
Definition: sparssym.hxx:98
const Indexmatrix & get_suppind() const
returns the index vector of the column representation holding the row index w.r.t. the principal support submatrix for each element
Definition: sparssym.hxx:250
Matrix Classes and Linear Algebra. See Matrix Classes (namespace CH_Matrix_Classes) for a quick intro...
Definition: PSCOracle.hxx:20
Matrix class of symmetric matrices with real values of type Real
Definition: sparssym.hxx:89
Integer dim() const
returns the dimension rows * columns when the matrix is regarded as a vector
Definition: sparssym.hxx:209
Indexmatrix & init(const Indexmatrix &A, Integer d=1)
initialize to *this=A*d
friend 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 ...
Integer coldim() const
returns the column dimension
Definition: sparssym.hxx:215
Integer nonzeros() const
returns the number of nonzeros in the lower triangle (including diagonal)
Definition: sparssym.hxx:218
void get_edge_rep(Indexmatrix &I, Indexmatrix &J, Matrix &val) const
stores the nz nonzero values of the lower triangle of *this in I,J,val so that this(I(i),J(i))=val(i) for i=0,...,nz-1 and dim(I)=dim(J)=dim(val)=nz (ordered as in row representation)
Matrix class for real values of type Real
Definition: matrix.hxx:74
void display(std::ostream &out, int precision=0, int width=0, int screenwidth=0) const
displays a matrix in a pretty way for bounded screen widths; for variables of value zero default valu...
const Matrix & get_colval() const
returns the value vector of the column representation holding the value for each element ...
Definition: sparssym.hxx:248
Matrix & transpose()
transposes itself (cheap for vectors, expensive for matrices)
friend Matrix & 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 B; if beta==0...
Matrix class of sparse matrices with real values of type Real
Definition: sparsmat.hxx:74
const Indexmatrix & get_suppcol() const
returns the vector listing in ascending order the original column indices of the principal support su...
Definition: sparssym.hxx:252
Symmatrix operator-(const Symmatrix &A, const Sparsesym &B)
returns a Symmatrix that equals A-B
Definition: sparssym.hxx:786
friend Sparsesym & xbpeya(Sparsesym &x, const Sparsesym &y, Real alpha, Real beta)
returns x= alpha*y+beta*x; if beta==0. then x is initialized to the correct size
Definition: sparssym.hxx:654
friend Sparsesym operator/(const Sparsesym &A, Real d)
ATTENTION: d is NOT checked for 0.
Definition: sparssym.hxx:697
bool get_init() const
returns true if the matrix has been declared initialized (not needed if CONICBUNDLE_DEBUG is undefine...
Definition: sparssym.hxx:150
friend 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...
All derived classes share a common Memarray memory manager, which is generated with the first user an...
Definition: memarray.hxx:117
friend Sparsesym abs(const Sparsesym &A)
returns a Sparsesym with elements abs((*this)(i,j)) for all i,j
Real operator[](Integer i) const
returns value of element (i) of the matrix if regarded as vector of stacked columns [element (irowdim...
Definition: sparssym.hxx:649
Sparsesym & transpose()
transposes itself (at almost no cost)
Definition: sparssym.hxx:357
#define chk_init(x)
CONICBUNDLE_DEBUG being undefined, the template function is removed. Otherwise it would check...
Definition: matop.hxx:1761
Sparsesym()
empty matrix
Definition: sparssym.hxx:628
void set_tol(Real t)
set tolerance for recognizing zero values to t
Definition: sparssym.hxx:176
Matrix()
empty matrix
Definition: matrix.hxx:1082
friend Matrix sumcols(const Sparsesym &A)
returns a column vector holding the sum over all columns, i.e., A*(1 1 ... 1)^T
Definition: sparssym.hxx:733
friend 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...
Real operator()(Integer i, Integer j) const
returns value of element (i,j) of the matrix (rowindex i, columnindex j)
Header declaring the class CH_Matrix_Classes::Sparsemat for sparse matrices with Real elements...
Indexmatrix suppcol
the index of the support column in the original matrix
Definition: sparssym.hxx:106
Symmatrix & xpeya(const Symmatrix &A, Real d=1.)
sets *this+=d*A and returns *this
void update_support()
removes zeros and updates suppind and suppcol