15 template<
class Sub
class>
33 MatrixP&
parent()
const {
return *_m; }
55 assert(_rows >= 0 && _cols >= 0,
"Block size must be zero or greater");
57 <<
"Block row bounds out of matrix range. Matrix rows: " << _m->rows()
58 <<
" ; Block range: [" << _row <<
", " << _row + _rows <<
")");
60 <<
"Block column bounds out of matrix range. Matrix columns: " << _m->cols()
61 <<
" ; Block range: [" << _col <<
", " << _col + _cols <<
")");
74 template<
class Src,
class Dst>
77 if (!src.
size())
return;
78 for (
sdt i = 0; i < src.
rows(); ++i)
79 std::copy_n(&src(i, 0), src.
cols(), &dst(i, 0));
83 template<
class Src,
class Dst>
85 template<
class Src,
class Dst>
87 template<
class Src,
class Dst>
94 if (!dst.
size())
return;
95 for (
sdt i = 0; i < dst.
rows(); ++i)
96 std::copy_n(src + i*dst.
cols(), dst.
cols(), &dst(i, 0));
101 if (!src.
size())
return;
102 for (
sdt i = 0; i < src.
rows(); ++i)
103 std::copy_n(&src(i, 0), src.
cols(), dst + i*src.
cols());
107 template<
class Src,
class Dst,
class Func>
110 if (!src.
size())
return;
111 for (
sdt i = 0; i < src.
rows(); ++i)
113 auto srcRow = &src(i, 0);
114 std::transform(srcRow, srcRow + src.
cols(), &dst(i, 0), f);
119 template<
class Src,
class Dst,
class Func>
121 template<
class Src,
class Dst,
class Func>
123 template<
class Src,
class Dst,
class Func>
130 if (!store.
size())
return;
131 for (
sdt i = 0; i < store.
rows(); ++i)
132 std::fill_n(&store(i, 0), store.
cols(), f);
138 if (!store.
size())
return;
139 for (
sdt i = 0; i < store.
rows(); ++i)
144 template<
class T,
class T2>
148 if (!lhs.
size())
return true;
149 for (
sdt i = 0; i < lhs.
rows(); ++i)
156 template<
class T,
class T2>
159 template<
class T,
class T2>
161 template<
class T,
class T2>
165 template<
class MatrixP_, sdt Rows, sdt Cols>
174 typedef typename std::conditional<std::is_const<MatrixP>::value,
const typename MatrixP::ElemT,
typename MatrixP::ElemT>::type
179 typedef typename MatrixP::Alloc
Alloc;
182 template<
class MatrixP, sdt Rows, sdt Cols>
187 template<
class MatrixP, sdt s_rows, sdt s_cols>
196 { this->initBlock(m, row, col, rows, cols); }
210 namespace vec {
namespace priv
213 template<
class Vec, sdt Dim>
218 Traits::cols == 1 ? 1 : Dim>
type;
220 static type
create(Vec& v,
sdt i,
sdt dim = -1) {
return Traits::cols == 1 ?
type(v,i,0,dim,1) :
type(v,0,i,1,dim); }
(m x n)-dimensional matrix
Definition: Matrix.h:24
static const sdt dynamic
Definition: Traits.h:23
Block()
Definition: Block.h:194
void storageFillZero(StorageBlock< T > &store)
Fill block storage with zeros.
Definition: Block.h:136
std::conditional< std::is_const< MatrixP >::value, const typename MatrixP::ElemT, typename MatrixP::ElemT >::type ElemT
Our element access is const if matrix is const.
Definition: Block.h:175
Traits< Subclass >::Real Real
Definition: Storage.h:12
MatrixP::Real Real
Definition: Block.h:172
static const sdt s_cols
Definition: Storage.h:16
static type create(Vec &v, sdt i, sdt dim=-1)
Definition: Block.h:220
Traits< Subclass >::ElemT ElemT
Definition: Storage.h:14
sdt size() const
Get size.
Definition: Block.h:43
Vector segment view.
Definition: Block.h:214
sdt size() const
Definition: Storage.h:36
Block(MatrixP &m, sdt row, sdt col, sdt rows=-1, sdt cols=-1)
Definition: Block.h:195
bool storageRowEqual(const StorageDense< T > &lhs, const StorageDense< T2 > &rhs)
Test by row between dense storages.
Definition: Block.h:145
ptrdiff_t sdt
Size difference type, shorthand for ptrdiff_t.
Definition: Core.h:92
bool storageEqual(const StorageBlock< T > &lhs, const StorageBlock< T2 > &rhs)
Test between block storages.
Definition: Block.h:157
sdt rows() const
Get row size.
Definition: Block.h:39
static const sdt s_rows
Definition: Storage.h:15
matrix::Block< Vec, Traits::cols==1?Dim:1, Traits::cols==1?1:Dim > type
Definition: Block.h:218
Block wrapper around any constant matrix with auto / dynamic dense storage type. Fully recursive...
Definition: Block.h:16
void initBlock(MatrixP &m, sdt row, sdt col, sdt rows, sdt cols)
Definition: Block.h:46
Matrix block view.
Definition: Block.h:188
ElemT & operator()(sdt row, sdt col) const
Definition: Block.h:27
static const sdt cols
Definition: Block.h:177
ElemT * data() const
Get as array. Top-left corner of block sub-section is at index 0.
Definition: Block.h:30
ElemT * operator[](sdt row) const
Definition: Block.h:25
static const sdt rows
Definition: Block.h:176
unsigned char uint8
Definition: Core.h:12
void assertIndex(sdt i) const
Definition: Storage.h:50
MatrixP::Alloc Alloc
Definition: Block.h:179
ostringstream sout()
Shorthand to create ostringstream.
Definition: Stream.h:15
void storageTransform(const StorageBlock< Src > &src, StorageBlock< Dst > &dst, Func &&f)
Transform between block and dense storages.
Definition: Block.h:120
#define assert(...)
Forwards to assert_#args. See assert_1(), assert_2().
Definition: Debug.h:24
N-dimensional vector.
Definition: Traits.h:12
static const sdt cols
Definition: Vec.h:21
Matrix< s_rows, s_cols, typename Super::Real, Super::options, typename Super::Alloc > MatrixEval
Definition: Block.h:192
float Real
Real number type. See Real_ for real number operations and constants.
Definition: Real.h:21
void storageRowTransform(const StorageDense< Src > &src, StorageDense< Dst > &dst, const Func &f)
Tranform by row between dense storages.
Definition: Block.h:108
sdt col() const
Get column offset.
Definition: Block.h:37
Traits< Subclass >::MatrixP MatrixP
Definition: Block.h:23
MatrixP & parent() const
Get parent matrix that contains this sub-block.
Definition: Block.h:33
void storageFill(StorageBlock< T > &store, typename StorageBlock< T >::Real f)
Fill block storage with scalar.
Definition: Block.h:128
sdt cols() const
Definition: Storage.h:35
MatrixBase< Subclass > Base
Definition: Block.h:169
Block< MatrixP_, Rows, Cols > Subclass
Definition: Block.h:168
sdt rows() const
Definition: Storage.h:34
void storageRowCopy(const StorageDense< Src > &src, StorageDense< Dst > &dst)
Copy by row between dense storages.
Definition: Block.h:75
MatrixP_ MatrixP
Definition: Block.h:171
static const int options
Definition: Block.h:178
sdt row() const
Get row offset.
Definition: Block.h:35
matrix::priv::Traits< typename std::remove_const< Vec >::type > Traits
Definition: Block.h:216
void storageCopy(const StorageBlock< Src > &src, StorageBlock< Dst > &dst)
Copy between block and dense storages.
Definition: Block.h:84
Block & operator=(const MatrixBase< T > &rhs)
Assign to matrix.
Definition: Block.h:200
Matrix base class.
Definition: Base.h:17
sdt cols() const
Get column size.
Definition: Block.h:41
ElemT & operator()(sdt i) const
Definition: Block.h:26
Global Honeycomb namespace.
StorageBlock< Subclass > Storage
Definition: Block.h:170
MatrixEval eval() const
Convert to matrix.
Definition: Block.h:203