LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::TensorView Class Reference

Description

Simple, light-weight, non-owning wrappper over MTensor.

Intended for use in functions that only need to access MTensor metadata, where it can alleviate the need for introducing template parameters for MTensor passing mode (like in GenericTensor) or data type (like in Tensor class).

+ Inheritance diagram for LLU::TensorView:
+ Collaboration diagram for LLU::TensorView:

#include <Tensor.hpp>

Public Member Functions

 TensorView (const GenericTensor &gTen)
 Create a NumericArrayView from a GenericNumericArray. More...
 
 TensorView (MTensor mt)
 Create a NumericArrayView from a raw MNumericArray. More...
 
mint getRank () const override
 Get rank. More...
 
mint const * getDimensions () const override
 Get dimensions. More...
 
mint getFlattenedLength () const override
 Get total length. More...
 
mint type () const final
 Get the data type of this tensor. More...
 
void * rawData () const override
 Get raw pointer to the data of this tensor. More...
 

Constructor & Destructor Documentation

◆ TensorView() [1/2]

LLU::TensorView::TensorView ( const GenericTensor gTen)
inline

Create a NumericArrayView from a GenericNumericArray.

Parameters
gTen- a GenericNumericArray

◆ TensorView() [2/2]

LLU::TensorView::TensorView ( MTensor  mt)
inline

Create a NumericArrayView from a raw MNumericArray.

Parameters
mt- a raw MNumericArray

Member Function Documentation

◆ getDimensions()

mint const* LLU::TensorView::getDimensions ( ) const
inlineoverridevirtual

Get dimensions.

Returns
raw pointer to dimensions of this tensor
See also
http://reference.wolfram.com/language/LibraryLink/ref/callback/MTensor_getDimensions.html

Implements LLU::TensorInterface.

◆ getFlattenedLength()

mint LLU::TensorView::getFlattenedLength ( ) const
inlineoverridevirtual

◆ getRank()

mint LLU::TensorView::getRank ( ) const
inlineoverridevirtual

Get rank.

Returns
number of dimensions in this tensor
See also
http://reference.wolfram.com/language/LibraryLink/ref/callback/MTensor_getRank.html

Implements LLU::TensorInterface.

◆ rawData()

void* LLU::TensorView::rawData ( ) const
inlineoverridevirtual

Get raw pointer to the data of this tensor.

Implements LLU::TensorInterface.

◆ type()

mint LLU::TensorView::type ( ) const
inlinefinalvirtual

Get the data type of this tensor.

Returns
type of elements (MType_Integer, MType_Real or MType_Complex)
See also
http://reference.wolfram.com/language/LibraryLink/ref/callback/MTensor_getType.html

Implements LLU::TensorInterface.