cuLite v0.3.1
A lite CUDA C++ Interface
Loading...
Searching...
No Matches
culite::dns::XxMatrix< T_Scalar > Class Template Reference

The device dense matrix class. More...

Inheritance diagram for culite::dns::XxMatrix< T_Scalar >:

Constructors

 XxMatrix ()
 Default constructor.
 XxMatrix (int_t nr, int_t nc, const Property &pr=Property::General())
 Dimension constructor.
 XxMatrix (int_t nr, int_t nc, T_Scalar *vals, int_t ldv, bool bind, const Property &pr=Property::General())
 Auxiliary constructor.
 XxMatrix (const XxMatrix< T_Scalar > &other)
 Copy constructor.
 XxMatrix (XxMatrix< T_Scalar > &&other)
 Move constructor.
 ~XxMatrix ()
 Destructor.

Operators

XxMatrix< T_Scalar > & operator= (const XxMatrix< T_Scalar > &other)
 Copy assignment operator.
XxMatrix< T_Scalar > & operator= (XxMatrix< T_Scalar > &&other)
 Move assignment operator.
void operator= (T_Scalar val)
 Fill operator.
alias::VirtualScal_dns< T_Scalar > operator- () const
 Unary negation operator.

Arguments

int_t ld () const
 Get the leading dimension.

Public Member Functions

void clear ()
 Clear the device matrix.
void fill (T_Scalar val)
 Fill all elements with a value.
XxMatrix< T_Scalar > copy () const
 Create a deep copy of the device matrix.
XxMatrix< T_Scalar > rcopy ()
 Create a reference copy (shallow copy) of the device matrix.
Guard< XxMatrix< T_Scalar > > rcopy () const
 Create a guarded reference copy (shallow copy) of the device matrix.
XxMatrix< T_Scalar > move ()
 Move the device matrix's resources.
std::string info (const std::string &header="") const
 Get information about the device matrix.
void iscale (T_Scalar val)
 Scale the device matrix in-place.
alias::VirtualTrans_dns< T_Scalar > transpose () const
 Transpose the device matrix.
alias::VirtualTrans_dns< T_Scalar > ctranspose () const
 Conjugate transpose the device matrix.
alias::VirtualConj_dns< T_Scalar > conjugate () const
 Compute the complex conjugate.
void iconjugate ()
 Conjugate the device matrix in-place.
T_RScalar normOne () const
 Compute the 1-norm.
T_RScalar normInf () const
 Compute the infinity norm.
T_RScalar normMax () const
 Compute the maximum norm.
T_RScalar normFro () const
 Compute the Frobenius norm.
XxMatrix< T_Scalar > block (int_t ibgn, int_t jbgn, int_t ni, int_t nj) const
 Extract a block as a new device matrix.
XxMatrix< T_Scalar > rblock (int_t ibgn, int_t jbgn, int_t ni, int_t nj)
 Extract a reference block.
Guard< XxMatrix< T_Scalar > > rblock (int_t ibgn, int_t jbgn, int_t ni, int_t nj) const
 Extract a guarded reference block.
void setBlock (int_t ibgn, int_t jbgn, const XxMatrix< T_Scalar > &src)
 Set a block of elements.
XxVector< T_Scalar > column (int_t j) const
 Extract a column as a new device vector.
XxVector< T_Scalar > rcolumn (int_t j)
 Extract a column as a reference.
Guard< XxVector< T_Scalar > > rcolumn (int_t j) const
 Extract a column as a guarded reference.
XxMatrix< T_Scalar > row (int_t i) const
 Extract a row as a new device matrix.
XxMatrix< T_Scalar > rrow (int_t i)
 Extract a row as a reference.
Guard< XxMatrix< T_Scalar > > rrow (int_t i) const
 Extract a row as a guarded reference.
VirtualRowvec< T_Scalar > rrowvec (int_t i) const
 Extract a row as a virtual row vector.
void copyToHost (::cla3p::dns::XxMatrix< T_Cla3pScalar > &dest) const
 Copies the device matrix to a host matrix.
void copyFromHost (const ::cla3p::dns::XxMatrix< T_Cla3pScalar > &src)
 Copies a host matrix to the device matrix.

Creators/Generators

static Guard< XxMatrix< T_Scalar > > view (int_t nr, int_t nc, const T_Scalar *vals, int_t ldv, const Property &pr=Property::General())
 Create a view of existing device memory.

Detailed Description

template<typename T_Scalar>
class culite::dns::XxMatrix< T_Scalar >

The device dense matrix class.

