isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | List of all members
isce3::core::Matrix< class > Class Template Reference

Data structure for a 2D row-major matrix. More...

#include <Matrix.h>

Public Types

using rep_t = std::array< size_t, 2 >
 
using index_t = pyre::grid::index_t< rep_t >
 
using layout_t = pyre::grid::layout_t< index_t >
 
using grid_t = pyre::grid::grid_t< cell_t, layout_t, pyre::memory::view_t< cell_t >>
 
using view_t = typename grid_t::view_type
 
using shape_t = typename layout_t::shape_type
 
using slice_t = typename layout_t::slice_type
 
using packing_t = typename layout_t::packing_type
 

Public Member Functions

 Matrix ()
 Default constructor.
 
 Matrix (size_t nrows, size_t ncols)
 Constructor with number of rows and number of columns. More...
 
 Matrix (const Matrix< cell_t > &m)
 Deep copy constructor from another matrix - allocates memory and copies values. More...
 
 Matrix (Matrix< cell_t > &m)
 Shallow copy constructor from another matrix - does not allocate own memory. More...
 
 Matrix (const view_t &view)
 Copy constructor from a grid view (copy values) More...
 
 Matrix (cell_t *data, size_t nrows, size_t ncols)
 Shallow copy constructor from raw pointer to data - does not allocate own memory. More...
 
 Matrix (std::valarray< cell_t > &data, size_t ncols)
 Shallow copy constructor from an std::valarray - does not allocate own memory. More...
 
 Matrix (std::vector< cell_t > &data, size_t ncols)
 Shallow copy constructor from an std::vector - does not allocate own memory. More...
 
 ~Matrix ()
 Destructor.
 
Matrix< cell_t > & operator= (const Matrix< cell_t > &m)
 Deep assignment operator - allocates memory and copies values. More...
 
Matrix< cell_t > & operator= (Matrix< cell_t > &m)
 Shallow assignment operator - does not allocate own memory. More...
 
Matrix< cell_t > & operator= (const view_t &view)
 Assignment operator from a grid view (copy values) More...
 
void resize (size_t nrows, size_t ncols)
 Resize memory for a given number of rows and columns. More...
 
const view_t submat (size_t row, size_t col, size_t rowspan, size_t colspan)
 Extract copy of sub-matrix given starting indices and span. More...
 
cell_t * data ()
 Access to data buffer.
 
const cell_t * data () const
 Read-only access to data buffer.
 
cell_t * rowptr (size_t row)
 Access to data buffer at a specific row. More...
 
const cell_t * rowptr (size_t row) const
 Read-only access to data buffer at a specific row. More...
 
cell_t & operator() (size_t row, size_t col)
 Access matrix value for a given row and column. More...
 
const cell_t & operator() (size_t row, size_t col) const
 Read-only access to matrix value for a given row and column. More...
 
cell_t & operator() (size_t index)
 Access matrix value for a flattened index. More...
 
const cell_t & operator() (size_t index) const
 Read-only access to matrix value for a flattened index. More...
 
cell_t & operator[] (const index_t &index)
 Access matrix value for a given grid::index_type. More...
 
const cell_t & operator[] (const index_t &index) const
 Read-only access to matrix value for a given grid::idnex_type. More...
 
void zeros ()
 Fill with zeros.
 
void fill (cell_t value)
 Fill with a constant value.
 
shape_t shape () const
 Get shape information as grid::shape_type.
 
size_t width () const
 Get matrix width.
 
size_t length () const
 Get matrix length.
 
shape_t byteoffset () const
 Get byteoffset for row and column for reading flat binary buffer. More...
 
auto map () const
 

Detailed Description

template<class>
class isce3::core::Matrix< class >

Data structure for a 2D row-major matrix.

Constructor & Destructor Documentation

template<typename cell_t >
isce3::core::Matrix< cell_t >::Matrix ( size_t  nrows,
size_t  ncols 
)
inline

Constructor with number of rows and number of columns.

Parameters
[in]nrowsNumber of rows
[in]ncolsNumber of columns
template<typename cell_t >
isce3::core::Matrix< cell_t >::Matrix ( const Matrix< cell_t > &  m)
inline

Deep copy constructor from another matrix - allocates memory and copies values.

Parameters
[in]misce3::core::Matrix object to copy
template<typename cell_t >
isce3::core::Matrix< cell_t >::Matrix ( Matrix< cell_t > &  m)
inline

Shallow copy constructor from another matrix - does not allocate own memory.

Parameters
[in]misce3::core::Matrix object to copy
template<typename cell_t >
isce3::core::Matrix< cell_t >::Matrix ( const view_t &  view)
inline

Copy constructor from a grid view (copy values)

