Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Morpheus::DenseMatrix< ValueType, Properties > Class Template Reference

The DenseMatrix container is a two-dimensional dense container that contains contiguous elements. It is a polymorphic container in the sense that it can store scalar or integer type values, on host or device depending how the template parameters are selected. More...

#include <Morpheus_DenseMatrix.hpp>

Inheritance diagram for Morpheus::DenseMatrix< ValueType, Properties >:
Inheritance graph
[legend]
Collaboration diagram for Morpheus::DenseMatrix< ValueType, Properties >:
Collaboration graph
[legend]

Public Types

using traits = ContainerTraits< DenseMatrix, ValueType, Properties... >
 
using type = typename traits::type
 
using base = MatrixBase< DenseMatrix, ValueType, Properties... >
 
using tag = typename MatrixFormatTag< Morpheus::DenseMatrixFormatTag >::tag
 
using value_type = typename traits::value_type
 
using non_const_value_type = typename traits::non_const_value_type
 
using size_type = typename traits::size_type
 
using index_type = typename traits::index_type
 
using non_const_index_type = typename traits::non_const_index_type
 
using array_layout = typename traits::array_layout
 
using backend = typename traits::backend
 
using memory_space = typename traits::memory_space
 
using execution_space = typename traits::execution_space
 
using device_type = typename traits::device_type
 
using memory_traits = typename traits::memory_traits
 
using HostMirror = typename traits::HostMirror
 
using pointer = typename traits::pointer
 
using const_pointer = typename traits::const_pointer
 
using reference = typename traits::reference
 
using const_reference = typename traits::const_reference
 
using value_array_type = Kokkos::View< value_type **, array_layout, execution_space, memory_traits >
 
using value_array_pointer = typename value_array_type::pointer_type
 
using value_array_reference = typename value_array_type::reference_type
 
- Public Types inherited from Morpheus::MatrixBase< DenseMatrix, ValueType, Properties... >
using type = MatrixBase< DenseMatrix, ValueType, Properties... >
 The traits associated with the particular container.
 
using traits = ContainerTraits< DenseMatrix, ValueType, Properties... >
 The type of the indices held by the container.
 
using size_type = typename traits::size_type
 
- Public Types inherited from Morpheus::ContainerTraits< Container, ValueType, Properties >
enum  { is_hostspace = std::is_same<MemorySpace, Kokkos::HostSpace>::value }
 
enum  { is_managed = MemoryTraits::is_unmanaged == 0 }
 
using value_type = ValueType
 The type of values held by the container.
 
using const_value_type = typename std::add_const< ValueType >::type
 The const type of values held by the container.
 
using non_const_value_type = typename std::remove_const< ValueType >::type
 The non-const type of values held by the container.
 
using index_type = IndexType
 The type of indices held by the container.
 
using size_type = size_t
 The size type of the container.
 
using non_const_index_type = typename std::remove_const< IndexType >::type
 The non-const type of indices held by the container.
 
using array_layout = ArrayLayout
 The storage layout of data held by the container.
 
using backend = Backend
 The backend out of which algorithms will be dispatched from.
 
using execution_space = ExecutionSpace
 The space in which member functions will be executed in.
 
using memory_space = MemorySpace
 The space in which data will be stored in.
 
using device_type = Morpheus::Device< execution_space, memory_space, backend >
 A device aware of the execution, memory spaces and backend.
 
using memory_traits = MemoryTraits
 Represents the user's intended access behaviour.
 
using host_mirror_backend = typename Morpheus::HostMirror< backend >::backend
 The host equivalent backend.
 
using type = Container< value_type, index_type, array_layout, backend, memory_traits >
 The complete type of the container.
 
using HostMirror = Container< non_const_value_type, non_const_index_type, array_layout, Morpheus::Device< typename host_mirror_backend::execution_space, typename host_mirror_backend::memory_space, typename host_mirror_backend::backend >, typename Kokkos::MemoryManaged >
 The host mirror equivalent for the container. More...
 
using pointer = typename std::add_pointer< type >::type
 The pointer type of the container.
 
using const_pointer = typename std::add_pointer< typename std::add_const< type >::type >::type
 The const pointer type of the container.
 
using reference = typename std::add_lvalue_reference< type >::type
 The reference type of the container.
 
using const_reference = typename std::add_lvalue_reference< typename std::add_const< type >::type >::type
 The const reference type of the container.
 