Represents a dense matrix stored on the GPU device.

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

Constructor & Destructor Documentation

◆ XxMatrix() [1/5]

template<typename T_Scalar>
culite::dns::XxMatrix< T_Scalar >::XxMatrix ( )

Default constructor.

Creates an empty device matrix with no allocated device memory.

◆ XxMatrix() [2/5]

template<typename T_Scalar>
culite::dns::XxMatrix< T_Scalar >::XxMatrix ( int_t nr,
int_t nc,
const Property & pr = Property::General() )
explicit

Dimension constructor.

Creates a device matrix of the specified dimensions and allocates device memory.

Parameters
[in]nrThe number of rows.
[in]ncThe number of columns.
[in]prThe matrix property (default: General).

◆ XxMatrix() [3/5]

template<typename T_Scalar>
culite::dns::XxMatrix< T_Scalar >::XxMatrix ( int_t nr,
int_t nc,
T_Scalar * vals,
int_t ldv,
bool bind,
const Property & pr = Property::General() )
explicit

Auxiliary constructor.

Creates a device matrix using existing device memory.

Parameters
[in]nrThe number of rows.
[in]ncThe number of columns.
[in]valsPointer to existing device memory.
[in]ldvThe leading dimension.
[in]bindIf true, the matrix takes ownership of the memory.
[in]prThe matrix property (default: General).

◆ XxMatrix() [4/5]

template<typename T_Scalar>
culite::dns::XxMatrix< T_Scalar >::XxMatrix ( const XxMatrix< T_Scalar > & other)

Copy constructor.

Creates a new device matrix by copying another device matrix.

Parameters
[in]otherThe device matrix to copy.

◆ XxMatrix() [5/5]

template<typename T_Scalar>
culite::dns::XxMatrix< T_Scalar >::XxMatrix ( XxMatrix< T_Scalar > && other)

Move constructor.

Creates a new device matrix by moving resources from another device matrix.

Parameters
[in]otherThe device matrix to move from.

◆ ~XxMatrix()

template<typename T_Scalar>
culite::dns::XxMatrix< T_Scalar >::~XxMatrix ( )

Destructor.

Destroys the device matrix and releases allocated device memory.

Member Function Documentation

◆ operator=() [1/3]

template<typename T_Scalar>
XxMatrix< T_Scalar > & culite::dns::XxMatrix< T_Scalar >::operator= ( const XxMatrix< T_Scalar > & other)

Copy assignment operator.

Copies the contents of another device matrix to this device matrix.

Parameters
[in]otherThe device matrix to copy.
Returns
Reference to this device matrix.

◆ operator=() [2/3]

template<typename T_Scalar>
XxMatrix< T_Scalar > & culite::dns::XxMatrix< T_Scalar >::operator= ( XxMatrix< T_Scalar > && other)

Move assignment operator.

Moves resources from another device matrix to this device matrix.

Parameters
[in]otherThe device matrix to move from.
Returns
Reference to this device matrix.

◆ operator=() [3/3]

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::operator= ( T_Scalar val)

Fill operator.

Fills all elements with the specified value.

Parameters
[in]valThe scalar value to fill with.

◆ operator-()

template<typename T_Scalar>
alias::VirtualScal_dns< T_Scalar > culite::dns::XxMatrix< T_Scalar >::operator- ( ) const

Unary negation operator.

Returns a negated copy of the device matrix.

Returns
A device matrix containing the negated elements.

◆ ld()

template<typename T_Scalar>
int_t culite::dns::XxMatrix< T_Scalar >::ld ( ) const

Get the leading dimension.

Returns the leading dimension of the device matrix (distance between consecutive columns).

Returns
The leading dimension.

◆ clear()

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::clear ( )

Clear the device matrix.

Releases all device memory and resets the matrix to an empty state.

◆ fill()

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::fill ( T_Scalar val)

Fill all elements with a value.

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

Parameters
[in]valThe scalar value to fill with.

◆ copy()

template<typename T_Scalar>
XxMatrix< T_Scalar > culite::dns::XxMatrix< T_Scalar >::copy ( ) const

Create a deep copy of the device matrix.

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

Returns
A new device matrix containing a copy of this matrix's data.

◆ rcopy() [1/2]

template<typename T_Scalar>
XxMatrix< T_Scalar > culite::dns::XxMatrix< T_Scalar >::rcopy ( )

Create a reference copy (shallow copy) of the device matrix.

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

Returns
A device matrix that shares device memory with this matrix.

◆ rcopy() [2/2]

