![]() |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Strongly typed wrapper for MSparseArray.
| T | - any type supported by MSparseArray (mint, double or std::complex<double>) |
Inheritance diagram for LLU::SparseArray< T >:
Collaboration diagram for LLU::SparseArray< T >:#include <SparseArray.h>
Public Types | |
| using | value_type = T |
| using | Container = Argument::CType< Type > |
| The type of underlying LibraryLink structure (e.g. MTensor, MImage, etc.) will be called "Container". More... | |
Public Member Functions | |
| SparseArray ()=default | |
| Default constructor, creates a SparseArray that does not wrap over any raw MSparseArray. More... | |
| SparseArray (MSparseArray t, Ownership owner) | |
| Constructs SparseArray based on MSparseArray. More... | |
| SparseArray (GenericSparseArray t) | |
| Create new SparseArray from a GenericSparseArray. More... | |
| SparseArray (const Tensor< mint > &positions, const Tensor< T > &values, const Tensor< mint > &dimensions, T implicitValue) | |
| Create a new SparseArray from positions, values, dimensions and an implicit value. More... | |
| SparseArray (const Tensor< T > &data, T implicitValue) | |
| Create a new SparseArray from data array and an implicit value. More... | |
| SparseArray (const SparseArray &s, T implicitValue) | |
| Create a copy of given SparseArray with different implicit value. More... | |
| mint | rank () const |
| Get the rank (number of dimensions) of this sparse array. More... | |
| T | implicitValue () const |
| Get the implicit value of this sparse array. More... | |
| void | setImplicitValue (T newImplicitValue) |
| Change the implicit value of this array. More... | |
| Tensor< T > | explicitValues () const |
| Get a tensor with the values corresponding to the explicitly stored positions in the sparse array. More... | |
| Tensor< mint > | rowPointers () const |
| Get a row pointer array for this sparse array. More... | |
| Tensor< mint > | columnIndices () const |
| Get the column indices for the explicitly stored positions in this sparse array. More... | |
| Tensor< mint > | explicitPositions () const |
| Get the explicitly specified positions in this sparse array. More... | |
| Tensor< T > | toTensor () const |
| Expand this sparse array to a regular tensor. More... | |
| MContainer | clone () const |
| Clone this MContainer, performs a deep copy of the underlying MSparseArray. More... | |
| GenericTensor | getImplicitValueAsTensor () const |
| Get the implicit value of this sparse array. More... | |
| void | setImplicitValueFromTensor (const GenericTensor &implicitValue) |
| Change the implicit value of this array. More... | |
| mint | getRank () const |
| Get the rank (number of dimensions) of this sparse array. More... | |
| mint const * | getDimensions () const |
| Get dimensions of this sparse array. More... | |
| GenericTensor | getExplicitValues () const |
| Get a tensor with the values corresponding to the explicitly stored positions in the sparse array. More... | |
| GenericTensor | getRowPointers () const |
| Get a row pointer array for this sparse array. More... | |
| GenericTensor | getColumnIndices () const |
| Get the column indices for the explicitly stored positions in this sparse array. More... | |
| GenericTensor | getExplicitPositions () const |
| Get the explicitly specified positions in this sparse array. More... | |
| GenericTensor | toGenericTensor () const |
| Expand this sparse array to a regular tensor. More... | |
| void | resparsify () |
| Use current implicit value to recalculate the sparse array after the data has been modified. More... | |
| mint | type () const |
| Get the data type of this MSparseArray. More... | |
| Container | getContainer () const noexcept |
| Get internal container. More... | |
| Container | abandonContainer () const noexcept |
| Give a handle to internal container and stop owning it. More... | |
| mint | shareCount () const noexcept |
| Return share count of internal container, if present and 0 otherwise. More... | |
| void | pass (MArgument &res) const |
| Pass the internal container as result of a LibraryLink function. More... | |
| Ownership | getOwner () const noexcept |
| Get ownership information. More... | |
Protected Member Functions | |
| Container | cloneContainer () const |
| Clone the raw container, if it's present. More... | |
| void | disown () const noexcept |
| Disown internal container if present. More... | |
| void | free () const noexcept |
| Free internal container if present. More... | |
| void | reset (Container newCont, Ownership newOwnerMode=Ownership::Library) noexcept |
| Set a new internal container safely disposing of the old one. More... | |
|
inherited |
The type of underlying LibraryLink structure (e.g. MTensor, MImage, etc.) will be called "Container".
|
default |
Default constructor, creates a SparseArray that does not wrap over any raw MSparseArray.
| LLU::SparseArray< T >::SparseArray | ( | MSparseArray< T > | t, |
| Ownership | owner | ||
| ) |
Constructs SparseArray based on MSparseArray.
| [in] | t | - LibraryLink structure to be wrapped |
| [in] | owner | - who manages the memory the raw MSparseArray |
| ErrorName::SparseArrayTypeError | - if the SparseArray template type T does not match the actual data type of the MSparseArray |
|
explicit |
Create new SparseArray from a GenericSparseArray.
| [in] | t | - generic SparseArray to be wrapped into SparseArray class |
| ErrorName::SparseArrayTypeError | - if the SparseArray template type T does not match the actual data type of the generic SparseArray |
| LLU::SparseArray< T >::SparseArray | ( | const Tensor< mint > & | positions, |
| const Tensor< T > & | values, | ||
| const Tensor< mint > & | dimensions, | ||
| T | implicitValue | ||
| ) |
Create a new SparseArray from positions, values, dimensions and an implicit value.
| positions | - positions of all the explicit values in the array |
| values | - explicit values to be stored in the array |
| dimensions | - dimensions of the new SparseArray |
| implicitValue | - implicit value (the one that is not stored) of the new SparseArray |
| LLU::SparseArray< T >::SparseArray | ( | const Tensor< T > & | data, |
| T | implicitValue | ||
| ) |
Create a new SparseArray from data array and an implicit value.
| data | - a tensor whose contents will be copied and sparsified |
| implicitValue | - implicit value (the one that is not stored) of the new SparseArray |
| LLU::SparseArray< T >::SparseArray | ( | const SparseArray< T > & | s, |
| T | implicitValue | ||
| ) |
Create a copy of given SparseArray with different implicit value.
| s | - other SparseArray of type T |
| implicitValue | - implicit value (the one that is not stored) of the new SparseArray |
|
inlinenoexceptinherited |
Give a handle to internal container and stop owning it.
Should be used with caution as it may potentially result with resource leak.
|
inlineinherited |
Clone this MContainer, performs a deep copy of the underlying MSparseArray.
|
inlineprotectedinherited |
Clone the raw container, if it's present.
| Tensor< mint > LLU::SparseArray< T >::columnIndices |
|
inlineprotectednoexceptinherited |
Disown internal container if present.
| Tensor< mint > LLU::SparseArray< T >::explicitPositions |
| Tensor< T > LLU::SparseArray< T >::explicitValues |
Get a tensor with the values corresponding to the explicitly stored positions in the sparse array.
|
inlineprotectednoexceptinherited |
Free internal container if present.
|
inherited |
Get the column indices for the explicitly stored positions in this sparse array.
The first dimension of the resulting tensor is the number of explicit positions, and the second dimension is equal to getRank() - 1.
|
inlinenoexceptinherited |
Get internal container.
|
inlineinherited |
Get dimensions of this sparse array.
|
inherited |
Get the explicitly specified positions in this sparse array.
The first dimension of the resulting tensor is the number of explicit positions, and the second dimension is equal to getRank().
|
inherited |
Get a tensor with the values corresponding to the explicitly stored positions in the sparse array.
|
inherited |
Get the implicit value of this sparse array.
|
inlinenoexceptinherited |
Get ownership information.
|
inlineinherited |
Get the rank (number of dimensions) of this sparse array.
|
inherited |
Get a row pointer array for this sparse array.
The values returned are the cumulative number of explicitly represented elements for each row, so the values will be non-decreasing.
| T LLU::SparseArray< T >::implicitValue |
Get the implicit value of this sparse array.
|
inlineinherited |
Pass the internal container as result of a LibraryLink function.
| res | - MArgument which will hold internal container of this MContainerBase |
|
inline |
Get the rank (number of dimensions) of this sparse array.
|
inlineprotectednoexceptinherited |
Set a new internal container safely disposing of the old one.
| newCont | - new internal container |
| newOwnerMode | - owner of the new container |
|
inherited |
Use current implicit value to recalculate the sparse array after the data has been modified.
| Tensor< mint > LLU::SparseArray< T >::rowPointers |
Get a row pointer array for this sparse array.
The values returned are the cumulative number of explicitly represented elements for each row, so the values will be non-decreasing.
| void LLU::SparseArray< T >::setImplicitValue | ( | T | newImplicitValue | ) |
Change the implicit value of this array.
| newImplicitValue | - new implicit value |
|
inherited |
Change the implicit value of this array.
| implicitValue | - new implicit value |
|
inlinenoexceptinherited |
Return share count of internal container, if present and 0 otherwise.
|
inherited |
Expand this sparse array to a regular tensor.
| Tensor< T > LLU::SparseArray< T >::toTensor |
Expand this sparse array to a regular tensor.
|
inherited |
Get the data type of this MSparseArray.