libpnicore
Modules | Data Structures | Typedefs | Functions
Multidimensional arrays

Modules

 Internal classes
 
 Dimension layout classes
 

Data Structures

singleton  pni::core::array_view< ATYPE >
 provides a view on a part of an array More...
 
class  pni::core::mdarray< STORAGE, IMAP, IPA >
 template for a multi-dimensional array class More...
 
class  pni::core::scalar< T >
 Scalar template for scalar values. More...
 
class  pni::core::slice
 index slice More...
 

Typedefs

template<typename T >
using pni::core::dynamic_array = mdarray< std::vector< T >, dynamic_cindex_map >
 a dynamic array template More...
 
template<typename T , size_t D>
using pni::core::fixed_dim_array = mdarray< std::vector< T >, fixed_dim_cindex_map< D >>
 array template with fixed dimension More...
 
template<typename T , size_t... NDIMS>
using pni::core::static_array = mdarray< std::array< T, boost::mpl::times< boost::mpl::size_t< 1 >, boost::mpl::size_t< NDIMS >... >::value >, static_cindex_map< NDIMS...> >
 static array template More...
 

Functions

template<typename ATYPE >
bool pni::core::operator== (const array_view< ATYPE > &a, const array_view< ATYPE > &b)
 compare two array views More...
 
template<typename ATYPE >
bool pni::core::operator!= (const array_view< ATYPE > &a, const array_view< ATYPE > &b)
 compare two array views More...
 
template<typename ATYPE >
std::ostream & pni::core::operator<< (std::ostream &stream, const array_view< ATYPE > &v)
 output operator for view More...
 
template<typename ATYPE >
std::istream & pni::core::operator>> (std::istream &stream, array_view< ATYPE > &v)
 input operator for view More...
 
template<typename STORAGE , typename IMAP , typename IPA >
std::ostream & pni::core::operator<< (std::ostream &o, const mdarray< STORAGE, IMAP, IPA > &a)
 output operator More...
 
template<typename STORAGE , typename IMAP , typename IPA >
std::istream & pni::core::operator>> (std::istream &is, mdarray< STORAGE, IMAP, IPA > &a)
 input stream operator More...
 
template<typename STORAGE , typename IMAP , typename IPA >
bool pni::core::operator== (const mdarray< STORAGE, IMAP, IPA > &b1, const mdarray< STORAGE, IMAP, IPA > &b2)
 equality comparison operator More...
 
template<typename STORAGE , typename IMAP , typename IPA >
bool pni::core::operator!= (const mdarray< STORAGE, IMAP, IPA > &b1, const mdarray< STORAGE, IMAP, IPA > &b2)
 inequality comparison operator More...
 
template<typename T >
bool pni::core::operator== (const scalar< T > &a, const scalar< T > &b)
 == operator for scalar More...
 
template<typename T >
bool pni::core::operator!= (const scalar< T > &a, const scalar< T > &b)
 != operator for scalar More...
 
template<typename T >
std::ostream & pni::core::operator<< (std::ostream &os, const scalar< T > &s)
 stream output operator More...
 
template<typename T >
std::istream & pni::core::operator>> (std::istream &is, scalar< T > &s)
 input strema data More...
 
size_t pni::core::size (const slice &s)
 compute slice size More...
 
size_t pni::core::span (const slice &s)
 compute total elements spanned More...
 
type_id_t pni::core::type_id (const array &a)
 get type id More...
 

Detailed Description

Typedef Documentation

template<typename T >
using pni::core::dynamic_array = typedef mdarray<std::vector<T>,dynamic_cindex_map>

This template creates a fully dynamic array type. Its rank as well as its number of elements along each dimension (the shape) can be created dynamically. Use this type if all decisions have to be made at runtime.

typedef dynamic_array<float64> array_type;
array_type a = ...;
Template Parameters
Telement type
template<typename T , size_t D>
using pni::core::fixed_dim_array = typedef mdarray<std::vector<T>,fixed_dim_cindex_map<D>>

This array template fixes the number of dimensions for an array type at compile time. It will be the appropriate type for most applications. The following code defines an image type (we know that images have always 2 dimensions):

typedef fixed_dim_array<uint32,2> image_type;
Template Parameters
Telement data type
Dnumber of dimensions
template<typename T , size_t... NDIMS>
using pni::core::static_array = typedef mdarray<std::array<T,boost::mpl::times< boost::mpl::size_t<1>, boost::mpl::size_t<NDIMS>... >::value >, static_cindex_map<NDIMS...> >

This template can be used for static array types. These are types where the number of dimensions as well as the total number of elements along each dimension are known at compile time. A typical application would be matrices and vectors for 3D operations.

typedef static_array<float64,3> vector_type;
typedef static_array<float64,3,3> matrix_type;
typedef static_array<float64,6,6> elasticity_tensor;

