RobWorkProject  23.9.11-
Public Types | Public Member Functions | Static Public Member Functions | List of all members
RawArray< T, Dim > Class Template Reference

Representation of a N-dimensional Mathematica array with fixed depth. More...

#include <RawArray.hpp>

Inherits Mathematica::Array< T >.

Public Types

typedef rw::core::Ptr< RawArray< T, Dim > > Ptr
 Smart pointer type.
 
typedef boost::multi_array< T, Dim > ArrayType
 The underlying array type.
 
- Public Types inherited from Mathematica::Array< T >
typedef rw::core::Ptr< Array< T > > Ptr
 Smart pointer type.
 
- Public Types inherited from Mathematica::Expression
enum  Type {
  String , Integer , Real , Symbol ,
  Function , Array
}
 Type of expression. More...
 
typedef rw::core::Ptr< ExpressionPtr
 Smart pointer type.
 
typedef enum rwlibs::mathematica::Mathematica::Expression::Type Type
 Type of expression.
 

Public Member Functions

 RawArray (const ArrayType &array)
 Construct new array. More...
 
 RawArray (boost::array< typename ArrayType::index, Dim > shape)
 Construct new array with specific shape. More...
 
 RawArray (const std::vector< std::size_t > shape)
 Construct new array with specific shape. More...
 
 RawArray (const T *const data, const int *const shape)
 Construct RawArray from native Mathematica array. More...
 
virtual ~RawArray ()
 Destructor.
 
const ArrayTypegetArray () const
 Get the underlying array. More...
 
void set (std::vector< std::size_t > indexes, T value)
 Set a value. More...
 
std::vector< std::size_t > getSize () const
 Get the shape. More...
 
virtual void out (std::ostream &stream) const
 Print to output stream. More...
 
virtual Mathematica::Expression::Ptr clone () const
 Make a copy of the expression. More...
 
virtual const int * size () const
 Get the shape as a list of integers. More...
 
virtual const T * data () const
 Get the raw data. More...
 
virtual int dimensions () const
 Get the dimensions. More...
 
- Public Member Functions inherited from Mathematica::Array< T >
virtual ~Array ()
 Destructor.
 
Type getType () const
 Get the type of expression. More...
 

Static Public Member Functions

static RawArray< T, Dim >::Ptr fromExpression (const Mathematica::FunctionBase &exp)
 Construct a new array from an expression. More...
 
static void setValues (ArrayType &array, rw::core::Ptr< const List > list, std::size_t level, boost::array< typename ArrayType::index, Dim > cur, const std::vector< std::size_t > &size)
 Set the values of an array recursively. More...
 
static List::Ptr createList (const ArrayType &array, std::size_t level, boost::array< typename ArrayType::index, Dim > cur, const std::vector< std::size_t > &size)
 Create a List expression from an array. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from Mathematica::Expression
template<typename Type >
static void toList (std::list< rw::core::Ptr< Type >> &)
 Helper function for extracting a list of arguments when given as a variable number of arguments. More...
 
template<typename Type , typename Exp , typename... T>
static void toList (std::list< rw::core::Ptr< Type >> &list, const Exp &r, T... t)
 Helper function for extracting a list of arguments when given as a variable number of arguments. More...
 

Detailed Description

template<typename T, std::size_t Dim>
class rwlibs::mathematica::RawArray< T, Dim >

Representation of a N-dimensional Mathematica array with fixed depth.

Constructor & Destructor Documentation

◆ RawArray() [1/4]

RawArray ( const ArrayType array)
inline

Construct new array.

Parameters
array[in] the array.

◆ RawArray() [2/4]

RawArray ( boost::array< typename ArrayType::index, Dim >  shape)
inline

Construct new array with specific shape.

Parameters
shape[in] the shape.

◆ RawArray() [3/4]

RawArray ( const std::vector< std::size_t >  shape)
inline

Construct new array with specific shape.

Parameters
shape[in] the shape.

◆ RawArray() [4/4]

RawArray ( const T *const  data,
const int *const  shape 
)
inline

Construct RawArray from native Mathematica array.

Parameters
data[in] the data.
shape[in] the shape.

Member Function Documentation

◆ clone()

virtual Mathematica::Expression::Ptr clone ( ) const
inlinevirtual

Make a copy of the expression.

Returns
a new copy.

Implements Mathematica::Expression.

◆ createList()

static List::Ptr createList ( const ArrayType array,
std::size_t  level,
boost::array< typename ArrayType::index, Dim >  cur,
const std::vector< std::size_t > &  size 
)
inlinestatic

Create a List expression from an array.

Parameters
array[in] the array.
level[in] the current level.
cur[in] the current indices.
size[in] the shape of the array.
Returns
a list.

◆ data()

virtual const T* data ( ) const
inlinevirtual

Get the raw data.

Returns
a pointer to the first element.

Implements Mathematica::Array< T >.

◆ dimensions()

virtual int dimensions ( ) const
inlinevirtual

Get the dimensions.

Returns
the number of dimensions.

Implements Mathematica::Array< T >.

◆ fromExpression()

static RawArray<T, Dim>::Ptr fromExpression ( const Mathematica::FunctionBase exp)
inlinestatic

Construct a new array from an expression.

Parameters
exp[in] the expression to parse.
Returns
a new array.

◆ getArray()

const ArrayType& getArray ( ) const
inline

Get the underlying array.

Returns
a reference to the array.

◆ getSize()

std::vector<std::size_t> getSize ( ) const
inline

Get the shape.

Returns
a list of sizes for each dimension.

◆ out()

virtual void out ( std::ostream &  stream) const
inlinevirtual

Print to output stream.

Parameters
stream[in/out] the stream to print to.

Implements Mathematica::Expression.

◆ set()

void set ( std::vector< std::size_t >  indexes,
value 
)
inline

Set a value.

Parameters
indexes[in] the indices.
value[in] the value to set.

◆ setValues()

static void setValues ( ArrayType array,
rw::core::Ptr< const List list,
std::size_t  level,
boost::array< typename ArrayType::index, Dim >  cur,
const std::vector< std::size_t > &  size 
)
inlinestatic

Set the values of an array recursively.

Parameters
array[in/out] the array.
list[in] the list at the current level.
level[in] the current level.
cur[in] the current indices.
size[in] the shape of the array.

◆ size()

virtual const int* size ( ) const
inlinevirtual

Get the shape as a list of integers.

Returns
list of same length as dimensions()

Implements Mathematica::Array< T >.


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