Rosetta  2019.07
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Attributes | List of all members
numeric::MathNTensor< T, N > Class Template Reference

#include <MathNTensor.hh>

Inheritance diagram for numeric::MathNTensor< T, N >:
Inheritance graph
[legend]

Public Types

typedef numeric::Size Size
 
typedef MathNTensorBase< Tparent
 
- Public Types inherited from numeric::MathNTensorBase< T >
typedef numeric::Size Size
 

Public Member Functions

 MathNTensor ()
 Default constructor – make a MathNTensor that's 0-dimensional with 0 elements. More...
 
 MathNTensor (utility::fixedsizearray1< Size, N > const &n_bins, T const &value=T())
 Constructor: make a MathNTensor from fixedsizearray of dims and single element. More...
 
 MathNTensor (utility::vector1< Size > const &n_bins, T const &value=T())
 Constructor: make a MathNTensor from vector of dims and single element. More...
 
 MathNTensor (MathNTensor const &src)
 Copy constructor. More...
 
MathNTensorBaseOP< Tclone () const override
 Implementation of pure virtual clone function from base class. More...
 
MathNTensor< T, N > & operator= (MathNTensor< T, N > const &rhs)
 Assignment operator. More...
 
 ~MathNTensor ()
 Destructor. More...
 
T sum () const
 
bool is_valid_position (utility::fixedsizearray1< Size, N > const &positions) const
 Is the position in the N-Tensor given by the positions vector a valid position? More...
 
bool is_valid_position (utility::vector1< Size > const &positions) const override
 Is the given coordinate a valid position in the tensor? More...
 
void set_value (utility::vector1< Size > const &position, T const &value_in) override
 Set a value in a tensor. More...
 
T const & value (utility::vector1< Size > const &position) const override
 Get a value from a tensor. More...
 
 MathNTensor (utility::fixedsizearray1< Size, N > const &n_bins, T const *data)
 Raw pointer constructor. Avoid this. More...
 
Size n_bins (Size const dimension) const override
 return number of bins for ith dimension More...
 
T min () const override
 Get the minimum value stored in this tensor. More...
 
T max () const override
 Get the maximum value stored in this tensor. More...
 
Size num_dimensions () const
 Return number of dimensions overall (i.e. the dimensionality of this MathNTensor). More...
 
void replace_layer (Size layer, MathNTensor< T, N-1 > const &matrix)
 Copies elements of argument matrix into this object at position ( layer ) More...
 
T const & data (Size const index) const
 
void replace_layer (Size const layer, MathMatrix< T > const &matrix)
 ONLY for 3-dimensional tensors, replace a layer with a 2D matrix. More...
 
MathMatrix< Tget_mathmatrix ()
 ONLY for 2-dimensional tensors, give me a MathMatrix that's identical to the tensor. (That is, convert the MathNTensor to MathMatrix form. More...
 
Toperator() (utility::fixedsizearray1< Size, N > const &position)
 Access a position in the N-dimensional tensor. More...
 
T const & operator() (utility::fixedsizearray1< Size, N > const &position) const
 Use an N-vector of coordinates to access a position in the N-dimensional tensor. More...
 
Toperator() (utility::vector1< Size > const &position)
 
T const & operator() (utility::vector1< Size > const &position) const
 
Toperator() (Size const b1, Size const b2)
 
Toperator() (Size const b1, Size const b2) const
 
Toperator() (Size const b1, Size const b2, Size const b3)
 
T const & operator() (Size const b1, Size const b2, Size const b3) const
 
Toperator() (Size const b1, Size const b2, Size const b3, Size const b4)
 
T const & operator() (Size const b1, Size const b2, Size const b3, Size const b4) const
 
T const & operator() (Size const b1, Size const b2, Size const b3, Size const b4, Size const b5) const
 
T const & operator() (Size const b1, Size const b2, Size const b3, Size const b4, Size const b5, Size const b6) const
 
void operator/= (Real const divisor)
 
Size size () const
 
utility::fixedsizearray1< Size,
N > const & 
n_bins () const
 
- Public Member Functions inherited from numeric::MathNTensorBase< T >
 MathNTensorBase ()
 Default constructor. More...
 
virtual ~MathNTensorBase ()
 Virtual destructor needed for polymorphism. More...
 
 MathNTensorBase (Size const dimensionality_in)
 Costructor with dimensionality value. More...
 