Instances of such types usually reside on the stack which makes access to their data elements extremely fast.

Template Parameters
Telement data type
NDIMSnumber of elements along each dimension

Function Documentation

template<typename T >
bool pni::core::operator!= ( const scalar< T > &  a,
const scalar< T > &  b 
)

Returns true if the two value of a and b are not equal.

Template Parameters
Tdata type for the scalar instance
Parameters
alhs value of the operator
brhs value of the operator
Returns
false if both are equal, true otherwise
template<typename ATYPE >
bool pni::core::operator!= ( const array_view< ATYPE > &  a,
const array_view< ATYPE > &  b 
)

Returns false if all elements in a an b are equal. a and b must have equal size, otherwise a size_mismatch_error exception is thrown.

Template Parameters
ATYPEarray type for the view
Parameters
alhs value of the operator
brhs value of the operator
Returns
false if all values are equal, true otherwise
template<typename STORAGE , typename IMAP , typename IPA >
bool pni::core::operator!= ( const mdarray< STORAGE, IMAP, IPA > &  b1,
const mdarray< STORAGE, IMAP, IPA > &  b2 
)

Returns true if thwo arrays are not equal.

Parameters
b1array on the lhs of the comparison
b2array on the rhs of the comparison
Returns
true if not equal, false otherwise
template<typename T >
std::ostream& pni::core::operator<< ( std::ostream &  os,
const scalar< T > &  s 
)

Write content to output stream.

Parameters
osoutput stream
sscalar value
Returns
reference to output stream
template<typename ATYPE >
std::ostream& pni::core::operator<< ( std::ostream &  stream,
const array_view< ATYPE > &  v 
)

Output a view instance to a stream.

Template Parameters
ATYPEarray type of the view
Parameters
streamreference to output stream
vview instance
Returns
reference to the modified stream
Examples:
example_array3.cpp, and example_array4.cpp.
template<typename STORAGE , typename IMAP , typename IPA >
std::ostream& pni::core::operator<< ( std::ostream &  o,
const mdarray< STORAGE, IMAP, IPA > &  a 
)

Writes content of a DArray to an output stream.

Parameters
ooutput stream
aarray to output
Returns
output stream
template<typename T >
bool pni::core::operator== ( const scalar< T > &  a,
const scalar< T > &  b 
)

Returns true if the two value of a and b are equal.

Template Parameters
Tdata type for the scalar instance
Parameters
alhs value of the operator
brhs value of the operator
Returns
true if both are equal, false otherwise
template<typename ATYPE >
bool pni::core::operator== ( const array_view< ATYPE > &  a,
const array_view< ATYPE > &  b 
)

Returns true if all elements of a an b are equal. The two views must have equal size. Otherwise a size_mismatch_excpetion is thrown.

Template Parameters
ATYPEarray type for the view
Parameters
alhs value of the operator
brhs value of the operator
Returns
true if all elements are equal, flase otherwise
template<typename STORAGE , typename IMAP , typename IPA >
bool pni::core::operator== ( const mdarray< STORAGE, IMAP, IPA > &  b1,
const mdarray< STORAGE, IMAP, IPA > &  b2 
)

Returns true if thwo arrays are equal. This is the case when all element stored in the arrays are equal.

Parameters
b1array on the lhs of the comparison
b2array on the rhs of the comparison
Returns
true if all elements are equal, false otherwise
template<typename T >
std::istream& pni::core::operator>> ( std::istream &  is,
scalar< T > &  s 
)

Read content from input stream

Parameters
isinput stream
sscalar
Returns
reference to input stream
template<typename ATYPE >
std::istream& pni::core::operator>> ( std::istream &  stream,
array_view< ATYPE > &  v 
)

Write data from a stream to a view.

Template Parameters
ATYPEarray type of the view
Parameters
streamreference to the input stream
vreference to the view
Returns
reference to the modified input stream
template<typename STORAGE , typename IMAP , typename IPA >
std::istream& pni::core::operator>> ( std::istream &  is,
mdarray< STORAGE, IMAP, IPA > &  a 
)

Read data from an input stream.

Parameters
isinput stream
aarray where to store the data
Returns
reference to input stream
size_t pni::core::size ( const slice &  s)

Computes the number of elements spanned by a slice.

\[ size=\frac{last-first+stride-1}{stride} \]

Parameters
sslice object
Returns
number of spanned elements
size_t pni::core::span ( const slice &  s)

Computes the total number of elements spanned by the slice.

\[ span = last-first \]

Parameters
sslice for which to compute the span
Returns
total number of elements
type_id_t pni::core::type_id ( const array &  a)

Get the type ID of the array stored in an array type erasure.

Parameters
areference to the array
Returns
the type ID