CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
ex02i_dense_matrix_block_operations.cpp
#include <iostream>
#include <cla3p/dense.hpp>
int main()
{
for(cla3p::uint_t j = 0, icnt = 0; j < 5; j++)
for(cla3p::uint_t i = 0; i < 5; i++)
A(i,j) = icnt++;
std::cout << "A:\n" << A << "\n";
/*
* Get a (2x2) copy of the contents of A starting at (1,2).
* Get a (3x2) reference of the contents of A starting at (2,0).
*/
cla3p::dns::RdMatrix Ab = A.block(1, 2, 2, 2);
cla3p::dns::RdMatrix Ar = A.rblock(2, 0, 3, 2);
std::cout << "Ab:\n" << Ab;
std::cout << "Ar:\n" << Ar;
/*
* Get a (3x2) guarded reference of the contents of Aref starting at (2,0).
*/
const cla3p::dns::RdMatrix& Aref = A;
std::cout << "Ag:\n" << Ag.get() << "\n";
/*
* Change values in blocks.
*/
Ar = -1;
std::cout << "A:\n" << A;
/*
* Set values of Ab to A, starting at (1,1).
*/
Ab = -2;
A.setBlock(1, 1, Ab);
std::cout << "A:\n" << A;
/*
* Set values of Ab to A, starting at (2,3).
*/
Ab = -3;
A.rblock(2, 3, 2, 2) = Ab;
std::cout << "A:\n" << A;
return 0;
}
Immutable object wrapper.
Definition guard.hpp:37
const T_Object & get() const
Retrieves the guarded object.
Definition guard.hpp:96
XxMatrix< T_Scalar > block(int_t ibgn, int_t jbgn, int_t ni, int_t nj) const
Extract a block as a new matrix.
void setBlock(int_t ibgn, int_t jbgn, const XxMatrix< T_Scalar > &src)
Set a block of elements.
XxMatrix< T_Scalar > rblock(int_t ibgn, int_t jbgn, int_t ni, int_t nj)
Extract a reference block.
XxMatrix< real_t > RdMatrix
Double precision real matrix.
Definition dense.hpp:55