Size dimensionality () const
 Get the dimensionality of derived classes. More...
 

Private Attributes

utility::fixedsizearray1< Size, N > n_bins_
 
Size size_
 The total number of bins in the MathNTensor (the product of all dimensions). More...
 
Tdata_
 Array of data stored in this N-tensor. More...
 

Additional Inherited Members

- Protected Member Functions inherited from numeric::MathNTensorBase< T >
void set_dimensionality (Size const dimensionality_in)
 Lets the derived class set the dimensionality stored in the base class. More...
 

Member Typedef Documentation

template<class T, numeric::Size N>
typedef MathNTensorBase<T> numeric::MathNTensor< T, N >::parent
template<class T, numeric::Size N>
typedef numeric::Size numeric::MathNTensor< T, N >::Size

Constructor & Destructor Documentation

template<class T, numeric::Size N>
numeric::MathNTensor< T, N >::MathNTensor ( )
inline

Default constructor – make a MathNTensor that's 0-dimensional with 0 elements.

template<class T, numeric::Size N>
numeric::MathNTensor< T, N >::MathNTensor ( utility::fixedsizearray1< Size, N > const &  n_bins,
T const &  value = T() 
)
inline

Constructor: make a MathNTensor from fixedsizearray of dims and single element.

The single element gets copied to every entry in the MathNTensor, initializing it.

template<class T, numeric::Size N>
numeric::MathNTensor< T, N >::MathNTensor ( utility::vector1< Size > const &  n_bins,
T const &  value = T() 
)
inline

Constructor: make a MathNTensor from vector of dims and single element.

The single element gets copied to every entry in the MathNTensor, initializing it.

template<class T, numeric::Size N>
numeric::MathNTensor< T, N >::MathNTensor ( MathNTensor< T, N > const &  src)
inline

Copy constructor.

template<class T, numeric::Size N>
numeric::MathNTensor< T, N >::~MathNTensor ( )
inline

Destructor.

template<class T, numeric::Size N>
numeric::MathNTensor< T, N >::MathNTensor ( utility::fixedsizearray1< Size, N > const &  n_bins,
T const *  data 
)
inline

Raw pointer constructor. Avoid this.

Member Function Documentation

template<class T, numeric::Size N>
MathNTensorBaseOP< T > numeric::MathNTensor< T, N >::clone ( ) const
inlineoverridevirtual

Implementation of pure virtual clone function from base class.

Creates a copy of this object and returns an owning pointer to the copy. Must be implemented by derived classes.

Implements numeric::MathNTensorBase< T >.

template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::data ( Size const  index) const
inline
template<class T, numeric::Size N>
MathMatrix< T > numeric::MathNTensor< T, N >::get_mathmatrix ( )
inline

ONLY for 2-dimensional tensors, give me a MathMatrix that's identical to the tensor. (That is, convert the MathNTensor to MathMatrix form.

Throws if this is not a 2D tensor.

Returns
A MathMatrix containing the full contents of the MathNTensor.
Author
Vikram K. Mulligan (vmull.nosp@m.ig@u.nosp@m.w.edu).
template<class T, numeric::Size N>
bool numeric::MathNTensor< T, N >::is_valid_position ( utility::fixedsizearray1< Size, N > const &  positions) const
inline

Is the position in the N-Tensor given by the positions vector a valid position?

Returns true if each coordinate is in the range [1, dimension], false otherwise.

Referenced by numeric::interpolation::get_val(), numeric::MathNTensor< double, 2 >::operator()(), numeric::MathNTensor< double, 2 >::replace_layer(), numeric::MathNTensor< double, 2 >::set_value(), and numeric::MathNTensor< double, 2 >::value().

template<class T, numeric::Size N>
bool numeric::MathNTensor< T, N >::is_valid_position ( utility::vector1< Size > const &  position) const
inlineoverridevirtual

Is the given coordinate a valid position in the tensor?

Returns false if out of range. Pure virtual; must be implemented by derived classes.

Implements numeric::MathNTensorBase< T >.

template<class T, numeric::Size N>
T numeric::MathNTensor< T, N >::max ( ) const
inlineoverridevirtual

Get the maximum value stored in this tensor.

Implements pure virtual from base class.

Implements numeric::MathNTensorBase< T >.

