IntaRNA 3.4.1
RNA-RNA interaction prediction | C++ API
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
IntaRNA::Matrix< T > Class Template Reference

#include <Matrix.h>

Public Types

using value_type = T
 Type of one stored cell.
 

Public Member Functions

 Matrix ()=default
 
 Matrix (std::size_t rows, std::size_t columns, const T &value=T{})
 
 Matrix (const Matrix &)=default
 
Matrix & operator= (const Matrix &)=default
 
 Matrix (Matrix &&other) noexcept
 
Matrix & operator= (Matrix &&other) noexcept
 
std::size_t size1 () const noexcept
 
std::size_t size2 () const noexcept
 
std::size_t storageSize () const noexcept
 
T & operator() (std::size_t i, std::size_t j)
 
const T & operator() (std::size_t i, std::size_t j) const
 
void clear ()
 
void swap (Matrix &other) noexcept
 
void resize (std::size_t newRows, std::size_t newColumns, bool preserve=true)
 

Detailed Description

template<class T>
class IntaRNA::Matrix< T >

Owning row-major matrix. Views are constructed on access, so copies, moves and resizes cannot leave a cached mdspan pointing into another allocation. resize preserves the overlapping rectangle unless preserve=false is passed. Preserving resize value-initializes new cells. With preserve=false, callers must overwrite all cells before reading. clear resets cells without changing shape.

Member Typedef Documentation

◆ value_type

template<class T >
using IntaRNA::Matrix< T >::value_type = T

Type of one stored cell.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

template<class T >
IntaRNA::Matrix< T >::Matrix ( )
default

Construct an empty matrix.

◆ Matrix() [2/4]

template<class T >
IntaRNA::Matrix< T >::Matrix ( std::size_t  rows,
std::size_t  columns,
const T &  value = T{} 
)
inline

Allocate a dense matrix initialized to one value.

Parameters
rowslogical row count
columnslogical column count
valueinitial value for each cell
Exceptions
std::length_errorif the storage size overflows

◆ Matrix() [3/4]

template<class T >
IntaRNA::Matrix< T >::Matrix ( const Matrix< T > &  )
default

Copy the shape and values into independent storage.

◆ Matrix() [4/4]

template<class T >
IntaRNA::Matrix< T >::Matrix ( Matrix< T > &&  other)
inlinenoexcept

Take ownership of another matrix and leave it empty.

Parameters
othermatrix whose storage is moved

Member Function Documentation

◆ clear()

template<class T >
void IntaRNA::Matrix< T >::clear ( )
inline

Reset stored cells to default values without changing the shape.

◆ operator()() [1/2]

template<class T >
T & IntaRNA::Matrix< T >::operator() ( std::size_t  i,
std::size_t  j 
)
inline

Access a cell within the logical shape.

Parameters
izero-based row within the logical shape
jzero-based column within the logical shape
Returns
mutable reference to the cell

◆ operator()() [2/2]

template<class T >
const T & IntaRNA::Matrix< T >::operator() ( std::size_t  i,
std::size_t  j 
) const
inline

Access a cell within the logical shape.

Parameters
izero-based row within the logical shape
jzero-based column within the logical shape
Returns
read-only reference to the cell

◆ operator=() [1/2]

template<class T >
Matrix & IntaRNA::Matrix< T >::operator= ( const Matrix< T > &  )
default

Copy the shape and values into independent storage.

Returns
this matrix

◆ operator=() [2/2]

template<class T >
Matrix< T > & IntaRNA::Matrix< T >::operator= ( Matrix< T > &&  other)
inlinenoexcept

Take ownership of another matrix; self-move leaves this matrix unchanged.

Parameters
othermatrix whose storage is moved; emptied on a non-self move
Returns
this matrix

◆ resize()

template<class T >
void IntaRNA::Matrix< T >::resize ( std::size_t  newRows,
std::size_t  newColumns,
bool  preserve = true 
)
inline

Resize, preserving overlapping logical cells when requested.

Parameters
newRowsnew row count
newColumnsnew column count
preserveretain overlapping cells and default-initialize new cells; otherwise callers must overwrite cells before reading
Exceptions
std::length_errorif the storage size overflows

◆ size1()

template<class T >
std::size_t IntaRNA::Matrix< T >::size1 ( ) const
inlinenoexcept

Number of logical rows.

Returns
logical row count

◆ size2()

template<class T >
std::size_t IntaRNA::Matrix< T >::size2 ( ) const
inlinenoexcept

Number of logical columns.

Returns
logical column count

◆ storageSize()

template<class T >
std::size_t IntaRNA::Matrix< T >::storageSize ( ) const
inlinenoexcept

Number of stored elements, including any band padding.

Returns
stored element count

◆ swap()

template<class T >
void IntaRNA::Matrix< T >::swap ( Matrix< T > &  other)
inlinenoexcept

Exchange shape and owned storage.

Parameters
othermatrix to exchange with

The documentation for this class was generated from the following file: