chsvlib
chsv helper source code

◆ make_fixed_augmentation_matrix()

FixedMatrix<aug1_t::value_type, sum_of_columns, rows, aug1_t::allocator_type> Chusov::Math::make_fixed_augmentation_matrix ( aug1_t &&  aug1,
aug_t_n &&...  aug_n 
)

Creates a FixedMatrix object as an augmentation of other fixed-sized matrices, columns, or ranges of iterators of thereof.

Template Parameters
aug1_tis a type of the mandatory first entity of the parameter list.
aug_t_n...is a pack of types defining other columns to be augmented to the created matrix.
Parameters
aug1is the first (left) column(s) of the matrix being created.
aug_nis an optional set of entities specifying additional columns to be augmented to the created matrix from the right.
Returns
Returns a resulting matrix. See below.

The function is built to be used with template deduction mechanisms and can be used to augment various types of fixed-size matrices into one matrix object, also of fixed size.

An actual type of the returned matrix and acceptable types of parameters are determined according to the rules given for the make_augmentation_matrix function with the following additional requirements:

  • All parameters must be based upon a FixedMatrix template with a size known at a compile time.
  • Although iterator ranges are accepted by the function, a size of a range cannot be determined at a compile time, therefore the function will only consider a size of the first element of the range to form a type of the resulting matrix. Hence, only ranges with one matrix, or complete ranges of columns of a matrix (i.e. from M.begin() to M.end() for a fixed matrix M) will be processed successfully. If this constraint is not met, the construction routing will generate Chusov::Exceptions::InvalidParameterException.

To augment variable-size matrices use the make_augmentation_matrix function.

Example:

#include <iomanip>
#include <iostream>
using namespace Chusov::Math;
template <class value_t, class alloc_t, class derived_t>
std::ostream& operator<<(std::ostream& os, const Matrix<value_t, alloc_t, derived_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 argc, char** argv)
{
FixedMatrix<double, 3, 2> m1 =
{
{1, 2, 3},
{4, 5, 6}
};
FixedMatrix<double, 2, 2> m2 =
{
{7, 8},
{9, 10}
};
FixedMatrix<int, 2, 2> m3 =
{
{11, 12},
{13, 14}
};
auto aug1 = make_fixed_augmentation_matrix(m1, m2, m3, m3[0]);
std::cout << "aug1[" << decltype(aug1)::columns_number << "][" << decltype(aug1)::rows_number << "]\n" << aug1 << "\n";
auto aug2 = make_fixed_augmentation_matrix(m3, m2);
std::cout << "aug2[" << decltype(aug2)::columns_number << "][" << decltype(aug2)::rows_number << "]\n" << aug2 << "\n";
auto aug3 = make_fixed_augmentation_matrix(m1[0], m2);
std::cout << "aug3[" << decltype(aug3)::columns_number << "][" << decltype(aug3)::rows_number << "]\n" << aug3 << "\n";
return 0;
}
mathematical and arithmetical functions mostly over integer operands.
FixedMatrix< aug1_t::value_type, sum_of_columns, rows, aug1_t::allocator_type > make_fixed_augmentation_matrix(aug1_t &&aug1, aug_t_n &&...aug_n)
Creates a FixedMatrix object as an augmentation of other fixed-sized matrices, columns,...
Definition: chsvmath.h:9442
A namespace containing mathematical functions and components.
Definition: chsvmath.h:84

Output:

aug1[8][2]
[ 1 2 3 7 8 11 12 11]
[ 4 5 6 9 10 13 14 13]
aug2[4][2]
[ 11 12 7 8]
[ 13 14 9 10]
aug3[3][2]
[ 1 7 8]
[ 4 9 10]
See also
make_augmentation_matrix.
Exceptions
Chusov::Exceptions::InvalidParameterExceptionInvalid sizes of parameters.