template<class T, numeric::Size N>
T numeric::MathNTensor< T, N >::min ( ) const
inlineoverridevirtual

Get the minimum value stored in this tensor.

Implements pure virtual from base class.

Implements numeric::MathNTensorBase< T >.

template<class T, numeric::Size N>
Size numeric::MathNTensor< T, N >::n_bins ( Size const  dimension) const
inlineoverridevirtual
template<class T, numeric::Size N>
utility::fixedsizearray1< Size, N > const& numeric::MathNTensor< T, N >::n_bins ( ) const
inline
template<class T, numeric::Size N>
Size numeric::MathNTensor< T, N >::num_dimensions ( ) const
inline

Return number of dimensions overall (i.e. the dimensionality of this MathNTensor).

template<class T, numeric::Size N>
T& numeric::MathNTensor< T, N >::operator() ( utility::fixedsizearray1< Size, N > const &  position)
inline

Access a position in the N-dimensional tensor.

Accessors, both as const and nonconst reference and via fixedsizearray1, vector1, or sequences of values.

template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::operator() ( utility::fixedsizearray1< Size, N > const &  position) const
inline

Use an N-vector of coordinates to access a position in the N-dimensional tensor.

Const access (assignment prohibited).

template<class T, numeric::Size N>
T& numeric::MathNTensor< T, N >::operator() ( utility::vector1< Size > const &  position)
inline
template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::operator() ( utility::vector1< Size > const &  position) const
inline
template<class T, numeric::Size N>
T& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2 
)
inline
template<class T, numeric::Size N>
T& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2 
) const
inline
template<class T, numeric::Size N>
T& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2,
Size const  b3 
)
inline
template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2,
Size const  b3 
) const
inline
template<class T, numeric::Size N>
T& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2,
Size const  b3,
Size const  b4 
)
inline
template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2,
Size const  b3,
Size const  b4 
) const
inline
template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2,
Size const  b3,
Size const  b4,
Size const  b5 
) const
inline
template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::operator() ( Size const  b1,
Size const  b2,
Size const  b3,
Size const  b4,
Size const  b5,
Size const  b6 
) const
inline
template<class T, numeric::Size N>
void numeric::MathNTensor< T, N >::operator/= ( Real const  divisor)
inline
template<class T, numeric::Size N>
MathNTensor< T, N >& numeric::MathNTensor< T, N >::operator= ( MathNTensor< T, N > const &  rhs)
inline

Assignment operator.

template<class T, numeric::Size N>
void numeric::MathNTensor< T, N >::replace_layer ( Size  layer,
MathNTensor< T, N-1 > const &  matrix 
)
inline

Copies elements of argument matrix into this object at position ( layer )

layer is the FIRST index.

template<class T, numeric::Size N>
void numeric::MathNTensor< T, N >::replace_layer ( Size const  layer,
MathMatrix< T > const &  matrix 
)
inline

ONLY for 3-dimensional tensors, replace a layer with a 2D matrix.

template<class T, numeric::Size N>
void numeric::MathNTensor< T, N >::set_value ( utility::vector1< Size > const &  position,
T const &  value_in 
)
inlineoverridevirtual

Set a value in a tensor.

Note that bounds-checking only occurs in debug builds!

Note
Implements pure virtual function from base class.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org)

Implements numeric::MathNTensorBase< T >.

template<class T, numeric::Size N>
Size numeric::MathNTensor< T, N >::size ( ) const
inline
template<class T, numeric::Size N>
T numeric::MathNTensor< T, N >::sum ( ) const
inline
template<class T, numeric::Size N>
T const& numeric::MathNTensor< T, N >::value ( utility::vector1< Size > const &  position) const
inlineoverridevirtual

Get a value from a tensor.

Note that bounds-checking only occurs in debug builds!

Note
Implements pure virtual function from base class.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org)

Implements numeric::MathNTensorBase< T >.

Referenced by numeric::MathNTensor< double, 2 >::MathNTensor().

Member Data Documentation

template<class T, numeric::Size N>
T* numeric::MathNTensor< T, N >::data_
private
template<class T, numeric::Size N>
utility::fixedsizearray1< Size, N > numeric::MathNTensor< T, N >::n_bins_
private
template<class T, numeric::Size N>
Size numeric::MathNTensor< T, N >::size_
private

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