chsvlib
chsv helper source code

◆ Matrix() [10/16]

Matrix ( value_t(&)  Arr2[cRows][cColumns],
const allocator_type alloc = allocator_type() 
)

Constructs a matrix from a two dimensional array of elements.

Template Parameters
value_tis a type of an array element to be explicitly converted into value_type.
cColumnsis a number of columns within the array and a number of columns within the matrix to be created.
cRowsis a number of rows within the array and a number of rows within the matrix created.
Parameters
Arr2is the two dimensional array of matrix elements. The first dimension specifies rows of the created matrix, while the second one specifies the columns, that is the array has a form Arr2[cRows][cColumn].
allocis an allocator object used to manage storage of the matrix elements.

Example code:

#include <iostream>
#include <iomanip>
template <class value_t, class alloc_t, class derived_t, class policy_t>
std::ostream& operator<<(std::ostream& os, const Chusov::Math::Matrix<value_t, alloc_t, derived_t, policy_t>& m)
{
for (std::size_t iRow = 0; iRow < m.Rows(); ++iRow)
{
os << '[';
for (auto& c:m)
{
os << ' ' << std::setw(3) << c[iRow];
}
os << "]\n";
}
return os;
}
int main(int, char**)
{
int array[][4] =
{
{1, 2, 3, 4},
{4, 3, 2, 1}
};
std::cout << Chusov::Math::Matrix<int>(array);
return 0;
}
mathematical and arithmetical functions mostly over integer operands.
A class template for matrices of elements of various types and semantics, including types which do no...
Definition: chsvmath.h:6374
size_type Rows() const
Returns a number of rows in the current matrix.