Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
q3::Matrix< T > Class Template Reference

#include <matrix.hpp>

Public Member Functions

 Matrix ()
 
 Matrix (size_t rows, size_t cols, const T &initial_value=T())
 
void assign (size_t rows, size_t cols, const T &initial_value)
 
size_t cols () const
 
T * data ()
 Returns the underlying flat data pointer.
 
const T * data () const
 
bool empty () const
 
T & operator() (size_t row_index, size_t column_index)
 2D indexing operator
 
const T & operator() (size_t row_index, size_t column_index) const
 
T * operator[] (size_t row_index)
 Access row row_index. Allows matrix[row_index][column_index] syntax to remain valid.
 
const T * operator[] (size_t row_index) const
 
std::vector< T > & raw ()
 Returns raw vector (useful for MPI calls that need contiguous block)
 
const std::vector< T > & raw () const
 
void resize (size_t rows, size_t cols)
 Resizes the matrix, invalidating previous content structure if dimensions change.
 
void resize (size_t rows, size_t cols, const T &initial_value)
 
size_t rows () const
 
size_t size () const
 Returns the number of rows (to mimic outer std::vector::size())
 

Detailed Description

template<typename T>
class q3::Matrix< T >

A simple, contiguous 2D array class to replace std::vector<std::vector<T>>. This prevents memory fragmentation and improves cache locality in HPC contexts.

Definition at line 13 of file matrix.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

template<typename T >
q3::Matrix< T >::Matrix ( )
inline

Definition at line 20 of file matrix.hpp.

◆ Matrix() [2/2]

template<typename T >
q3::Matrix< T >::Matrix ( size_t  rows,
size_t  cols,
const T &  initial_value = T() 
)
inline

Definition at line 22 of file matrix.hpp.

Member Function Documentation

◆ assign()

template<typename T >
void q3::Matrix< T >::assign ( size_t  rows,
size_t  cols,
const T &  initial_value 
)
inline

◆ cols()

◆ data() [1/2]

◆ data() [2/2]

template<typename T >
const T * q3::Matrix< T >::data ( ) const
inline

Definition at line 78 of file matrix.hpp.

◆ empty()

template<typename T >
bool q3::Matrix< T >::empty ( ) const
inline

◆ operator()() [1/2]

template<typename T >
T & q3::Matrix< T >::operator() ( size_t  row_index,
size_t  column_index 
)
inline

2D indexing operator

Definition at line 54 of file matrix.hpp.

◆ operator()() [2/2]

template<typename T >
const T & q3::Matrix< T >::operator() ( size_t  row_index,
size_t  column_index 
) const
inline

Definition at line 58 of file matrix.hpp.

◆ operator[]() [1/2]

template<typename T >
T * q3::Matrix< T >::operator[] ( size_t  row_index)
inline

Access row row_index. Allows matrix[row_index][column_index] syntax to remain valid.

Definition at line 45 of file matrix.hpp.

◆ operator[]() [2/2]

template<typename T >
const T * q3::Matrix< T >::operator[] ( size_t  row_index) const
inline

Definition at line 49 of file matrix.hpp.

◆ raw() [1/2]

template<typename T >
std::vector< T > & q3::Matrix< T >::raw ( )
inline

◆ raw() [2/2]

template<typename T >
const std::vector< T > & q3::Matrix< T >::raw ( ) const
inline

Definition at line 86 of file matrix.hpp.

◆ resize() [1/2]

template<typename T >
void q3::Matrix< T >::resize ( size_t  rows,
size_t  cols 
)
inline

Resizes the matrix, invalidating previous content structure if dimensions change.

Definition at line 26 of file matrix.hpp.

Referenced by q3::compute_kleinman_bylander_projectors().

◆ resize() [2/2]

template<typename T >
void q3::Matrix< T >::resize ( size_t  rows,
size_t  cols,
const T &  initial_value 
)
inline

Definition at line 32 of file matrix.hpp.

◆ rows()

◆ size()

template<typename T >
size_t q3::Matrix< T >::size ( ) const
inline

Returns the number of rows (to mimic outer std::vector::size())

Definition at line 70 of file matrix.hpp.


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