geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
Public Member Functions | List of all members
geopm::TensorOneD Class Reference

Class to store and perform operations on 1D Tensors, aka vectors, suitable for use in feed-forward neural networks. More...

#include <TensorOneD.hpp>

Public Member Functions

 TensorOneD ()
 
 TensorOneD (size_t n)
 Constructor with size specified. More...
 
 TensorOneD (const TensorOneD &other)
 Constructs a deep copy of the argument. More...
 
 TensorOneD (TensorOneD &&other)
 
 TensorOneD (const std::vector< double > &input)
 Constructor from vector of values. More...
 
 TensorOneD (const std::vector< double > &input, std::shared_ptr< TensorMath > math)
 Test constructor. More...
 
void set_dim (size_t dim)
 Set length of 1D tensor. More...
 
size_t get_dim () const
 Get the length of the 1D tensor. More...
 
TensorOneD operator+ (const TensorOneD &other) const
 
TensorOneD operator- (const TensorOneD &other) const
 
double operator* (const TensorOneD &other) const
 
TensorOneDoperator= (const TensorOneD &other)
 Overload = operator with an in-place deep copy. More...
 
TensorOneDoperator= (TensorOneD &&other)
 
bool operator== (const TensorOneD &other) const
 Overload == operator to do comparison of the underlying. More...
 
double & operator[] (size_t idx)
 Reference indexing of 1D tensor value at idx. More...
 
double operator[] (size_t idx) const
 Value access of 1D Tensor value at idx. More...
 
TensorOneD sigmoid () const
 
const std::vector< double > & get_data () const
 Return the tensor as a vector of doubles. More...
 
virtual ~TensorOneD ()=default
 

Detailed Description

Class to store and perform operations on 1D Tensors, aka vectors, suitable for use in feed-forward neural networks.

Constructor & Destructor Documentation

◆ TensorOneD() [1/6]

geopm::TensorOneD::TensorOneD ( )

◆ TensorOneD() [2/6]

geopm::TensorOneD::TensorOneD ( size_t  n)

Constructor with size specified.

Parameters
[in]nSize of 1D tensor

◆ TensorOneD() [3/6]

geopm::TensorOneD::TensorOneD ( const TensorOneD other)

Constructs a deep copy of the argument.

Parameters
[in]TensorOneDTensor to copy

◆ TensorOneD() [4/6]

geopm::TensorOneD::TensorOneD ( TensorOneD &&  other)

◆ TensorOneD() [5/6]

geopm::TensorOneD::TensorOneD ( const std::vector< double > &  input)

Constructor from vector of values.

Parameters
[in]inputThe values to store in the 1D tensor.
Exceptions
geopm::Exceptionif input is empty.

◆ TensorOneD() [6/6]

geopm::TensorOneD::TensorOneD ( const std::vector< double > &  input,
std::shared_ptr< TensorMath math 
)

Test constructor.

Parameters
[in]inputThe values to store in the 1D tensor.
[in]mathTensorMath instance
Exceptions
geopm::Exceptionif input is empty.

◆ ~TensorOneD()

virtual geopm::TensorOneD::~TensorOneD ( )
virtualdefault

Member Function Documentation

◆ get_data()

const std::vector< double > & geopm::TensorOneD::get_data ( ) const

Return the tensor as a vector of doubles.

Returns
Returns the contents of the tensor.

◆ get_dim()

size_t geopm::TensorOneD::get_dim ( ) const

Get the length of the 1D tensor.

Returns
Returns the length of the 1D tensor

◆ operator*()

double geopm::TensorOneD::operator* ( const TensorOneD other) const

◆ operator+()

TensorOneD geopm::TensorOneD::operator+ ( const TensorOneD other) const

◆ operator-()

TensorOneD geopm::TensorOneD::operator- ( const TensorOneD other) const

◆ operator=() [1/2]

TensorOneD & geopm::TensorOneD::operator= ( const TensorOneD other)

Overload = operator with an in-place deep copy.

Parameters
[in]otherThe assignee (tensor to be copied)

◆ operator=() [2/2]

TensorOneD & geopm::TensorOneD::operator= ( TensorOneD &&  other)

◆ operator==()

bool geopm::TensorOneD::operator== ( const TensorOneD other) const

Overload == operator to do comparison of the underlying.

Parameters
[in]otherThe tensor to compare against

◆ operator[]() [1/2]

double & geopm::TensorOneD::operator[] ( size_t  idx)

Reference indexing of 1D tensor value at idx.

Parameters
[in]idxThe index at which to look for the value
Returns
Returns a reference to the 1D tensor at idx

◆ operator[]() [2/2]

double geopm::TensorOneD::operator[] ( size_t  idx) const

Value access of 1D Tensor value at idx.

Parameters
[in]idxThe index at which to look for the value
Returns
Returns the value of the 1D tensor at idx

◆ set_dim()

void geopm::TensorOneD::set_dim ( size_t  dim)

Set length of 1D tensor.

If the instance has more than n elements, it will be truncated. If it has fewer than n elements, the tensor will be expanded to a total size of n, uninitialized.

Parameters
[in]nResulting size of 1D tensor

◆ sigmoid()

TensorOneD geopm::TensorOneD::sigmoid ( ) const

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