Public Member Functions

 ~DenseMatrix ()=default
 Default destructor.
 
 DenseMatrix (const DenseMatrix &)=default
 The default copy contructor (shallow copy) of a DenseMatrix container from another DenseMatrix container with the same properties.
 
 DenseMatrix (DenseMatrix &&)=default
 The default move contructor (shallow copy) of a DenseMatrix container from another DenseMatrix container with the same properties.
 
DenseMatrixoperator= (const DenseMatrix &)=default
 The default copy assignment (shallow copy) of a DenseMatrix container from another DenseMatrix container with the same properties.
 
DenseMatrixoperator= (DenseMatrix &&)=default
 The default move assignment (shallow copy) of a DenseMatrix container from another DenseMatrix container with the same properties.
 
 DenseMatrix ()
 Construct an empty DenseVector object.
 
 DenseMatrix (const size_type num_rows, const size_type num_cols, const value_type val=0)
 Construct a DenseMatrix object with shape (num_rows, num_cols) and values set to val. More...
 
template<typename ValuePtr >
 DenseMatrix (const size_type num_rows, const size_type num_cols, ValuePtr ptr, typename std::enable_if< std::is_pointer< ValuePtr >::value &&is_same_value_type< value_type, ValuePtr >::value &&memory_traits::is_unmanaged >::type *=nullptr)
 Construct a DenseMatrix object from a raw pointer. This is only enabled if the DenseMatrix is an unmanaged container. More...
 
template<class VR , class... PR>
 DenseMatrix (const DenseMatrix< VR, PR... > &src, typename std::enable_if< is_format_compatible< DenseMatrix, DenseMatrix< VR, PR... > >::value >::type *=nullptr)
 Shallow Copy contrustor from another DenseMatrix container with different properties. Note that this is only possible when the is_compatible check is satisfied. More...
 
template<class VR , class... PR>
std::enable_if< is_format_compatible< DenseMatrix, DenseMatrix< VR, PR... > >::value, DenseMatrix & >::type operator= (const DenseMatrix< VR, PR... > &src)
 Shallow Copy Assignment from another DenseMatrix container with different properties. Note that this is only possible when the is_compatible check is satisfied. More...
 
template<class MatrixType >
 DenseMatrix (const MatrixType &src)=delete
 Construct a DenserMatrix object from another storage format. This functionality is disabled to avoid implicit copies and conversion operations. More...
 
template<class MatrixType >
reference operator= (const MatrixType &src)=delete
 Assign to DenseMatrix object from another storage format. This functionality is disabled to avoid implicit copies and conversion operations. More...
 
void assign (size_type num_rows, size_type num_cols, const value_type val)
 Assigns (num_rows * num_cols) elements of value val to the DenseMatrix. The container will always resize to match the new shape. More...
 
void resize (size_type num_rows, size_type num_cols)
 Resizes DenseMatrix with shape (num_rows * num_cols). Overlapping subextents will preserve their contents. More...
 
template<class VR , class... PR>
void resize (const DenseMatrix< VR, PR... > &src)
 Resizes DenseVector with the shape another DenseMatrix with different parameters. More...
 
template<class VR , class... PR>
DenseMatrixallocate (const DenseMatrix< VR, PR... > &src)
 Allocates memory from another DenseMatrix container with different properties. More...
 
MORPHEUS_FORCEINLINE_FUNCTION value_array_reference operator() (size_type i, size_type j) const
 Returns a reference to the element with index (i,j) More...
 
value_array_pointer data () const
 Returns a pointer to the data at the beginning of the container. More...
 
value_array_typeview ()
 Returns a reference to the beginning of the view that holds the data. More...
 
const value_array_typeconst_view () const
 Returns a constant reference to the beginning of the view that holds the data. More...
 
- Public Member Functions inherited from Morpheus::MatrixBase< DenseMatrix, ValueType, Properties... >
 MatrixBase ()
 Default constructor. More...
 
 MatrixBase (size_type rows, size_type cols, size_type entries=0)
 Construct a MatrixBase object with shape (num_rows, num_cols) and number of non-zeros equal to num_entries. More...
 
void resize (size_type rows, size_type cols, size_type entries)
 Resizes MatrixBase with shape of (num_rows, num_cols) and sets number of non-zero entries to num_entries. More...
 
size_type nrows () const
 Number of rows of the matrix. More...
 
size_type ncols () const
 Number of columns of the matrix. More...
 
size_type nnnz () const
 Number of non-zeros of the matrix. More...
 
