Jive reference manual
List of all members | Public Types | Public Member Functions
jem::ArrayExpr< T, N > Class Template Reference

A dummy class representing array expressions. More...

#include <jem/base/array/ArrayExpr.h>

Public Types

typedef Tuple< int, N > Shape
 A type representing the shape of an array expression. More...
 

Public Member Functions

const ArrayExpr< T, N > & operator= (const ArrayExpr< T, N > &rhs) const
 Copies an rvalue array expression. More...
 
const ArrayExpr< T, N > & operator= (const T &rhs) const
 Sets all elements to a specified value. More...
 
int size () const
 Returns the size of a one-dimensional array expression. More...
 
Shape shape () const
 Returns the shape of this array expression. More...
 

Detailed Description

template<class T, int N>
class jem::ArrayExpr< T, N >

The class ArrayExpr is a fictitious class that represents array expressions. The template parameter T denotes the type of the elements of the array expression, while the template parameter N denotes the rank of the array expression. For instance, if a and b are both arrays of type Array<float,3>, then the expression (a + b) is represented by the class ArrayExpr<float,3>.

The ArrayExpr class is used in this documentation to indicate that a function accepts an array expression as one of its arguments. For instance, the declaration

template <class T, int N>
void min ( const ArrayExpr<T,N>& e );

indicates that the function min can be called with any array expression of which the elements have type T, and of which the rank is N. Thus, min(a + b) is a valid function call.

The ArrayExpr class is conceptually (but not in reality!) a base class of the Array class. This means that an Array object can be passed to any function expecting an array expression. Thus, min(a) is also a valid function call.

The ArrayExpr class represents both rvalue expressions and lvalue expressions. An rvalue expression can only be used as a data source, while an lvalue expression can also be used as a data sink. This means that an rvalue expression can only be used as the right-hand side of an assignment and as the input parameter of a function. An lvalue expression, on the other hand, can also be used as the left-hand side of an assignment and as an output parameter of a function. Note that an lvalue expression is also an rvalue expression.

See also
Array, Array expressions.

Member Typedef Documentation

template<class T , int N>
typedef Tuple<int,N> jem::ArrayExpr< T, N >::Shape

The Shape type represents the shape of an array expression. It is an alias for Tuple<int,N>.

Member Function Documentation

template<class T , int N>
const ArrayExpr<T,N>& jem::ArrayExpr< T, N >::operator= ( const ArrayExpr< T, N > &  rhs) const

Assigns the values of the elements of the rvalue array expression rhs to the corresponding elements represented by this array expression.

Parameters
rhs- an rvalue array expression or an Array object.
Precondition
equal( this->shape(), rhs.shape() )
and this array expressions is an lvalue expression,
and the type T provides an assignment operator.
Returns
*this
template<class T , int N>
const ArrayExpr<T,N>& jem::ArrayExpr< T, N >::operator= ( const T &  rhs) const

Assigns all elements represented by this array expression to the value rhs.

Parameters
rhs- an object of type T.
Precondition
This array expression is an lvalue expression, and the type T provides an assignment operator.
Returns
*this
template<class T , int N>
int jem::ArrayExpr< T, N >::size ( ) const

Returns the size of a one-dimensional array expression. This function does not exist for multi-dimensional array expressions.

Returns
this->shape()[0]
template<class T , int N>
Shape jem::ArrayExpr< T, N >::shape ( ) const

Returns the shape of this array expression. It is equal to the shape of the operands of this array expression.

Returns
The shape of this array expression.