6 #ifndef MYRAMATH_SPARSE_SPARSEMATRIXBUILDER_H 7 #define MYRAMATH_SPARSE_SPARSEMATRIXBUILDER_H 15 #include <myramath/MYRAMATH_EXPORT.h> 29 template<
class Number>
class SparseMatrix;
30 template<
class Number>
class CSparseMatrixRange;
31 template<
class Number>
class Matrix;
45 : i(ii), j(jj), value(vv) { }
49 : i(ii), j(jj), value(0) { }
53 : i(0), j(0), value(0) { }
58 template<
class Number>
class MYRAMATH_EXPORT SparseMatrixBuilder
64 typedef std::vector<Triplet> Triplets;
65 typedef const Triplet* Iterator;
70 SparseMatrixBuilder();
73 explicit SparseMatrixBuilder(
int in_I,
int in_J);
74 explicit SparseMatrixBuilder(std::pair<int,int> in_IJ);
77 SparseMatrixBuilder(
const SparseMatrixBuilder& that);
80 void swap(SparseMatrixBuilder& that);
82 #ifdef MYRAMATH_ENABLE_CPP11 83 SparseMatrixBuilder(SparseMatrixBuilder&& that);
88 SparseMatrixBuilder& operator = (SparseMatrixBuilder that);
103 ~SparseMatrixBuilder();
108 Iterator begin()
const;
109 Iterator end()
const;
112 std::pair<int,int> size()
const;
117 Number& operator () (
int i,
int j);
120 void erase(
int i,
int j);
123 void operator += (
const SparseMatrixBuilder& that);
127 void operator -= (
const SparseMatrixBuilder& that);
131 void operator *= (Number alpha);
134 void operator /= (Number alpha);
159 void check_size(
const std::pair<int,int>& IJ)
const;
175 {
public:
typedef Number type; };
179 {
public:
typedef Number type; };
206 MYRAMATH_EXPORT std::ostream& operator << (std::ostream& out, const SparseMatrixBuilder<NumberS>& A);
207 MYRAMATH_EXPORT std::ostream& operator << (std::ostream& out, const SparseMatrixBuilder<NumberD>& A);
208 MYRAMATH_EXPORT std::ostream& operator << (std::ostream& out, const SparseMatrixBuilder<NumberC>& A);
209 MYRAMATH_EXPORT std::ostream& operator << (std::ostream& out, const SparseMatrixBuilder<NumberZ>& A);
Number random()
Generate random real/complex Numbers, uniformly distributed over [-1,1].
Reflects Number trait for a Container, containers of Numbers (Matrix's, Vector's, etc) should special...
Definition: Number.h:55
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
Represents an immutable view of a Pattern.
Definition: PatternRange.h:31
Abstraction layer, serializable objects write themselves to these.
Definition: Streams.h:39
Value type of SparseMatrixBuilder, a triplet of (i,j,value)
Definition: SparseMatrixBuilder.h:34
Various utility functions/classes related to scalar Number types.
Represents a const SparseMatrixRange.
Definition: bothcat.h:24
Holds the nonzero pattern of a sparse matrix.
Definition: Pattern.h:55
Convenience type for building SparseMatrix's, uses coordinate/triplet format.
Definition: SparseMatrix.h:32
Stores an IxJ matrix A in compressed sparse column format.
Definition: bothcat.h:23
float NumberS
Useful typedefs.
Definition: Number.h:21