22 #ifndef general_band_matrix_h 23 #define general_band_matrix_h 58 typedef AT value_type;
64 explicit Matrix() : memory(), ele(0) {
76 explicit Matrix(
int n_,
int kl_,
int ku_,
Noinit) : memory(n_*(kl_+ku_+1)), ele((AT*)memory.get()), n(n_), kl(kl_), ku(ku_) { }
77 explicit Matrix(
int n_,
int kl_,
int ku_, Init ini=INIT,
const AT &a=AT()) : memory(n_*(kl_+ku_+1)), ele((AT*)memory.get()), n(n_), kl(kl_), ku(ku_) { init(a); }
78 explicit Matrix(
int n_,
int kl_,
int ku_, Eye ini,
const AT &a=1) : memory(n_*(kl_+ku_+1)), ele((AT*)memory.get()), n(n_), kl(kl_), ku(ku_) { init(ini,a); }
79 explicit Matrix(
int m_,
int n_,
int kl_,
int ku_, Noinit) : memory(n_*(kl_+ku_+1)), ele((AT*)memory.get()), n(n_), kl(kl_), ku(ku_) { }
80 explicit Matrix(
int m_,
int n_,
int kl_,
int ku_, Init ini=INIT,
const AT &a=AT()) : memory(n_*(kl_+ku_+1)), ele((AT*)memory.get()), n(n_), kl(kl_), ku(ku_) { init(a); }
81 explicit Matrix(
int m_,
int n_,
int kl_,
int ku_, Eye ini,
const AT &a=1) : memory(n_*(kl_+ku_+1)), ele((AT*)memory.get()), n(n_), kl(kl_), ku(ku_) { init(ini,a); }
97 template<
class Type,
class Row,
class Col>
99 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
112 explicit Matrix(
int n_,
int kl_,
int ku_, AT* ele_) : memory(), ele(ele_), n(n_), kl(kl_), ku(ku_) {
120 n = n_; kl = kl_; ku = ku_;
121 memory.resize(n*(kl+ku+1));
122 ele = (AT*)memory.get();
126 Matrix<GeneralBand,Ref,Ref,AT>& resize(
int n,
int kl,
int ku=0, Init ini=INIT,
const AT &a=AT()) {
return resize(n,kl,ku,Noinit()).
init(a); }
128 Matrix<GeneralBand,Ref,Ref,AT>& resize(
int n,
int kl,
int ku, Eye ini,
const AT &a=1) {
return resize(n,kl,ku,Noinit()).
init(a); }
137 FMATVEC_ASSERT(n == A.n, AT);
147 template<
class Type,
class Row,
class Col>
149 FMATVEC_ASSERT(n == A.
rows(), AT);
150 FMATVEC_ASSERT(n == A.
cols(), AT);
173 template<
class Type,
class Row,
class Col>
175 if(n!=A.n) resize(A.
rows(),NONINIT);
189 FMATVEC_ASSERT(i>=0, AT);
190 FMATVEC_ASSERT(j>=0, AT);
191 FMATVEC_ASSERT(i<n, AT);
192 FMATVEC_ASSERT(j<n, AT);
197 return ((i-j>kl) || (i-j<-ku)) ? zero : ele[ku+i+j*(kl+ku)];
239 return CblasColMajor;
266 inline Matrix<GeneralBand,Ref,Ref,AT>& init(Eye,
const AT &val=1);
267 inline Matrix<GeneralBand,Ref,Ref,AT>& init(Noinit,
const AT &a=AT()) {
return *
this; }
273 explicit inline operator std::vector<std::vector<AT>>()
const;
278 for(
int i=0; i<kl+ku+1; i++)
279 for(
int j=0; j<n; j++)
280 ele[i+j*(kl+ku+1)] = val;
286 for(
int i=0; i<n; i++)
312 std::vector<std::vector<AT>> ret(rows());
313 for(
int r=0; r<rows(); r++) {
314 ret[r].resize(cols());
315 for(
int c=0; c<cols(); c++)
316 ret[r][c]=
operator()(r,c);
325 for(
int i=0; i<kl+ku+1; i++)
326 for(
int j=0; j<n; j++)
327 ele[i+j*(kl+ku+1)] = A.ele[i+j*(kl+ku+1)];
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
Matrix(const Matrix< GeneralBand, Ref, Ref, AT > &A)
Copy Constructor.
Definition: band_matrix.h:88
This is a matrix class for general band matrices.
Definition: band_matrix.h:40
const CBLAS_ORDER blasOrder() const
Storage convention.
Definition: band_matrix.h:238
Shape class for general band matrices.
Definition: types.h:140
const AT * operator()() const
Pointer operator.
Definition: band_matrix.h:211
Matrix(const Matrix< Type, Row, Col, AT > &A)
Copy Constructor.
Definition: band_matrix.h:98
int size() const
Size.
Definition: band_matrix.h:217
Matrix< GeneralBand, Ref, Ref, AT > & operator=(const Matrix< GeneralBand, Ref, Ref, AT > &A)
Assignment operator.
Definition: band_matrix.h:136
int rows() const
Number of rows.
Definition: band_matrix.h:223
AT * operator()()
Pointer operator.
Definition: band_matrix.h:205
Matrix(int n_, int kl_, int ku_, AT *ele_)
Regular Constructor.
Definition: band_matrix.h:112
int cols() const
Number of columns.
Matrix< GeneralBand, Ref, Ref, AT > & operator=(const Matrix< Type, Row, Col, AT > &A)
Assignment operator.
Definition: band_matrix.h:148
Matrix()
Standard constructor.
Definition: band_matrix.h:64
Namespace fmatvec.
Definition: _memory.cc:28
Matrix< GeneralBand, Ref, Ref, AT > & operator&=(Matrix< GeneralBand, Ref, Ref, AT > &A)
Reference operator.
Definition: band_matrix.h:160
int cols() const
Number of columns.
Definition: band_matrix.h:229
const AT & operator()(int i, int j) const
Element operator.
Definition: band_matrix.h:188
Matrix< GeneralBand, Ref, Ref, AT > & init(const AT &val=AT())
Diagonal operator.
Definition: band_matrix.h:277
int rows() const
Number of rows.