jplus-0.4.7
|
Typed variant of jarray, performs automatic type conversion on instantiation. More...
#include <src/jarray.h>
Public Member Functions | |
jarray_of_type (const jarray &ja) | |
Initialize with type conversion. | |
T & | operator[] (const I i) |
Directly access element of ravel. | |
const T & | operator[] (const I i) const |
Direct read-only access to an element of ravel. | |
jarray_of_type (jengine *je_) | |
Conveniently allocate scalar. | |
jarray_of_type (jengine *je_, const I l0) | |
Conveniently allocate 1-D array. | |
T & | operator() (const I i0) |
conveniently access 1-D array. | |
const T & | operator() (const I i0) const |
Convenient read-only access to 1-D array. | |
jarray_of_type (jengine *je_, const I l0, const I l1) | |
Conveniently allocate 2-D array. | |
T & | operator() (const I i0, const I i1) |
Conveniently access 2-D array. | |
const T & | operator() (const I i0, const I i1) const |
Convenient read-only access to 2-D array. | |
jarray_of_type (jengine *je_, const I l0, const I l1, const I l2) | |
Conveniently allocate 3-D array. | |
T & | operator() (const I i0, const I i1, const I i2) |
Conveniently access 3-D array. | |
const T & | operator() (const I i0, const I i1, const I i2) const |
Convenient read-only access to 3-D array. | |
jarray_of_type (jengine *je_, const I l0, const I l1, const I l2, const I l3) | |
Conveniently allocate 4-D array. | |
T & | operator() (const I i0, const I i1, const I i2, const I i3) |
Conveniently access 4-D array. | |
const T & | operator() (const I i0, const I i1, const I i2, const I i3) const |
Convenient read-only access to 4-D array. | |
jarray_of_type (jengine *je_, const I l0, const I l1, const I l2, const I l3, const I l4) | |
Conveniently allocate 5-D array. | |
T & | operator() (const I i0, const I i1, const I i2, const I i3, const I i4) |
Conveniently access 5-D array. | |
const T & | operator() (const I i0, const I i1, const I i2, const I i3, const I i4) const |
Convenient read-only access to 5-D array. | |
jarray_of_type (jengine *je_, const I rank, const I *shape) | |
Conveniently allocate n-D array. | |
jarray_of_type (jengine *je_, const std::vector< I > &shape) | |
Conveniently allocate n-D array. | |
T & | operator() (const std::vector< I > &subscripts) |
Conveniently access n-D array. | |
const T & | operator() (const std::vector< I > &subscripts) const |
Convenient read-only access to n-D array. | |
T & | operator() (const I *subscripts) |
Conveniently access n-D array. | |
const T & | operator() (const I *subscripts) const |
Convenient read-only access to n-D array. | |
Public Member Functions inherited from jarray | |
I | getRefcount () const |
returns the array refcount | |
template<class T > | |
int | get (T &v, const int i) const |
Obtains the value of a specified element of ravel. | |
template<class T > | |
int | set (const int i, const T v) |
Assigns the value of the specified element of ravel. | |
template<class T > | |
int | get (std::vector< T > &v) const |
Fits ravel of the array into the specified STL vector. | |
template<class T > | |
int | get (T &v) |
Attempts to fit the whole array into the specified type. | |
jarray () | |
Invalid array, a valid array can be assigned to it. | |
jarray (jengine *je_, std::istream &in) | |
Loads the array from binary representation in a stream. | |
jarray::I | esize () const |
Size (in bytes) of the single element of this array. | |
void | addhash (SHA1 &sha) |
Add this array (both shape and values) to the hash. | |
bool | write (std::ostream &out) |
Writes binary representation of this array into the specified output stream. | |
bool | isValid () const |
Returns true if the array is valid. | |
const I | type () const |
Returns array type. | |
const I | rank () const |
Rank (dimensionality) of the array. | |
I * | shape () const |
Returns pointer to the first element of the shape. | |
int | extent (int dimension) const |
Returns the extent of the specified dimension, element of shape. | |
void | shape (std::vector< I > &shape) const |
Copies array shape into STL vector. | |
const int | size () const |
Number of elements in ravel. | |
I * | data () const |
Returns pointer to the beginning of the array data. | |
jengine * | getEngine () const |
Returns pointer to jengine, managing memory of this array. | |
jarray (jengine *je_, void *hdr_) | |
Instantiates on top of an existing J array. | |
jarray (jengine *je_, elementType type, I rank, I *shape) | |
Creates new multidimensional array of the given J type. | |
jarray (jengine *je_, elementType type, const std::vector< I > &shape) | |
Creates new multidimensional array of the given J type. | |
jarray (jengine *je_, const std::string &str) | |
Creates T_LIT vector from C++ string. | |
jarray (const jarray &other) | |
Makes a copy of another array (increments refcount). | |
jarray & | assign (const jarray &other) |
Assigns another array to this one (increments refcount and frees memory, if necessary) | |
jarray & | operator= (const jarray &other) |
Shortcut to assign. | |
bool | operator== (const jarray &rhs) const |
Performs by-element comparison and return true if two arrays are the same. | |
~jarray () | |
Decrements refcount, frees array memory, if necessary. | |
Additional Inherited Members | |
Public Types inherited from jarray | |
enum | errorType { ERR_CONV =10 , ERR_SHAPE =11 } |
error codes More... | |
enum | elementType { T_B01 =1 , T_LIT =2 , T_INT =4 , T_FL =8 , T_CMPX =16 } |
Constants for possible array element types. More... | |
typedef char | B |
byte type, equivalent to J | |
typedef char | C |
literal type, equivalent to J | |
typedef short | S |
short int type, equivalent to J | |
typedef long | I |
integer type, equivalent to J | |
typedef double | D |
floating point type, equivalent to J | |
Static Public Member Functions inherited from jarray | |
static jarray::I | esize (elementType type) |
Size (in bytes) of the particular data type. | |
Protected Member Functions inherited from jarray | |
bool | allocate (jengine *je_, elementType type, const I rank, const I *shape) |
Allocates new array in memory. | |
void | grab () const |
Increments refcount. | |
void | release () |
Decrements refcount and frees memory, if necessary. | |
I | getHeader (bool give_up_ownership=true) const |
Protected Attributes inherited from jarray | |
header * | hdr |
Pointer to the array header, NULL for invalid array. | |
jengine * | je |
Pointer to jengine, managing the memory of this array. | |
Typed variant of jarray, performs automatic type conversion on instantiation.
|
inline |
Initialize with type conversion.
In case no conversion is needed the original array is accessed directly, otherwise a copy is made. To access the array members (subscripting) round backets are used like in Blitz++ and not the square ones, like in Boost. Convenience methods are provided for ranks up to 5, for bigger ranks one has to construct and use for indexing an integer vector.
ja | jarray, holding the data. |
References jarray::allocate(), jarray::assign(), jarray::get(), jarray::getEngine(), jarray::rank(), jarray::set(), jarray::shape(), jarray::size(), and jarray::type().
|
inline |
Conveniently allocate scalar.
je_ | jengine to manage memory of this array. |
References jarray::allocate(), and jarray::shape().
|
inline |
Conveniently allocate 1-D array.
je_ | jengine to manage memory of this array. |
l0 | new array dimension |
References jarray::allocate(), and jarray::shape().
|
inline |
Conveniently allocate 2-D array.
je_ | jengine to manage memory of this array. |
l0 | new array 1-st dimension |
l1 | new array 2-nd dimension |
References jarray::allocate(), and jarray::shape().
|
inline |
Conveniently allocate 3-D array.
je_ | jengine to manage memory of this array. |
l0 | new array 1-st dimension |
l1 | new array 2-nd dimension |
l2 | new array 3-rd dimension |
References jarray::allocate(), and jarray::shape().
|
inline |
Conveniently allocate 4-D array.
je_ | jengine to manage memory of this array. |
l0 | new array 1-st dimension |
l1 | new array 2-nd dimension |
l2 | new array 3-rd dimension |
l3 | new array 4-th dimension |
References jarray::allocate(), and jarray::shape().
|
inline |
Conveniently allocate 5-D array.
je_ | jengine to manage memory of this array. |
l0 | new array 1-st dimension |
l1 | new array 2-nd dimension |
l2 | new array 3-rd dimension |
l3 | new array 4-th dimension |
l4 | new array 5-th dimension |
References jarray::allocate(), and jarray::shape().
|
inline |
Conveniently allocate n-D array.
je_ | jengine to manage memory of this array. |
rank | rank of new array. |
shape | shape of new array. |
References jarray::allocate(), jarray::rank(), and jarray::shape().
|
inline |
Conveniently allocate n-D array.
je_ | jengine to manage memory of this array. |
shape | shape of new array. |
References jarray::allocate(), and jarray::shape().
|
inline |
Conveniently access n-D array.
Be careful, allocating enough subscripts.
subscripts | subscripts of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Convenient read-only access to n-D array.
Be careful, allocating enough subscripts.
subscripts | subscripts of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
conveniently access 1-D array.
i0 | zero-based index of the element to access. |
References jarray::data(), and jarray::rank().
|
inline |
Convenient read-only access to 1-D array.
i0 | zero-based index of the element to access. |
References jarray::data(), and jarray::rank().
|
inline |
Conveniently access 2-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Convenient read-only access to 2-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Conveniently access 3-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
i2 | zero-based 3-rd index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
Convenient read-only access to 3-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
i2 | zero-based 3-rd index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
Conveniently access 4-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
i2 | zero-based 3-rd index of the element to access. |
i3 | zero-based 4-th index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Convenient read-only access to 4-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
i2 | zero-based 3-rd index of the element to access. |
i3 | zero-based 4-th index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Conveniently access 5-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
i2 | zero-based 3-rd index of the element to access. |
i3 | zero-based 4-th index of the element to access. |
i4 | zero-based 5-th index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Convenient read-only access to 5-D array.
i0 | zero-based 1-st index of the element to access. |
i1 | zero-based 2-nd index of the element to access. |
i2 | zero-based 3-rd index of the element to access. |
i3 | zero-based 4-th index of the element to access. |
i4 | zero-based 5-th index of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Conveniently access n-D array.
subscripts | subscripts of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Convenient read-only access to n-D array.
subscripts | subscripts of the element to access. |
References jarray::data(), jarray::extent(), and jarray::rank().
|
inline |
Directly access element of ravel.
i | index. |
References jarray::data().
|
inline |
Direct read-only access to an element of ravel.
i | index. |
References jarray::data().