void set_nrows (const size_type rows)
 Set the number of rows of the matrix. More...
 
void set_ncols (const size_type cols)
 Set the number of columns of the matrix. More...
 
void set_nnnz (const size_type nnz)
 Set the number of non-zeros of the matrix. More...
 
MatrixStructure structure () const
 The specialized structure of the matrix e.g Symmetric. More...
 
MatrixOptions options () const
 Information about specific characteristics of the matrix e.g has short rows. More...
 
void set_structure (MatrixStructure op)
 Set the structure of the matrix. More...
 
void set_options (MatrixOptions op)
 Set the characteristics of the matrix. More...
 

Detailed Description

template<class ValueType, class... Properties>
class Morpheus::DenseMatrix< ValueType, Properties >

The DenseMatrix container is a two-dimensional dense container that contains contiguous elements. It is a polymorphic container in the sense that it can store scalar or integer type values, on host or device depending how the template parameters are selected.

Template Parameters
ValueTypetype of values to store
Propertiesoptional properties to modify the behaviour of the container. Sensible defaults are selected based on the configuration. Please refer to impl/Morpheus_ContainerTraits.hpp to find out more about the valid properties.
Overview
TODO
Example
#include <Morpheus_Core.hpp>
int main(){
// Construct a vector on host, of size 10 and with values set to 5.0
// Set some values
A(2,4) = 5.0;
A(5,4) = -2.0;
}
The DenseMatrix container is a two-dimensional dense container that contains contiguous elements....
Definition: Morpheus_DenseMatrix.hpp:74

Member Typedef Documentation

◆ index_type

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::index_type = typename traits::index_type

The type of the indices held by the container - can be const

◆ non_const_index_type

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::non_const_index_type = typename traits::non_const_index_type

The non-constant type of the indices held by the container

◆ non_const_value_type

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::non_const_value_type = typename traits::non_const_value_type

The non-constant type of the values held by the container

◆ tag

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::tag = typename MatrixFormatTag<Morpheus::DenseMatrixFormatTag>::tag

The tag associated specificaly to the particular container

◆ traits

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::traits = ContainerTraits<DenseMatrix, ValueType, Properties...>

The traits associated with the particular container

◆ type

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::type = typename traits::type

The complete type of the container

◆ value_array_type

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::value_array_type = Kokkos::View<value_type **, array_layout, execution_space, memory_traits>

The type of view that holds the value_type data

◆ value_type

template<class ValueType , class... Properties>
using Morpheus::DenseMatrix< ValueType, Properties >::value_type = typename traits::value_type

The type of the values held by the container - can be const

Constructor & Destructor Documentation

◆ DenseMatrix() [1/4]

template<class ValueType , class... Properties>
Morpheus::DenseMatrix< ValueType, Properties >::DenseMatrix ( const size_type  num_rows,
const size_type  num_cols,
const value_type  val = 0 
)
inline

Construct a DenseMatrix object with shape (num_rows, num_cols) and values set to val.

Parameters
num_rowsNumber of rows
num_colsNumber of columns
valValue at which the elements of the DenseMatrix will be set to

◆ DenseMatrix() [2/4]

template<class ValueType , class... Properties>
template<typename ValuePtr >
Morpheus::DenseMatrix< ValueType, Properties >::DenseMatrix ( const size_type  num_rows,
const size_type  num_cols,
ValuePtr  ptr,
typename std::enable_if< std::is_pointer< ValuePtr >::value &&is_same_value_type< value_type, ValuePtr >::value &&memory_traits::is_unmanaged >::type = nullptr 
)
inlineexplicit

Construct a DenseMatrix object from a raw pointer. This is only enabled if the DenseMatrix is an unmanaged container.

Template Parameters
ValuePtrPointer type
Parameters
num_rowsNumber of rows
num_colsNumber of columns
ptrPointer value

◆ DenseMatrix() [3/4]

template<class ValueType , class... Properties>
template<class VR , class... PR>
Morpheus::DenseMatrix< ValueType, Properties >::DenseMatrix ( const DenseMatrix< VR, PR... > &  src,
typename std::enable_if< is_format_compatible< DenseMatrix< ValueType, Properties >, DenseMatrix< VR, PR... > >::value >::type = nullptr 
)
inline

Shallow Copy contrustor from another DenseMatrix container with different properties. Note that this is only possible when the is_compatible check is satisfied.

Template Parameters
VRValue Type of the container we are constructing from.
PROptional properties of the container we are constructing from.
Parameters
srcThe DenseMatrix container we are constructing from.