template<typename T_Scalar>
Guard< XxMatrix< T_Scalar > > culite::dns::XxMatrix< T_Scalar >::rcopy ( ) const

Create a guarded reference copy (shallow copy) of the device matrix.

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

Returns
A guarded device matrix that shares device memory with this matrix.

◆ move()

template<typename T_Scalar>
XxMatrix< T_Scalar > culite::dns::XxMatrix< T_Scalar >::move ( )

Move the device matrix's resources.

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

Returns
A new device matrix containing this matrix's device memory.

◆ info()

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

Get information about the device matrix.

Returns a string containing information about the matrix's dimensions and properties.

Parameters
[in]headerOptional header string to prepend to the information.
Returns
A string containing matrix information.

◆ iscale()

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::iscale ( T_Scalar val)

Scale the device matrix in-place.

Multiplies all elements of the device matrix by a scalar value.

Parameters
[in]valThe scalar value to multiply by.

◆ transpose()

template<typename T_Scalar>
alias::VirtualTrans_dns< T_Scalar > culite::dns::XxMatrix< T_Scalar >::transpose ( ) const

Transpose the device matrix.

Returns a transposed copy of the device matrix.

Returns
A device matrix containing the transposed elements.

◆ ctranspose()

template<typename T_Scalar>
alias::VirtualTrans_dns< T_Scalar > culite::dns::XxMatrix< T_Scalar >::ctranspose ( ) const

Conjugate transpose the device matrix.

Returns a conjugate transposed copy of the device matrix.

Returns
A device matrix containing the conjugate transposed elements.

◆ conjugate()

template<typename T_Scalar>
alias::VirtualConj_dns< T_Scalar > culite::dns::XxMatrix< T_Scalar >::conjugate ( ) const

Compute the complex conjugate.

Returns a device matrix containing the complex conjugate of each element.

Returns
A device matrix with conjugated elements.

◆ iconjugate()

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::iconjugate ( )

Conjugate the device matrix in-place.

Replaces all elements with their complex conjugates.

◆ normOne()

template<typename T_Scalar>
T_RScalar culite::dns::XxMatrix< T_Scalar >::normOne ( ) const

Compute the 1-norm.

Computes the maximum absolute column sum.

Returns
The 1-norm of the device matrix.

◆ normInf()

template<typename T_Scalar>
T_RScalar culite::dns::XxMatrix< T_Scalar >::normInf ( ) const

Compute the infinity norm.

Computes the maximum absolute row sum.

Returns
The infinity norm of the device matrix.

◆ normMax()

template<typename T_Scalar>
T_RScalar culite::dns::XxMatrix< T_Scalar >::normMax ( ) const

Compute the maximum norm.

Computes the maximum absolute value of all elements.

Returns
The maximum norm of the device matrix.

◆ normFro()

template<typename T_Scalar>
T_RScalar culite::dns::XxMatrix< T_Scalar >::normFro ( ) const

Compute the Frobenius norm.

Computes the square root of the sum of squared absolute values of all elements.

Returns
The Frobenius norm of the device matrix.

◆ block()

template<typename T_Scalar>
XxMatrix< T_Scalar > culite::dns::XxMatrix< T_Scalar >::block ( int_t ibgn,
int_t jbgn,
int_t ni,
int_t nj ) const

Extract a block as a new device matrix.

Creates a new device matrix containing a deep copy of a contiguous block of elements.

Parameters
[in]ibgnThe starting row index of the block.
[in]jbgnThe starting column index of the block.
[in]niThe number of rows in the block.
[in]njThe number of columns in the block.
Returns
A new device matrix containing the block's data.

◆ rblock() [1/2]

template<typename T_Scalar>
XxMatrix< T_Scalar > culite::dns::XxMatrix< T_Scalar >::rblock ( int_t ibgn,
int_t jbgn,
int_t ni,
int_t nj )

Extract a reference block.

Creates a device matrix that references a contiguous block of this matrix's device memory.

Parameters
[in]ibgnThe starting row index of the block.
[in]jbgnThe starting column index of the block.
[in]niThe number of rows in the block.
[in]njThe number of columns in the block.
Returns
A device matrix that shares device memory with this matrix.

◆ rblock() [2/2]

template<typename T_Scalar>
Guard< XxMatrix< T_Scalar > > culite::dns::XxMatrix< T_Scalar >::rblock ( int_t ibgn,
int_t jbgn,
int_t ni,
int_t nj ) const

Extract a guarded reference block.

Creates a guarded device matrix that references a contiguous block of this matrix's device memory.