Parameters
[in]viewpyre::grid_t::view_type to copy from
template<typename cell_t >
isce3::core::Matrix< cell_t >::Matrix ( cell_t *  data,
size_t  nrows,
size_t  ncols 
)
inline

Shallow copy constructor from raw pointer to data - does not allocate own memory.

Parameters
[in]dataValarray containing data
[in]ncolsNumber of columns for data (assume row major packing)
template<typename cell_t >
isce3::core::Matrix< cell_t >::Matrix ( std::valarray< cell_t > &  data,
size_t  ncols 
)
inline

Shallow copy constructor from an std::valarray - does not allocate own memory.

Parameters
[in]dataValarray containing data
[in]ncolsNumber of columns for data (assume row major packing)
template<typename cell_t >
isce3::core::Matrix< cell_t >::Matrix ( std::vector< cell_t > &  data,
size_t  ncols 
)
inline

Shallow copy constructor from an std::vector - does not allocate own memory.

Parameters
[in]dataVector containing data
[in]ncolsNumber of columns for data (assume row major packing)

Member Function Documentation

template<typename cell_t >
isce3::core::Matrix< cell_t >::shape_t isce3::core::Matrix< cell_t >::byteoffset ( ) const
inline

Get byteoffset for row and column for reading flat binary buffer.

Get matrix byte offset for row and column for raw binary buffer.

template<typename cell_t >
cell_t & isce3::core::Matrix< cell_t >::operator() ( size_t  row,
size_t  col 
)
inline

Access matrix value for a given row and column.

Parameters
[in]rowRow coordinate to access
[in]colColumn coordinate to access
template<typename cell_t >
const cell_t & isce3::core::Matrix< cell_t >::operator() ( size_t  row,
size_t  col 
) const
inline

Read-only access to matrix value for a given row and column.

Parameters
[in]rowRow coordinate to access
[in]colColumn coordinate to access
template<typename cell_t >
cell_t & isce3::core::Matrix< cell_t >::operator() ( size_t  index)
inline

Access matrix value for a flattened index.

Parameters
[in]indexFlattened index to access
template<typename cell_t >
const cell_t & isce3::core::Matrix< cell_t >::operator() ( size_t  index) const
inline

Read-only access to matrix value for a flattened index.

Parameters
[in]indexFlattened index to access
template<typename cell_t >
isce3::core::Matrix< cell_t > & isce3::core::Matrix< cell_t >::operator= ( const Matrix< cell_t > &  m)
inline

Deep assignment operator - allocates memory and copies values.

Parameters
[in]misce3::core::Matrix object to copy
template<typename cell_t >
isce3::core::Matrix< cell_t > & isce3::core::Matrix< cell_t >::operator= ( Matrix< cell_t > &  m)
inline

Shallow assignment operator - does not allocate own memory.

Parameters
[in]misce3::core::Matrix object to copy
template<typename cell_t >
isce3::core::Matrix< cell_t > & isce3::core::Matrix< cell_t >::operator= ( const view_t &  view)
inline

Assignment operator from a grid view (copy values)

Parameters
[in]viewpyre::grid_t::view_type to copy from
template<typename cell_t >
cell_t & isce3::core::Matrix< cell_t >::operator[] ( const index_t &  index)
inline

Access matrix value for a given grid::index_type.

Parameters
[in]indexpyre::grid_t::index_type for coordinate
template<typename cell_t >
const cell_t & isce3::core::Matrix< cell_t >::operator[] ( const index_t &  index) const
inline

Read-only access to matrix value for a given grid::idnex_type.

Parameters
[in]indexpyre::grid_t::index_type for coordinate
template<typename cell_t >
void isce3::core::Matrix< cell_t >::resize ( size_t  nrows,
size_t  ncols 
)
inline

Resize memory for a given number of rows and columns.

Parameters
[in]nrowsNumber of rows
[in]ncolsNumber of columns
template<typename cell_t >
cell_t * isce3::core::Matrix< cell_t >::rowptr ( size_t  row)
inline

Access to data buffer at a specific row.

Access to data buffer at specific row.

template<typename cell_t >
const cell_t * isce3::core::Matrix< cell_t >::rowptr ( size_t  row) const
inline

Read-only access to data buffer at a specific row.

Read-only access to data buffer at specific row.

template<typename cell_t >
const isce3::core::Matrix< cell_t >::view_t isce3::core::Matrix< cell_t >::submat ( size_t  row,
size_t  col,
size_t  rowspan,
size_t  colspan 
)
inline

Extract copy of sub-matrix given starting indices and span.

Parameters
[in]rowStarting row of submatrix
[in]colStarting column of submatrix
[in]rowspanNumber of rows of submatrix
[in]colspanNumber of columns of submatrix

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

Generated for ISCE3.0 by doxygen 1.8.5.