ALP User Documentation 0.7.0
Algebraic Programming User Documentation
Classes | Public Types | Public Member Functions | List of all members
Matrix< D, implementation, RowIndexType, ColIndexType, NonzeroIndexType > Class Template Reference

An ALP/GraphBLAS matrix. More...

#include <matrix.hpp>

Classes

class  const_iterator
 A standard iterator for an ALP/GraphBLAS matrix. More...
 

Public Types

typedef Matrix< D, implementation, RowIndexType, ColIndexType, NonzeroIndexType > self_type
 The type of this container.
 
typedef D value_type
 The value type of elements stored in this matrix.
 

Public Member Functions

 Matrix (const Matrix< D, implementation, RowIndexType, ColIndexType, NonzeroIndexType > &other)
 Copy constructor. More...
 
 Matrix (const size_t rows, const size_t columns)
 ALP/GraphBLAS matrix constructor that sets a default initial capacity. More...
 
 Matrix (const size_t rows, const size_t columns, const size_t nz)
 ALP/GraphBLAS matrix constructor that sets an initial capacity. More...
 
 Matrix (self_type &&other)
 Move constructor. More...
 
 ~Matrix ()
 Matrix destructor. More...
 
const_iterator begin () const
 Same as cbegin(). More...
 
const_iterator cbegin () const
 Provides the only mechanism to extract data from a GraphBLAS matrix. More...
 
const_iterator cend () const
 Indicates the end to the elements in this container. More...
 
const_iterator end () const
 Same as cend(). More...
 
self_typeoperator= (self_type &&other) noexcept
 Move-assignment. More...
 

Detailed Description

template<typename D, enum Backend implementation, typename RowIndexType, typename ColIndexType, typename NonzeroIndexType>
class grb::Matrix< D, implementation, RowIndexType, ColIndexType, NonzeroIndexType >

An ALP/GraphBLAS matrix.

This is an opaque data type that implements the below constructors, member functions, and destructors.

Template Parameters
DThe type of a nonzero element.

The given type D shall not be an ALP/GraphBLAS object.

Template Parameters
implementationAllows multiple backends to implement different versions of this data type.
Warning
Creating a grb::Matrix of other ALP/GraphBLAS types is not allowed.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

Matrix ( const size_t  rows,
const size_t  columns,
const size_t  nz 
)
inline

ALP/GraphBLAS matrix constructor that sets an initial capacity.

Parameters
[in]rowsThe number of rows of the matrix to be instantiated.
[in]columnsThe number of columns of the matrix to be instantiated.
[in]nzThe minimum initial capacity of the matrix to be instantiated.

After successful construction, the resulting matrix has a capacity of at least nz nonzeroes. If either rows or columns is 0, then the capacity may instead be 0 as well.

On errors such as out-of-memory, this constructor may throw exceptions.

Performance semantics.
Each backend must define performance semantics for this primitive.
See also
Performance Semantics
Warning
Avoid the use of this constructor within performance critical code sections.

◆ Matrix() [2/4]

Matrix ( const size_t  rows,
const size_t  columns 
)
inline

ALP/GraphBLAS matrix constructor that sets a default initial capacity.

Parameters
[in]rowsThe number of rows in the new matrix.
[in]columnsThe number of columns in the new matrix.

The default capacity is the maximum of rows and columns.

On errors such as out-of-memory, this constructor may throw exceptions.

For the full specification, please see the full constructor signature.

Warning
Avoid the use of this constructor within performance critical code sections.

◆ Matrix() [3/4]

Matrix ( const Matrix< D, implementation, RowIndexType, ColIndexType, NonzeroIndexType > &  other)
inline

Copy constructor.

Parameters
[in]otherThe matrix to copy.

This performs a deep copy; a new matrix is allocated with the same (or larger) capacity as other, after which the contents of other are copied into the new instance.

The use of this constructor is semantically the same as:

grb::Matrix< T > newMatrix(
    grb::nrows( other ), grb::ncols( other ),
    grb::capacity( other )
);
grb::set( newMatrix, other );

(Under the condition that all calls are successful.)

Performance semantics.
Each backend must define performance semantics for this primitive.
See also
Performance Semantics
Warning
Avoid the use of this constructor within performance critical code sections.

◆ Matrix() [4/4]

Matrix ( self_type &&  other)
inline

Move constructor.

This will take over the resources of the given other matrix, invalidating the contents of other while its contents are now moved into this instance instead.

Parameters
[in]otherThe matrix to move to this new instance.
Performance semantics.
Each backend must define performance semantics for this primitive.
See also
Performance Semantics

◆ ~Matrix()

~Matrix ( )
inline

Matrix destructor.

Performance semantics.
Each backend must define performance semantics for this primitive.
See also
Performance Semantics
Warning
Avoid calling destructors from within performance critical code sections.

Member Function Documentation

◆ begin()

const_iterator begin ( ) const
inline

Same as cbegin().

Since iterators are only supplied as a data extraction mechanism, there is no overloaded version of this function that returns a non-const iterator.

◆ cbegin()

const_iterator cbegin ( ) const
inline

Provides the only mechanism to extract data from a GraphBLAS matrix.

The order in which nonzero elements are returned is undefined.

Returns
An iterator pointing to the first element of this matrix, if any; or an iterator in end position if this vector contains no nonzeroes.
Note
An ‘iterator in end position’ compares equal to the const_iterator returned by cend().
Performance semantics.
Each backend must define performance semantics for this primitive.
See also
Performance Semantics
Note
This function may make use of a const_iterator that is buffered, hence possibly causing its implicitly called constructor to allocate dynamic memory.
Warning
Avoid the use of this function within performance critical code sections.

◆ cend()

const_iterator cend ( ) const
inline

Indicates the end to the elements in this container.

Returns
An iterator at the end position of this container.
Performance semantics.
Each backend must define performance semantics for this primitive.
See also
Performance Semantics
Note
Even if cbegin() returns a buffered const_iterator that may require dynamic memory allocation and additional data movement, this specification disallows the same to happen for the construction of an iterator in end position.
Warning
Avoid the use of this function within performance critical code sections.

◆ end()

const_iterator end ( ) const
inline

Same as cend().

Since iterators are only supplied as a data extraction mechanism, there is no overloaded version of this function that returns a non-const iterator.

◆ operator=()

self_type & operator= ( self_type &&  other)
inlinenoexcept

Move-assignment.

This will take over the resources of the given other matrix, invalidating the contents of other while its contents are now moved into this instance instead.

This will destroy any current contents in this container.

Parameters
[in]otherThe matrix contents to move into this instance.
Performance semantics.
Each backend must define performance semantics for this primitive.
See also
Performance Semantics

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