◆ DenseMatrix() [4/4]

template<class ValueType , class... Properties>
template<class MatrixType >
Morpheus::DenseMatrix< ValueType, Properties >::DenseMatrix ( const MatrixType &  src)
delete

Construct a DenserMatrix object from another storage format. This functionality is disabled to avoid implicit copies and conversion operations.

Template Parameters
MatrixTypeAny of the supported storage formats.
Parameters
srcThe source container.

Member Function Documentation

◆ allocate()

template<class ValueType , class... Properties>
template<class VR , class... PR>
DenseMatrix & Morpheus::DenseMatrix< ValueType, Properties >::allocate ( const DenseMatrix< VR, PR... > &  src)
inline

Allocates memory from another DenseMatrix container with different properties.

Template Parameters
VRValue Type of the container we are allocating from.
PROptional properties of the container we are allocating from.
Parameters
srcThe DenseMatrix container we are allocating from.

◆ assign()

template<class ValueType , class... Properties>
void Morpheus::DenseMatrix< ValueType, Properties >::assign ( size_type  num_rows,
size_type  num_cols,
const value_type  val 
)
inline

Assigns (num_rows * num_cols) elements of value val to the DenseMatrix. The container will always resize to match the new shape.

Parameters
num_rowsNumber of rows
num_colsNumber of columns
valValue to assign

◆ const_view()

template<class ValueType , class... Properties>
const value_array_type & Morpheus::DenseMatrix< ValueType, Properties >::const_view ( ) const
inline

Returns a constant reference to the beginning of the view that holds the data.

Returns
Constant type of view that holds the data

◆ data()

template<class ValueType , class... Properties>
value_array_pointer Morpheus::DenseMatrix< ValueType, Properties >::data ( ) const
inline

Returns a pointer to the data at the beginning of the container.

Returns
Pointer type of the value_type data

◆ operator()()

template<class ValueType , class... Properties>
MORPHEUS_FORCEINLINE_FUNCTION value_array_reference Morpheus::DenseMatrix< ValueType, Properties >::operator() ( size_type  i,
size_type  j 
) const
inline

Returns a reference to the element with index (i,j)

Parameters
iFirst index of the value to extract
jSecond index of the value to extract
Returns
Element at index (i,j)

◆ operator=() [1/2]

template<class ValueType , class... Properties>
template<class VR , class... PR>
std::enable_if< is_format_compatible< DenseMatrix, DenseMatrix< VR, PR... > >::value, DenseMatrix & >::type Morpheus::DenseMatrix< ValueType, Properties >::operator= ( const DenseMatrix< VR, PR... > &  src)
inline

Shallow Copy Assignment from another DenseMatrix container with different properties. Note that this is only possible when the is_compatible check is satisfied.

Template Parameters
VRValue Type of the container we are copying from.
PROptional properties of the container we are copying from.
Parameters
srcThe DenseMatrix container we are copying from.

◆ operator=() [2/2]

template<class ValueType , class... Properties>
template<class MatrixType >
reference Morpheus::DenseMatrix< ValueType, Properties >::operator= ( const MatrixType &  src)
delete

Assign to DenseMatrix object from another storage format. This functionality is disabled to avoid implicit copies and conversion operations.

Template Parameters
MatrixTypeAny of the supported storage formats.
Parameters
srcThe source container.

◆ resize() [1/2]

template<class ValueType , class... Properties>
template<class VR , class... PR>
void Morpheus::DenseMatrix< ValueType, Properties >::resize ( const DenseMatrix< VR, PR... > &  src)
inline

Resizes DenseVector with the shape another DenseMatrix with different parameters.

Template Parameters
VRType of values the source matrix stores.
PROther properties of source matrix.
Parameters
srcThe source DenseMatrix we are resizing from.

◆ resize() [2/2]

template<class ValueType , class... Properties>
void Morpheus::DenseMatrix< ValueType, Properties >::resize ( size_type  num_rows,
size_type  num_cols 
)
inline

Resizes DenseMatrix with shape (num_rows * num_cols). Overlapping subextents will preserve their contents.

Parameters
num_rowsNumber of new rows
num_colsNumber of new columns

◆ view()

template<class ValueType , class... Properties>
value_array_type & Morpheus::DenseMatrix< ValueType, Properties >::view ( )
inline

Returns a reference to the beginning of the view that holds the data.

Returns
Type of view that holds the data

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