chsvlib
chsv helper source code

◆ Matrix() [4/16]

Matrix ( const Matrix< Val2, Alloc2, Derived2_t, Policy2 > &  r)

Constructs a copy of given matrix transformed from some other instantiation of the Matrix template.

Template Parameters
Val2is a type of elements of a given matrix which should be explicitly convertible to value_type.
Alloc2is a type of an allocator of a given matrix which is rebinded to an allocator instance for value_type and then explicitly converted to allocator_type.
Derived2_tis a type implementing the matrix specified as the argument.
Policy2is a policy of execution of methods of the matrix specified as the argument. Policy is not considered by the constructor.
Parameters
ris a given matrix instance of another type. It is converted to the current type with a result (of conversion) to be a constructed matrix.

Example code:

#include <iostream>
template <class alloc_t>
double AverageElement(const Chusov::Math::Matrix<double, alloc_t>& m)
{
double ave = 0.;
for (auto c:m)
for (auto r:c)
ave += r;
return ave / (m.Rows() * m.Columns());
}
int main(int argc, char argv)
{
{
{1, 2, 3},
{4, 5, 6}
};
std::cout << "An average value between matrix elements is " << AverageElement(Chusov::Math::Matrix<double>(m)) << std::endl;
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

Output is

An average value of matrix elements is 3.5.