Parameters
[in]ibgnThe starting row index of the block.
[in]jbgnThe starting column index of the block.
[in]niThe number of rows in the block.
[in]njThe number of columns in the block.
Returns
A guarded device matrix that shares device memory with this matrix.

◆ setBlock()

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::setBlock ( int_t ibgn,
int_t jbgn,
const XxMatrix< T_Scalar > & src )

Set a block of elements.

Copies elements from the source device matrix to a contiguous block of this matrix.

Parameters
[in]ibgnThe starting row index where the block will be written.
[in]jbgnThe starting column index where the block will be written.
[in]srcThe source device matrix to copy from.

◆ column()

template<typename T_Scalar>
XxVector< T_Scalar > culite::dns::XxMatrix< T_Scalar >::column ( int_t j) const

Extract a column as a new device vector.

Creates a new device vector containing a deep copy of a column.

Parameters
[in]jThe column index.
Returns
A new device vector containing the column's data.

◆ rcolumn() [1/2]

template<typename T_Scalar>
XxVector< T_Scalar > culite::dns::XxMatrix< T_Scalar >::rcolumn ( int_t j)

Extract a column as a reference.

Creates a device vector that references a column of this matrix's device memory.

Parameters
[in]jThe column index.
Returns
A device vector that shares device memory with this matrix.

◆ rcolumn() [2/2]

template<typename T_Scalar>
Guard< XxVector< T_Scalar > > culite::dns::XxMatrix< T_Scalar >::rcolumn ( int_t j) const

Extract a column as a guarded reference.

Creates a guarded device vector that references a column of this matrix's device memory.

Parameters
[in]jThe column index.
Returns
A guarded device vector that shares device memory with this matrix.

◆ row()

template<typename T_Scalar>
XxMatrix< T_Scalar > culite::dns::XxMatrix< T_Scalar >::row ( int_t i) const

Extract a row as a new device matrix.

Creates a new device matrix containing a deep copy of a row.

Parameters
[in]iThe row index.
Returns
A new device matrix containing the row's data.

◆ rrow() [1/2]

template<typename T_Scalar>
XxMatrix< T_Scalar > culite::dns::XxMatrix< T_Scalar >::rrow ( int_t i)

Extract a row as a reference.

Creates a device matrix that references a row of this matrix's device memory.

Parameters
[in]iThe row index.
Returns
A device matrix that shares device memory with this matrix.

◆ rrow() [2/2]

template<typename T_Scalar>
Guard< XxMatrix< T_Scalar > > culite::dns::XxMatrix< T_Scalar >::rrow ( int_t i) const

Extract a row as a guarded reference.

Creates a guarded device matrix that references a row of this matrix's device memory.

Parameters
[in]iThe row index.
Returns
A guarded device matrix that shares device memory with this matrix.

◆ rrowvec()

template<typename T_Scalar>
VirtualRowvec< T_Scalar > culite::dns::XxMatrix< T_Scalar >::rrowvec ( int_t i) const

Extract a row as a virtual row vector.

Creates a virtual row vector expression that references a row of this matrix's device memory.

Parameters
[in]iThe row index.
Returns
A virtual row vector expression.

◆ copyToHost()

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::copyToHost ( ::cla3p::dns::XxMatrix< T_Cla3pScalar > & dest) const

Copies the device matrix to a host matrix.

Performs a device-to-host copy operation. If dest is empty, it is resized to match the dimensions and properties of the device matrix. Otherwise, dest must be compatible with the device matrix.

Parameters
[out]destThe destination host matrix.

◆ copyFromHost()

template<typename T_Scalar>
void culite::dns::XxMatrix< T_Scalar >::copyFromHost ( const ::cla3p::dns::XxMatrix< T_Cla3pScalar > & src)

Copies a host matrix to the device matrix.

Performs a host-to-device copy operation. If the device matrix is empty, it is resized to match the dimensions and properties of src. Otherwise, the device matrix must be compatible with src.

Parameters
[in]srcThe source host matrix.

◆ view()

template<typename T_Scalar>
Guard< XxMatrix< T_Scalar > > culite::dns::XxMatrix< T_Scalar >::view ( int_t nr,
int_t nc,
const T_Scalar * vals,
int_t ldv,
const Property & pr = Property::General() )
static

Create a view of existing device memory.

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

Parameters
[in]nrThe number of rows.
[in]ncThe number of columns.
[in]valsPointer to the device memory.
[in]ldvThe leading dimension.
[in]prThe matrix property (default: General).
Returns
A guarded device matrix that views the specified device memory.