chsvlib
chsv helper source code

◆ make_augmentation_matrix()

Matrix<common_value_type, common_allocator_type, void, common_policy_type> Chusov::Math::make_augmentation_matrix ( aug1_t &&  aug1,
aug_t_n &&...  aug_n 
)

Creates a Matrix object as an augmentation of other 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 matrices into one matrix object.

The following types of parameters are accepted:

Any combination of such parameters can be specified in the parameter list.

The resulting type of the returned matrix is defined according to the following rules.

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)
{
Matrix<double> m1 =
{
{1, 2, 3},
{4, 5, 6}
};
Matrix<double> m2 =
{
{7, 8},
{9, 10}
};
Matrix<int> m3 =
{
{11, 12},
{13, 14}
};
std::cout << make_augmentation_matrix(m1, m2, m3, m3[0]) << "\n";
std::cout << make_augmentation_matrix(m3, m2) << "\n";
std::cout << make_augmentation_matrix(m1[0], m2) << "\n";
return 0;
}
mathematical and arithmetical functions mostly over integer operands.
Matrix< common_value_type, common_allocator_type, void, common_policy_type > make_augmentation_matrix(aug1_t &&aug1, aug_t_n &&... aug_n)
Creates a Matrix object as an augmentation of other matrices, columns, or ranges of iterators of ther...
Definition: chsvmath.h:8351
A namespace containing mathematical functions and components.
Definition: chsvmath.h:84

Output:

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