libidx
ebl::midx< T > Class Template Reference

#include <idx.h>

Inheritance diagram for ebl::midx< T >:
ebl::idx< idx< T > * > ebl::smart_pointer

List of all members.

Public Member Functions

 midx (intg size, std::file *fp=NULL, idx< int64 > *offsets=NULL)
 midx (intg size0, intg size1, std::file *fp=NULL, idx< int64 > *offsets=NULL)
 midx (idxdim &d, std::file *fp=NULL, idx< int64 > *offsets=NULL)
 midx ()
 Empty constructor.
 midx (const midx< T > &o)
 Construct an midx given an idx of pointers to idx.
virtual ~midx ()
 The destructor deletes all allocated idx pointers.
virtual midx< T > & operator= (const midx< T > &other)
 Copy an midx into another.
void resize (intg i0)
void resize (intg i0, intg i1)
void resize (midx< T > &other)
 Allocate/resizes all elements of this to be the same as 'other'.
void remove (intg i0)
 Deletes idx at position 'i0' (if present).
void remove (intg i0, intg i1)
 Deletes idx at position ('i0', 'i1') (if present).
void clear ()
 Deletes all idx present and set all to NULL.
void set (idx< T > &e, intg i0)
 Set matrix 'e' at position 'i0'.
void set (idx< T > &e, intg i0, intg i1)
 Set matrix 'e' at position ('i0', 'i1').
idx< T > get (intg i0)
idx< T > get (intg i0, intg i1)
midx< T > narrow (int d, intg s, intg o)
 Return a narrowed version of current midx.
midx< T > select (int d, intg s)
 Return a slice 's' of this midx in dimension d.
bool exists (intg pos) const
 Returns true if a matrix is present at position 'pos', false otherwise.
bool exists (intg i0, intg i1) const
idxdim get_maxdim ()
virtual bool same_dim (const midx< T > &other) const
idx< int64 > get_offsets ()
 Returns the offsets of the on-demand loading matrix.
std::fileget_file_pointer ()
 Returns the on-demande file pointer.
virtual intg nelements_all () const
 Return total number of elements in all sub-matrices.
virtual idx< T > pack ()
virtual void shift_dim_internal (int d, int pos)
 For each sub-matrix, shift dimension 'd' to position 'pos'.
virtual void pretty () const
 Pretty all sub-matrices to std::cout.
template<class stream >
void pretty (stream &out, bool newline=true) const
 Pretty all sub-matrices.
virtual std::string str () const
 Pretty all sub-matrices into a string and return it.

Protected Member Functions

void lock_all ()
void unlock_all ()
 Unlock all idx contained in this midx.

Protected Attributes

std::filefp
 Load matrices ondemand if not null.
idx< int64 > offsets
 File offsets for each element.

Detailed Description

template<typename T>
class ebl::midx< T >

An idx vector containing pointers to other idx. Pointed idx can either be loaded all at once using 'load_matrices()' or on-demand using 'load_matrices_ondemand()'. Loading on-demand can be useful if the matrices are too big to all fit in memory at once.


Constructor & Destructor Documentation

template<typename T >
ebl::midx< T >::midx ( intg  size,
std::file fp = NULL,
idx< int64 > *  offsets = NULL 
)

This creates a vector of matrices of size 'size'. Initially all elements are set to empty.

Parameters:
fpIf not null, use this file pointer to dynamically load each matrix when requested.
template<typename T >
ebl::midx< T >::midx ( intg  size0,
intg  size1,
std::file fp = NULL,
idx< int64 > *  offsets = NULL 
)

This creates a matrix of matrices of size 'size0'x'size1'. Initially all elements are set to empty.

Parameters:
fpIf not null, use this file pointer to dynamically load each matrix when requested.
template<typename T >
ebl::midx< T >::midx ( idxdim d,
std::file fp = NULL,
idx< int64 > *  offsets = NULL 
)

This creates a matrix of matrices with dimensions 'd'. Initially all elements are set to empty.

Parameters:
fpIf not null, use this file pointer to dynamically load each matrix when requested.

Member Function Documentation

template<typename T >
bool ebl::midx< T >::exists ( intg  i0,
intg  i1 
) const

Returns true if a matrix is present at position ('i0', 'i1'), false otherwise.

template<typename T >
idx< T > ebl::midx< T >::get ( intg  i0)

Get matrix at position 'i0'. This throws an error if matrix does not exist. Use exists() to verify it does.

template<typename T >
idx< T > ebl::midx< T >::get ( intg  i0,
intg  i1 
)

Get matrix at position ('i0', 'i1'). This throws an error if matrix does not exist. Use exists() to verify it does.

template<typename T >
idxdim ebl::midx< T >::get_maxdim ( )

Returns the dimensions of the matrix with maximum number of elements among all matrices contained in this midx.

template<typename T >
void ebl::midx< T >::lock_all ( ) [protected]

Lock all idx contained in this midx, so that they are not deleted if other midx referencing them unlock them.

template<typename T >
idx< T > ebl::midx< T >::pack ( ) [virtual]

Pack all data into a single matrix. This function can only be called if all sub-matrices have the same size. An error will be thrown otherwise. This operation is expensive as it involves copying all data into a single idx.

template<typename T >
void ebl::midx< T >::resize ( intg  i0,
intg  i1 
)

Deletes all sub-tensors, resizes current vector to size ('i0', 'i1') and sets all pointers to NULL.

template<typename T >
void ebl::midx< T >::resize ( intg  i0)

Deletes all sub-tensors, resizes current vector to size 'i0' and sets all pointers to NULL.

template<typename T >
bool ebl::midx< T >::same_dim ( const midx< T > &  other) const [virtual]

Returns true if this midx has same order and dimensions for each submatrix of 'other'.


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