Boost logo

Boost :

From: RGProlog_at_[hidden]
Date: 2004-02-10 01:10:06


Is anyone interested in dynamic_multi_array template library that offers user
intuitive convenience of use as well as capacity to hone in upon any specific
subset of a multi-dimensional array? As an example of usage, a
dynamic_multi_array object can be constructed and then resized and then reshaped like this:
   size_t arrayShape = { 3, 7, 15};
   dynamic_multi_array<double, 3> A(arrayShape);
   boost::array<size_t, 3> anotherArrayShape = {{ 5, 4, 22}};
  A.resize(anotherArrayShape);
   boost::array<size_t, 5> yetAnotherArrayShape = {{ 440, 1, 1, 0, 0}} ;
  A.reshape(yetAnotherArrayShape);
   size_t stillAnotherArrayShape[4] = { 22, 10, 2, 11};
  A.reshape(stillAnotherArrayShape);
The library’s design owes a lot to Andrei Alexandrescu’s ideas. It is based
on the data_table helper class template defined as follows:
template<typename X>
class data_table {
…
protected:
    std::vector<X> data_table_ ;};
template<> <value_type>
class data_table {
…
protected:
    value_type* data_table_ ;};
Then, a sequence of the table class instantiation types is recursively
defined and then given a name that is shared in different dimensional contexts as
follows:
 
typedef data_table<value_type> data_table_01;
…………………………………………….
typedef data_table< data_table_49 > data_table_50 ;
 
class Int2Type<int> {
    typedef data_table_01 data_table;
}
……………………………………………
class Int2Type<> <50> {
    typedef data_table_50 data_table;
}
Being a recursive template class, the data_table is implemented in a concise
code that is mostly about stating a few recursive rules and implementing some
access operators and is totally dimension independent. This is the central
feature of the design since the user level wrapper class template by virtue of
exporting a dimension appropriate data_table instantiation that uses its shared
name
template <T, size_t i, Allocator>
class dynamic_multi_array {
……………………………………….
typedef …. class Int2Type <i>::data_table;
}
is also implemented in a way that hides all the implementation details, is
concise and dimension independent, thus providing user with a great deal of
flexibility, syntax safety, and, in case of a new user, a flat learning curve.
This is a std::vector based design. The dynamic_multi_array template class,
the library’s main component, extends, where appropriate, std::vector
capacities, replicates its exception safety guarantees and has std::vector as its back
end storage device.
   The library’s code, documentation including a short tutorial and a few key
tests and will be posted in Dynamic Multi Array Folder on boost Files once
the issue of available space will be resolved.
 
 



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk