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

#include <Matrix.h>

Public Types

using value_type = T
 Type of one stored cell.
 

Public Member Functions

 UpperTriangularMatrix ()=default
 
 UpperTriangularMatrix (std::size_t rows, std::size_t columns)
 
 UpperTriangularMatrix (const UpperTriangularMatrix &)=default
 
UpperTriangularMatrix & operator= (const UpperTriangularMatrix &)=default
 
 UpperTriangularMatrix (UpperTriangularMatrix &&other) noexcept
 
UpperTriangularMatrix & operator= (UpperTriangularMatrix &&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 (UpperTriangularMatrix &other) noexcept
 
void resize (std::size_t rows, std::size_t columns, bool preserve=true)
 

Detailed Description

template<class T>
class IntaRNA::UpperTriangularMatrix< T >

Square upper-triangular matrix with exactly n*(n+1)/2 stored cells. Rows are packed consecutively. A one-dimensional mdspan addresses the packed storage because triangular row lengths are not an affine 2D layout. Const access below the diagonal returns zero; writes require i <= j.

Member Typedef Documentation

◆ value_type

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

Type of one stored cell.

Constructor & Destructor Documentation

◆ UpperTriangularMatrix() [1/4]

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

Construct an empty matrix.

◆ UpperTriangularMatrix() [2/4]

template<class T >
IntaRNA::UpperTriangularMatrix< T >::UpperTriangularMatrix ( std::size_t  rows,
std::size_t  columns 
)
inline

Allocate a default-initialized square upper triangle.

Parameters
rowslogical row count
columnslogical column count; must equal rows
Exceptions
std::invalid_argumentif the shape is not square
std::length_errorif the storage size overflows

◆ UpperTriangularMatrix() [3/4]

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

Copy the shape and values into independent storage.

◆ UpperTriangularMatrix() [4/4]

template<class T >
IntaRNA::UpperTriangularMatrix< T >::UpperTriangularMatrix ( UpperTriangularMatrix< 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::UpperTriangularMatrix< T >::clear ( )
inline

Reset stored cells to default values without changing the shape.

◆ operator()() [1/2]

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

Access a cell with i <= j < size2().

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::UpperTriangularMatrix< T >::operator() ( std::size_t  i,
std::size_t  j 
) const
inline

Read a logical cell; structural zeros are returned outside stored cells.

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 >
UpperTriangularMatrix & IntaRNA::UpperTriangularMatrix< T >::operator= ( const UpperTriangularMatrix< T > &  )
default

Copy the shape and values into independent storage.

Returns
this matrix

◆ operator=() [2/2]

template<class T >
UpperTriangularMatrix< T > & IntaRNA::UpperTriangularMatrix< T >::operator= ( UpperTriangularMatrix< 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::UpperTriangularMatrix< T >::resize ( std::size_t  rows,
std::size_t  columns,
bool  preserve = true 
)
inline

Resize, preserving overlapping logical cells when requested.

Parameters
rowsnew row count
columnsnew column count; must equal rows
preserveretain overlapping cells and default-initialize new cells; otherwise callers must overwrite cells before reading
Exceptions
std::length_errorif the storage size overflows
std::invalid_argumentif the requested shape or band is unsupported

◆ size1()

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

Number of logical rows.

Returns
logical row count

◆ size2()

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

Number of logical columns.

Returns
logical column count

◆ storageSize()

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

Number of stored elements, including any band padding.

Returns
stored element count

◆ swap()

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

Exchange shape and owned storage.

Parameters
othermatrix to exchange with

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