12#define EPS DBL_EPSILON
15#define EPS std::numeric_limits<double>::epsilon()
31#define SparseAddInto_D 0
36 template<
class F,
class G>
70 typedef typename Cmplxtype<F>::type
c_type;
72 typedef typename std::conditional<std::is_same<typename Realtype<F>::type, F>::value ,
131 const bool single =
false);
164 const bool single =
false);
196 const Real eps = 0.0);
210 const Real eps = 0.0);
223 const Real eps = 0.0);
238 const Real eps = 0.0);
253 const Real eps = 0.0);
321 template<
class H,
class I>
362 this->
dimX_ = nX_ =
m; this->dimY_ = nY_ = n;
374 bool storeMatlab(
const std::string filename,
const std::string name =
"",
375 bool append =
false)
const;
394 template<
class H,
class I>
405 template<
class H,
class I>
412 template<
class H,
class I>
419 template<
class H,
class I>
458 virtual std::ostream&
info(std::ostream&
os)
const;
467 std::unique_ptr<HashedSparseMatrix<F> > m_;
470 static uint storeMatlabCounter_;
483 :
Matrix<F>(m.dimX(), m.dimY())
484 , nX_(m.dimX()), nY_(m.dimY())
487 int hashBits =
m.m()->HashBits();
488 int p = 1 << hashBits;
491 for (
uint r = 0; r < nX_; ++r)
494 matrix[(r<<hashBits) +
c_mod]; v !=
NULL; v = v->lnk)
495 (*m_)(r, v->idx) =
fnc(v->val);
501 :
Matrix<F>(m.dimX(), m.dimY())
502 , nX_(m.dimX()), nY_(m.dimY())
505 int hashBits =
m.m()->HashBits();
506 int p = 1 << hashBits;
509 for (
uint r = 0; r < nX_; ++r)
512 matrix[(r<<hashBits) +
c_mod]; v !=
NULL; v = v->lnk)
513 (*m_)(r, v->idx) = (F)(v->val);
519 const F&
fnc(
const H&))
520 :
Matrix<F>(m.dimX(), m.dimY())
521 , nX_(m.dimX()), nY_(m.dimY())
524 int hashBits =
m.m()->HashBits();
525 int p = 1 << hashBits;
528 for (
uint r = 0; r < nX_; ++r)
531 matrix[(r<<hashBits) +
c_mod]; v !=
NULL; v = v->lnk)
532 (*m_)(r, v->idx) =
fnc(v->val);
537 template<
class H,
class I>
544 "dest.dimY() = " <<
dest.dimY() <<
", dimY() = " <<
551 int hashBits = m_->HashBits();
552 int p = 1 << hashBits;
553 uint n = this->dimX();
556 for (
uint r = 0; r < n; ++r)
559 matrix[(r<<hashBits) +
c_mod]; v !=
NULL; v = v->lnk)
566 template<
class H,
class I>
572 "dest.dimY() = " <<
dest.dimX() <<
", dimX() = " <<
575 "dest.dimX() = " <<
dest.dimX() <<
", dimY() = " <<
581 int hashBits = m_->HashBits();
582 int p = 1 << hashBits;
583 uint n = this->dimX();
586 for (
uint r = 0; r < n; ++r)
589 matrix[(r<<hashBits) +
c_mod]; v !=
NULL; v = v->lnk)
596 template<
class H,
class I>
604 const H* h = (
const H*)v;
612 template<
class H,
class I>
620 const H* h = (
const H*)v;
uint dim() const
Returns the dimension of the function.
F type
Type of data, e.g. matrix entries.
virtual void operator()()
uint dimX_
Dimension of image space and the source space.
void addInto(Matrix< H > &dest, const I fact, const uint rowoffset=0, const uint coloffset=0) const
void multiply(const H &fact, Matrix< F > &dest) const
Multiplies this matrix with fact and adds the result to dest.
virtual void convertCCS(F *a, int *asub, int *xa) const
SparseMatrix(const Space< G > &spc, const Sequence< bool > &seq, const BilinearForm< F, G > &bf, const Real eps=0.0)
void histogram(std::map< int, uint > &hist) const
Creates a histogram of the matrix entries.
Cmplxtype< F >::type c_type
Complex type of data type.
Realtype< F >::type r_type
Real type of data type.
void addIntoT(Matrix< H > &dest, const I fact, const uint rowoffset=0, const uint coloffset=0) const
virtual void convertIJK(F *, int *, int *) const
void write(char *fname) const
virtual F & operator()(const uint i, const uint j)
Returns and allows access to entry with indices i and j.
SparseMatrix(const Space< G > &spc, const Vector< F > &x, const Vector< F > &y)
const HashedSparseMatrix< F > * m() const
Returns the sparse matrix itself.
SparseMatrix(const Space< G > &spc, const F *const v, const int i=-1)
const_iterator end() const
Last entrance of the particular order.
SparseMatrix(const Space< typename Realtype< F >::type > &spc, const BilinearFormContainer< F > bf, const Real eps=0.0)
void operator()(const Vector< H > &fncY, Vector< I > &fncX)
Multiplies the matrix with fncY. The result is fncX.
virtual void operator()(const Function< c_type > &fncY, Function< c_type > &fncX)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const_iterator begin(uint row=0) const
void copy(const SparseMatrix< F > &n)
Copies n to this matrix.
virtual void transpMult(const Vector< r_type > &fncY, Vector< F > &fncX)
std::conditional< std::is_same< typenameRealtype< F >::type, F >::value, typenameRealtype< F >::type, typenameCmplxtype< F >::type >::type d_type
Data type, depending if F is real or complex.
void multiply(const SparseMatrix< F > &fact, Matrix< F > &dest) const
Multiplies this matrix with fact and adds the result to dest.
SparseMatrix(const Space< G > &spc, const BilinearForm< F, G > &bf, const Real eps=0.0)
bool storeMatlab(const std::string filename, const std::string name="", bool append=false) const
iterator begin(uint row=0)
void compress(Real threshold=EPS)
SparseMatrix(Operator< H > &A, bool slow=false)
SparseMatrix(const Space< G > &spcX, const Space< G > &spcY, const BilinearForm< F, G > &bf, const Sequence< ElementWithCell< G > * > &seq, const Real eps=0.0)
float memory() const
Memory usage in byte.
virtual void convertCRS(F *a, int *asub, int *xa) const
void symmetrize()
Makes sure a theoretically symmetric matrix is symmetric in memory too.
SparseMatrix(const Space< G > &spc, const BilinearForm< F, G > &bf, const Sequence< ElementWithCell< G > * > &seq, const Real eps=0.0)
void addT(const Vector< H > &v, const I fact, const uint rowoffset=0, const uint coloffset=0)
SparseMatrix(const SparseMatrix< F > &m, bool t=false)
SparseMatrix(const SparseMatrix< H > &fncX)
SparseMatrix(const Space< G > &spcX, const Space< G > &spcY, const BilinearForm< F, G > &bf, const Real eps=0.0, const bool single=false)
virtual F operator()(const uint i, const uint j) const
Returns entry with indices i and j.
SparseMatrix(const Space< G > &spcX, const Space< G > &spcY)
virtual uint used() const
Returns the number of used entries in the matrix.
SparseMatrix(uint nofrows, uint nofcols)
void add(const Vector< H > &v, const I fact, const uint rowoffset=0, const uint coloffset=0)
virtual void resize(uint m, uint n)
Sets a new size, previous data might be lost
SparseMatrix(const SparseMatrix< H > &fncX, F fnc(const H &))
SparseMatrix(const Space< G > &spcX, const Space< G > &spcY, const Sequence< bool > &seq, const BilinearForm< F, G > &bf, const Real eps=0.0, const bool single=false)
#define conceptsAssert(cond, exc)
#define DEBUGL(doit, msg)
#define conceptsAssert3(cond, exc, msg)
void matrixMultiplyRowSorting(const F &factL, const G &factR, Matrix< H > &dest)
Set< F > makeSet(uint n, const F &first,...)