CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
cla3p::dns::XiVector< T_Scalar > Class Template Reference

The general purpose dense vector class. More...

Inheritance diagram for cla3p::dns::XiVector< T_Scalar >:

Operators

T_Scalar & operator() (int_t i)
 Element access operator.
const T_Scalar & operator() (int_t i) const
 Element access operator.

Public Member Functions

void clear ()
 Clear the vector.
void fill (T_Scalar val)
 Fill all elements with a value.
XiVector< T_Scalar > copy () const
 Create a deep copy of the vector.
XiVector< T_Scalar > rcopy ()
 Create a reference copy (shallow copy) of the vector.
Guard< XiVector< T_Scalar > > rcopy () const
 Create a guarded reference copy (shallow copy) of the vector.
XiVector< T_Scalar > move ()
 Move the vector's resources.
std::string info (const std::string &header="") const
 Get information about the vector.
void print (std::streamsize prec=0) const
 Print the vector to standard output.
void toStream (std::ostream &os, std::streamsize prec=0) const
 Output the vector to a stream.

Creators/Generators

static Guard< XiVector< T_Scalar > > view (int_t n, const T_Scalar *vals)
 Create a view of existing memory.

Additional Inherited Members

Public Member Functions inherited from cla3p::Meta1D< int_t >
int_t size () const
 Vector size.
bool empty () const
 Tests whether the object has zero dimension.
 operator bool () const
 Boolean conversion operator.
Public Member Functions inherited from cla3p::dns::XxContainerBase< T_Scalar >
T_Scalar * values ()
 Access the data buffer.
const T_Scalar * values () const
 Access the data buffer.
Public Member Functions inherited from cla3p::Ownership
 Ownership ()
 Default constructor.
 Ownership (bool owner)
 Ownership constructor.
 ~Ownership ()
 Destructor.
bool owner () const
 Tests memory ownership.
void unbind ()
 Relinquishes memory ownership.

Detailed Description

template<typename T_Scalar>
class cla3p::dns::XiVector< T_Scalar >

The general purpose dense vector class.

Represents a dense vector stored in contiguous memory.

Template Parameters
T_ScalarThe scalar type (e.g., float, double, complex).

Member Function Documentation

◆ operator()() [1/2]

template<typename T_Scalar>
T_Scalar & cla3p::dns::XiVector< T_Scalar >::operator() ( int_t i)

Element access operator.

Accesses the element at the specified index.

Parameters
[in]iThe index of the element (0-based).
Returns
Reference to the element at index i.

◆ operator()() [2/2]

template<typename T_Scalar>
const T_Scalar & cla3p::dns::XiVector< T_Scalar >::operator() ( int_t i) const

Element access operator.

Accesses the element at the specified index.

Parameters
[in]iThe index of the element (0-based).
Returns
Const reference to the element at index i.

◆ clear()

template<typename T_Scalar>
void cla3p::dns::XiVector< T_Scalar >::clear ( )

Clear the vector.

Releases all memory and resets the vector to an empty state.

◆ fill()

template<typename T_Scalar>
void cla3p::dns::XiVector< T_Scalar >::fill ( T_Scalar val)

Fill all elements with a value.

Sets all elements in the vector to the specified scalar value.

Parameters
[in]valThe scalar value to fill with.
Examples
ex01b_dense_vector_fill.cpp, and ex03b_permutation_matrix_fill.cpp.

◆ copy()

template<typename T_Scalar>
XiVector< T_Scalar > cla3p::dns::XiVector< T_Scalar >::copy ( ) const

Create a deep copy of the vector.

Creates a new vector with its own memory allocation and copies all elements from this vector to the new vector.

Returns
A new vector containing a copy of this vector's data.
Examples
ex01e_dense_vector_copy.cpp.

◆ rcopy() [1/2]

template<typename T_Scalar>
XiVector< T_Scalar > cla3p::dns::XiVector< T_Scalar >::rcopy ( )

Create a reference copy (shallow copy) of the vector.

Creates a new vector object that references the same memory as this vector. Changes to either vector will affect both.

Returns
A vector that shares memory with this vector.
Examples
ex01h_dense_vector_shallow_copy.cpp, and ex04a_guard_const_vector.cpp.

◆ rcopy() [2/2]

template<typename T_Scalar>
Guard< XiVector< T_Scalar > > cla3p::dns::XiVector< T_Scalar >::rcopy ( ) const

Create a guarded reference copy (shallow copy) of the vector.

Creates a guarded vector object that references the same memory as this vector. The guard ensures the reference is read-only.

Returns
A guarded vector that shares memory with this vector.

◆ move()

template<typename T_Scalar>
XiVector< T_Scalar > cla3p::dns::XiVector< T_Scalar >::move ( )

Move the vector's resources.

Transfers ownership of the memory to a new vector object, leaving this vector in an empty state.

Returns
A new vector containing this vector's memory.
Examples
ex01f_dense_vector_move.cpp.

◆ info()

template<typename T_Scalar>
std::string cla3p::dns::XiVector< T_Scalar >::info ( const std::string & header = "") const

Get information about the vector.

Returns a string containing information about the vector's dimensions.

Parameters
[in]headerOptional header string to prepend to the information.
Returns
A string containing vector information.
Examples
ex01a_dense_vector_create.cpp, ex01c_dense_vector_create_from_aux_data.cpp, ex01e_dense_vector_copy.cpp, ex01f_dense_vector_move.cpp, ex01h_dense_vector_shallow_copy.cpp, ex03a_permutation_matrix_create.cpp, ex03c_permutation_matrix_create_identity.cpp, ex03d_permutation_matrix_create_random.cpp, and ex04a_guard_const_vector.cpp.

◆ print()

template<typename T_Scalar>
void cla3p::dns::XiVector< T_Scalar >::print ( std::streamsize prec = 0) const

Print the vector to standard output.

Prints the vector elements to standard output with specified precision.

Parameters
[in]precThe output precision (default: 0 for default precision).

◆ toStream()

template<typename T_Scalar>
void cla3p::dns::XiVector< T_Scalar >::toStream ( std::ostream & os,
std::streamsize prec = 0 ) const

Output the vector to a stream.

Writes the vector elements to the specified output stream with specified precision.

Parameters
[in,out]osThe output stream to write to.
[in]precThe output precision (default: 0 for default precision).

◆ view()

template<typename T_Scalar>
Guard< XiVector< T_Scalar > > cla3p::dns::XiVector< T_Scalar >::view ( int_t n,
const T_Scalar * vals )
static

Create a view of existing memory.

Creates a guarded vector that references existing memory without taking ownership. The memory must remain valid for the lifetime of the returned view.

Parameters
[in]nThe number of elements.
[in]valsPointer to the memory.
Returns
A guarded vector that views the specified memory.