28 #include <type_traits> 32 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
42 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
43 template<
class Form2,
class Cmpt2>
53 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
56 template<
class, Foam::direction, Foam::direction>
class Block2,
62 const Block2<Form, BRowStart, BColStart>&
block 75 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
78 MatrixSpace::vsType(is)
82 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
83 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
93 "Rows in block > rows in matrix" 98 "Columns in block > columns in matrix" 103 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
104 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
114 "Rows in block > rows in matrix" 119 "Columns in block > columns in matrix" 126 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
127 template<Foam::direction Row, Foam::direction Col>
131 static_assert(Row < Mrows && Col < Ncols,
"Address outside matrix");
132 return this->
v_[Row*Ncols + Col];
136 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
137 template<Foam::direction Row, Foam::direction Col>
141 static_assert(Row < Mrows && Col < Ncols,
"Address outside matrix");
142 return this->
v_[Row*Ncols + Col];
146 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
150 static_assert(Mrows == Ncols,
"Matrix is not square");
162 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
180 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
188 ConstBlock<SubTensor, BRowStart, BColStart>
195 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
204 Block<SubTensor, BRowStart, BColStart>
213 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
221 if (i >= Mrows || j >= Ncols)
224 <<
"indices out of range" 229 return this->
v_[i*Ncols + j];
233 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
241 if (i >= Mrows || j >= Ncols)
244 <<
"indices out of range" 249 return this->
v_[i*Ncols + j];
253 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
254 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
264 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
265 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
271 return matrix_(BRowStart + i, BColStart + j);
275 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
276 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
284 for (
direction i=0; i<SubTensor::mRows; ++i)
286 for (
direction j=0; j<SubTensor::nCols; ++j)
288 st[i*SubTensor::nCols + j] =
operator()(i, j);
296 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
297 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
303 return matrix_(BRowStart + i, BColStart + j);
307 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
308 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
314 return matrix_(BRowStart + i, BColStart + j);
318 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
328 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
329 template<
class Form2>
332 const MatrixSpace<Form, Cmpt, Ncols, Ncols>& matrix
335 *
this = *
this & matrix;
339 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
342 template<
class, Foam::direction, Foam::direction>
class Block2,
348 const Block2<Form, BRowStart, BColStart>&
block 361 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
362 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
363 template<
class Form2>
382 template<
class Form,
class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
383 template<
class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
384 template<
class VSForm>
393 static_assert(
nCols == 1,
"Matrix must have a single column");
395 for (
direction i=0; i<SubTensor::mRows; ++i)
409 template<
class Form,
class Cmpt, direction Mrows, direction Ncols>
419 template<
class Form,
class Cmpt, direction Ncmpts>
422 const VectorSpace<Form, Cmpt, Ncmpts>& v
457 "Number of columns in matrix 1 != number of rows in matrix 2" 468 result(i, j) += matrix1(i,
k)*matrix2(
k, j);
477 template<
class Form,
class VSForm,
class Cmpt, direction Mrows, direction Ncols>
480 const MatrixSpace<Form, Cmpt, Mrows, Ncols>& matrix,
481 const VectorSpace<VSForm, Cmpt, Ncols>& v
490 result[i] += matrix(i, j)*v[j];
518 result(i, j) = v1[i]*v2[j];
Abstract template class to provide the form resulting from the outer-product of two forms...
Abstract template class to provide the form resulting from the inner-product of two forms...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Cmpt & operator()(const direction &i, const direction &j) const
(i, j) const element access operator
void operator=(const VectorSpace< Form, Cmpt, Ncmpts > &)
static const direction nCols
MatrixSpace< Form, Cmpt, Mrows, Ncols > msType
MatrixSpace type.
label k
Boltzmann constant.
typeOfTranspose< Cmpt, Form >::type T() const
Return the transpose of the matrix.
static const direction mRows
static constexpr direction nCols
static constexpr direction mRows
static const direction mRows
static const direction nCols
errorManip< error > abort(error &err)
Abstract template class to provide the transpose form of a form.
ConstBlock< SubTensor, BRowStart, BColStart > block() const
Return a const sub-block corresponding to the specified type.
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
const Cmpt & elmt() const noexcept
Fast const element access using compile-time addressing.
friend Ostream & operator(Ostream &, const VectorSpace< Form, Cmpt, Ncmpts > &)
MatrixSpace()=default
Default construct.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
static msType identity()
An identity matrix for square matrix-spaces.
Cmpt v_[Ncmpts]
The components of this vector space.
static constexpr const zero Zero
Global zero (0)