2 #ifndef CH_MATRIX_CLASSES__MATRIX_HXX 3 #define CH_MATRIX_CLASSES__MATRIX_HXX 14 #ifndef CH_MATRIX_CLASSES__INDEXMAT_HXX 47 from(_from),to(_to),step(_step),tol(_tol){}
102 inline void init_to_zero();
133 inline Matrix(
const std::vector<Real>& vec);
135 ~
Matrix(){memarray->free(m);
if (aux_m) memarray->free(aux_m);}
137 #if (CONICBUNDLE_DEBUG>=1) 138 void set_init(
bool i){is_init=i;}
141 bool get_init()
const {
return is_init;}
143 void set_init(
bool ){}
166 inline Matrix& init(
const std::vector<Real>& vec);
389 Real alpha,
Real beta,
int atrans,
int btrans);
519 friend std::vector<double>&
assign(std::vector<double>& vec,
const Matrix& A);
538 Real alpha,
Real beta,
int atrans,
int btrans);
543 Real alpha,
Real beta,
int atrans,
int btrans);
835 void display(std::ostream& out,
843 void mfile_output(std::ostream& out,
880 Real alpha=1.,
Real beta=0.,
int atrans=0,
int btrans=0);
886 std::vector<double>&
assign(std::vector<double>& vec,
const Matrix& A);
906 Real alpha,
Real beta,
int atrans,
int btrans);
910 Real alpha,
Real beta,
int atrans,
int btrans);
1005 nr=nc=0;mem_dim=0;m=0;
1024 if (incr==1)
mat_xey(nr*nc,m,p);
1028 if (incr==1)
mat_xeya(nr*nc,m,p,d);
1037 return xeya(A,d,atrans);
1048 for(
Integer i=0;i<nr;i++) m[i]=vec[(
unsigned long)(i)];
1077 for(
Integer i=0;i<n;i++) m[i*(n+1)]=vec.
m[i]*d;
1120 init(inr,inc,p,incr,d);
1154 {
return (*
this)(i);}
1157 {
return (*
this)(i);}
1179 assert(scaling->dim()==A.
nr);
1181 const Real*
const mend=mp+A.
nr;
1182 const Real* sp=scaling->m;
1185 const Real d=(*mp++);
1198 assert(scaling->dim()==A.
nc);
1199 const Real* mp=A.
m+i;
1200 const Real*
const mend=mp+A.
nc*A.
nr;
1201 const Real* sp=scaling->m;
1203 for(;mp!=mend;mp+=A.
nr) {
1229 (*tp++)+=(*mp)*(*mp);
1248 {
return xpeya(A); }
1251 {
return xpeya(A,-1.); }
1260 {
return Matrix(*
this,-1.); }
1288 {
Matrix C(A);
return C%=B;}
1292 {
Matrix C(A);
return C/=B;}
1308 {
Matrix B(A);
return B+=d;}
1312 {
Matrix B(A);
return B+=d;}
1316 {
Matrix B(A);
return B-=d;}
1320 {
Matrix B(A,-1.);
return B+=d;}
1325 {R=*
this;
return R.
QR_factor(Q,piv,tol);}
1360 #if (CONICBUNDLE_DEBUG>=1) 1367 {
Matrix A;
return A.
rand(rows,cols,random_generator);}
1442 {
return A.
find(tol);}
1447 inline std::vector<double>&
assign(std::vector<double>& vec,
const Matrix& A)
1450 vec.resize((
unsigned long)(A.
dim()));
1451 for(
Integer i=0;i<A.
dim();i++) vec[(
unsigned long)(i)]=A(i);
1461 #ifndef CH_MATRIX_CLASSES__SYMMAT_HXX #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 Matrix & genmult(const Matrix &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=...
AuxTask aux_task
the current purpose of the auxilliary information
Definition: matrix.hxx:95
Indexmatrix mincols(const Indexmatrix &A)
returns a column vector holding in each row the minimum over all columns in this row ...
Matrix & floor(void)
sets (*this)(i,j)=floor((*this)(i,j)) for all i,j and returns *this
void mat_xmultea(Integer len, Val *x, const Val a)
Set x[i]*=a for len elements of the array x.
Definition: matop.hxx:734
Matrix sqrt(const Matrix &A)
returns a matrix with elements (i,j)=sqrt((*this)(i,j)) for all i,j
Definition: matrix.hxx:1374
Integer mem_dim
amount of memory currently allocated
Definition: matrix.hxx:84
Matrix operator-(const Matrix &A, const Matrix &B)
returns Matrix equal to A-B
Definition: matrix.hxx:1283
Matrix & xpeya(const Matrix &A, Real d=1.)
sets *this+=d*A and returns *this
friend 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...
Definition: matrix.hxx:1221
Matrix cols(const Indexmatrix &vec) const
returns a matrix of size this->rowdim() x vec.dim(), with column i a copy of column vec(i) of *this ...
Real & operator[](Integer i)
returns reference to element (i) of the matrix if regarded as vector of stacked columns [element (iro...
Definition: matrix.hxx:1153
Integer rowdim() const
returns the row dimension
Definition: matrix.hxx:215
Real & operator()(Integer i, Integer j)
returns reference to element (i,j) of the matrix (rowindex i, columnindex j)
Definition: matrix.hxx:1129
Indexmatrix maxrows(const Indexmatrix &A)
returns a row vector holding in each column the maximum over all rows in this column ...
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
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 ...
Definition: matrix.hxx:1330
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...
Definition: matrix.hxx:1221
Matrix & init_diag(int nr, Real d=1.)
initialize to a diagonal nr x nr matrix with constant diagonal value d
Definition: matrix.hxx:1052
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
Definition: matrix.hxx:1342
void swap(double &a, double &b)
swaps two double variables
Definition: mymath.hxx:79
int ls(Matrix &rhs, Real tol)
computes a least squares solution by QR_solve, overwriting (*this). rhs is overwritten with the solut...
Definition: matrix.hxx:1326
Matrix floor(const Matrix &A)
returns a matrix with elements (i,j)=floor((*this)(i,j)) for all i,j
Definition: matrix.hxx:1386
friend 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...
Definition: matrix.hxx:1165
Real * aux_m
pointer to supplementary store for repeated use in some routines like qr
Definition: matrix.hxx:97
Indexmatrix maxcols(const Indexmatrix &A)
returns a column vector holding in each row the maximum over all columns in this row ...
Real tol
tolerance for chekcing equality
Definition: matrix.hxx:44
void mat_xea(Integer len, Val *x, const Val a)
Set x[i]=a for len elements of the array x.
Definition: matop.hxx:77
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 r...
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...
friend 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 ...
Definition: matrix.hxx:1447
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
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
Matrix & tril(Integer d=0)
keeps everything below and including diagonal d, everything above is set to zero, returns *this ...
friend Matrix operator*(const Matrix &A, const Matrix &B)
returns Matrix equal to A*B
Definition: matrix.hxx:1275
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...
Definition: matrix.hxx:1235
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...
Definition: matrix.hxx:1350
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 c...
Matrix & concat_right(const Matrix &A, int Atrans=0)
concats matrix A (or its tranpose) to the right of *this, A or *this may be the 0x0 matrix initally...
friend Matrix operator+(const Matrix &A, const Matrix &B)
returns Matrix equal to A+B
Definition: matrix.hxx:1279
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
Definition: matrix.hxx:1338
~Realrange()
destructor, nothing to do
Definition: matrix.hxx:49
Matrix operator*(const Matrix &A, const Matrix &B)
returns Matrix equal to A*B
Definition: matrix.hxx:1275
static const Mtype mtype
used for MatrixError templates (runtime type information was not yet existing)
Definition: matrix.hxx:83
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.
Definition: matop.hxx:340
friend 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...
Definition: matrix.hxx:1287
allows to specify a range of real values via (from, to, step,tol) meaning {x=from+i*step:x in(from-to...
Definition: matrix.hxx:34
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
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 poss...
Definition: matrix.hxx:1192
Matrix & rint(void)
sets (*this)(i,j)=rint((*this)(i,j)) for all i,j and returns *this
Matrix & concat_below(const Matrix &A)
concats matrix A to the bottom of *this, A or *this may be the 0x0 matrix initally, returns *this
Mtype get_mtype() const
returns the type of the matrix, MTmatrix
Definition: matrix.hxx:221
void mat_xhadey(Integer len, Val *x, const Val *y)
Set x[i]*=y[i] for len elements of the arrays x and y.
Definition: matop.hxx:470
Real * get_store()
returns the current address of the internal value array; use cautiously, do not use delete! ...
Definition: matrix.hxx:326
Matrix rint(const Matrix &A)
returns a matrix with elements (i,j)=rint((*this)(i,j)) for all i,j
Definition: matrix.hxx:1394
Matrix class of symmetric matrices with real values of type Real
Definition: symmat.hxx:43
Matrix ceil(const Matrix &A)
returns a matrix with elements (i,j)=ceil((*this)(i,j)) for all i,j
Definition: matrix.hxx:1390
Matrix operator-(Real d, const Matrix &A)
returns (i,j)=d-A(i,j) for all i,j
Definition: matrix.hxx:1319
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 val...
Definition: matrix.hxx:1444
Header declaring the class CH_Matrix_Classes::Symmatrix for symmetric matrices with Real elements...
friend Real colip(const Matrix &A, Integer j, const Matrix *scaling)
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 p...
Definition: matrix.hxx:1173
friend Real sum(const Matrix &A)
returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
int QR_factor(Real tol=1e-10)
computes a Householder QR_factorization overwriting (*this); returns 0 on success, otherwise column index +1 if the norm of the column is below tol when reaching it.
Real step
step distance between successive elements starting with from
Definition: matrix.hxx:42
Indexmatrix sumcols(const Indexmatrix &A)
returns a column vector holding the sum over all columns, i.e., 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
friend bool equal(const Matrix &A, const Matrix &B)
returns true if both matrices have the same size and the same elements
Definition: matrix.hxx:1433
friend Indexmatrix sortindex(const Matrix &vec, bool nondecreasing)
returns an Indexmatrix ind so that vec(ind(0))<=vec(ind(1))<=...<=vec(ind(vec.dim()-1)) (vec may be r...
Definition: matrix.hxx:1436
Matrix & round(void)
sets (*this)(i,j)=round((*this)(i,j)) for all i,j and returns *this
friend 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.
Definition: matrix.hxx:1291
friend 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 & xeya(const Matrix &A, Real d=1., int atrans=0)
sets *this=d*A where A may be transposed and returns *this
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...
Integer trace(const Indexmatrix &A)
returns the sum of the diagonal elements A(i,i) over all i
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.
Definition: matop.hxx:1415
friend Matrix & xeyapzb(Matrix &x, const Matrix &y, const Matrix &z, Real alpha, Real beta)
returns x= alpha*y+beta*z; x is initialized to the correct size
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
int sign(int a)
return the signum of an int a (1 for a>0,-1 for a<0,0 for a==0)
Definition: mymath.hxx:133
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)
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.
Definition: matrix.hxx:1291
Matrix Classes and Linear Algebra. See Matrix Classes (namespace CH_Matrix_Classes) for a quick intro...
Definition: PSCOracle.hxx:20
void newsize(Integer nr, Integer nc)
resize the matrix to nr x nc elements but WITHOUT initializing the memory
friend 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
Definition: matrix.hxx:1211
Matrix class of symmetric matrices with real values of type Real
Definition: sparssym.hxx:89
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
Matrix round(const Matrix &A)
returns a matrix with elements (i,j)=round((*this)(i,j)) for all i,j
Definition: matrix.hxx:1398
Matrix & operator/=(const Matrix &A)
ATTENTION: this is redefined to act componentwise without checking for zeros, (*this)(i,j)=(*this)(i,j)/A(i,j) for all i,j.
Definition: matrix.hxx:1256
Matrix & sqr(void)
sets (*this)(i,j)=sqr((*this)(i,j)) for all i,j and returns *this
#define chk_add(x, y)
CONICBUNDLE_DEBUG being undefined, the template function is removed. Otherwise it would check...
Definition: matop.hxx:1763
void mat_xey(Integer len, Val *x, const Val *y)
Copy an array of length len to destination x from source y.
Definition: matop.hxx:117
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!
Definition: matop.hxx:483
friend Real min(const Matrix &A, Integer *iindex, Integer *jindex)
returns the minimum value over all elements of the matrix
Integer dim() const
returns the dimension rows * columns when the matrix is regarded as a vector
Definition: matrix.hxx:212
Indexmatrix operator>=(const Indexmatrix &A, Integer d)
returns a matrix having elements (i,j)=Integer(A(i,j)>=d) for all i,j
Indexmatrix find_number(Real num=0., Real tol=1e-10) const
returns an Indexmatrix ind so that (*this)(ind(i)) 0<=i<ind.dim() runs through all elements of value ...
Matrix & sign(Real tol=1e-12)
sets (*this)(i,j)=sign((*this)(i,j),tol) for all i,j using sign(double,double) and returns *this ...
Integer coldim() const
returns the column dimension
Definition: matrix.hxx:218
Integer aux_dim
amount of memory currently allocated in auxm
Definition: matrix.hxx:96
bool is_init
flag whether memory is initialized, it is only used if CONICBUNDLE_DEBUG is defined ...
Definition: matrix.hxx:99
int QR_solve(Matrix &rhs, Real tol=1e-10)
solves (*this)*x=rhs by factorizing and overwriting (*this); rhs is overwritten with the solution...
friend 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 class for real values of type Real
Definition: matrix.hxx:74
Indexmatrix transpose(const Indexmatrix &A)
returns an Indexmatrix that is the transpose of A
const Real * get_store() const
returns the current address of the internal value array; use cautiously!
Definition: matrix.hxx:328
friend Real rowip(const Matrix &A, Integer i, const Matrix *scaling)
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 poss...
Definition: matrix.hxx:1192
Matrix & triu(Integer d=0)
keeps everything above and including diagonal d, everything below is set to zero, returns *this ...
Realrange(Real _from, Real _to, Real _step=1, Real _tol=1e-8)
constructor for {d: d=from+k*step for some k in N_0 and d<=to+tol}
Definition: matrix.hxx:46
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.
Definition: matop.hxx:1096
Matrix class of sparse matrices with real values of type Real
Definition: sparsmat.hxx:74
Matrix & inv(void)
sets (*this)(i,j)=1./(*this)(i,j) for all i,j and returns *this
int sqr(int a)
return a*a for int a
Definition: mymath.hxx:103
Indexmatrix operator>(const Indexmatrix &A, Integer d)
returns a matrix having elements (i,j)=Integer(A(i,j)>d) for all i,j
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 ...
Definition: matrix.hxx:1447
double max(double a, double b)
maximum value of two double variables
Definition: mymath.hxx:43
Indexmatrix sumrows(const Indexmatrix &A)
returns a row vector holding the sum over all rows, i.e., (1 1 ... 1)*A
All derived classes share a common Memarray memory manager, which is generated with the first user an...
Definition: memarray.hxx:117
friend Real max(const Matrix &A, Integer *iindex, Integer *jindex)
returns the maximum value over all elements of the matrix
Integer nc
number of columns
Definition: matrix.hxx:85
Integer nr
number of rows
Definition: matrix.hxx:85
#define chk_range(i, j, ubi, ubj)
CONICBUNDLE_DEBUG being undefined, the template function is removed. Otherwise it would check...
Definition: matop.hxx:1772
Indexmatrix minrows(const Indexmatrix &A)
returns a row vector holding in each column the minimum over all rows in this column ...
Real to
upper bound on element values
Definition: matrix.hxx:40
friend 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
Definition: matrix.hxx:1407
double min(double a, double b)
minimum value of two double variables
Definition: mymath.hxx:49
Indexmatrix & genmult(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=...
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 ...
Definition: matrix.hxx:1346
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)
double abs(double d)
absolute value of a double
Definition: mymath.hxx:25
friend 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
Integer * m
pointer to store, order is columnwise (a11,a21,...,anr1,a12,a22,.....)
Definition: indexmat.hxx:208
friend void swap(Matrix &A, Matrix &B)
swap the content of the two matrices A and B (involves no copying)
Definition: matrix.hxx:1354
Indexmatrix & xbpeya(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...
Matrix & operator%=(const Matrix &A)
ATTENTION: this is redefined as the Hadamard product, (*this)(i,j)=(*this)(i,j)*A(i,j) for all i,j.
Definition: matrix.hxx:1253
Header declaring the classes CH_Matrix_Classes::Range and CH_Matrix_Classes::Indexmatrix for supporti...
AuxTask
the auxilliary storage aux_m may be used for different pruposes which are listed here; this is used t...
Definition: matrix.hxx:91
Integer sum(const Indexmatrix &A)
returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
Matrix & ceil(void)
sets (*this)(i,j)=ceil((*this)(i,j)) for all i,j and returns *this
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 ...
Definition: matrix.hxx:1370
bool get_init() const
returns true if the matrix has been declared initialized (not needed if CONICBUNDLE_DEBUG is undefine...
Definition: matrix.hxx:146
Matrix operator+(const Matrix &A, const Matrix &B)
returns Matrix equal to A+B
Definition: matrix.hxx:1279
#define chk_init(x)
CONICBUNDLE_DEBUG being undefined, the template function is removed. Otherwise it would check...
Definition: matop.hxx:1761
Matrix & reduce_length(Integer n)
(*this) is set to a column vector of length min{max{0,n},dim()}; usually used to truncate a vector...
Definition: matrix.hxx:1159
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...
Definition: matrix.hxx:1366
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...
Definition: matrix.hxx:1287
Matrix & rand(Integer nr, Integer nc, CH_Tools::GB_rand *random_generator=0)
resize *this to an nr x nc matrix and assign to (i,j) a random number uniformly from [0...
void mat_xpea(Integer len, Val *x, const Val a)
Set x[i]+=a for len elements of the array x.
Definition: matop.hxx:690
void dim(Integer &_nr, Integer &_nc) const
returns the number of rows in _nr and the number of columns in _nc
Definition: indexmat.hxx:315
bool equal(const Matrix &A, const Matrix &B)
returns true if both matrices have the same size and the same elements
Definition: matrix.hxx:1433
Indexmatrix & xeyapzb(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 ...
double sqrt(int a)
return sqrt for int a
Definition: mymath.hxx:121
Matrix()
empty matrix
Definition: matrix.hxx:1082
friend 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
Definition: matrix.hxx:1403
aux_m currently not in use
Definition: matrix.hxx:92
friend 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
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...
Definition: matrix.hxx:1165
Matrix rows(const Indexmatrix &vec) const
returns a matrix of size vec.dim() x this->coldim(), with row i a copy of row vec(i) of *this ...
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 p...
Definition: matrix.hxx:1173
Matrix & sqrt(void)
sets (*this)(i,j)=sqrt((*this)(i,j)) for all i,j and returns *this
Real from
value of starting element
Definition: matrix.hxx:38
Indexmatrix find(Real tol=1e-10) const
returns an Indexmatrix ind so that (*this)(ind(i)) 0<=i<ind.dim() runs through all nonzero elements ...
Real * m
pointer to store, order is columnwise (a11,a21,...,anr1,a12,a22,.....)
Definition: matrix.hxx:87
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
Definition: matrix.hxx:1211
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
void init_to_zero()
initialize the matrix to a 0x0 matrix without storage
Definition: matrix.hxx:1003
friend 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...
Definition: matrix.hxx:1235
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 ab...
Definition: matrix.hxx:1441
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