CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
ex01g_dense_vector_block_operations.cpp
#include <iostream>
#include <cla3p/dense.hpp>
int main()
{
for(cla3p::uint_t i = 0; i < 5; i++)
x(i) = i;
std::cout << "x:\n" << x << "\n";
/*
* Get a copy of x[1:3) in xb.
* Get a reference of x[2:5) in xr.
*/
std::cout << "xb:\n" << xb;
std::cout << "xr:\n" << xr;
/*
* Get a guarded reference of xref[2:5) in xg.
*/
const cla3p::dns::RdVector& xref = x;
std::cout << "xg:\n" << xg.get() << "\n";
/*
* Change values in blocks.
*/
xr =-1;
std::cout << "x:\n" << x;
/*
* Set values of xb to x, starting at index 1.
*/
xb = -2;
x.setBlock(1, xb);
std::cout << "x:\n" << x;
/*
* Set values of xb to x, starting at index 2.
*/
xb = -3;
x.rblock(2, 2) = xb;
std::cout << "x:\n" << x;
return 0;
}
Immutable object wrapper.
Definition guard.hpp:37
const T_Object & get() const
Retrieves the guarded object.
Definition guard.hpp:96
XxVector< T_Scalar > block(int_t ibgn, int_t ni) const
Extract a block as a new vector.
XxVector< T_Scalar > rblock(int_t ibgn, int_t ni)
Extract a reference block.
void setBlock(int_t ibgn, const XxVector< T_Scalar > &src)
Set a block of elements.
XxVector< real_t > RdVector
Double precision real vector.
Definition dense.hpp:31