Boost logo

Boost Users :

From: Klett, Stefan (stefan.klett_at_[hidden])
Date: 2008-03-04 10:21:12


Hi list members,

This is a more or less a general kind of " how to extend container
classes" question -
I'm trying to write a class which inherits from boost::multi_array - the
to get a kind of matrix class with some additional service routines.
Maybe it is a lack of experience - but I for the time being I don't know
how to solve the problem to access the constructor of multi_array in my
own class to initialize my matrix class - my current guess was to use
the "this" pointer but it had not worked out like I supposed it to do.

class NetworkMultiArray: public boost::multi_array<double,3>
{
public:
        NetworkMultiArray(int);
        virtual ~NetworkMultiArray();
};

Here is the constructor code:

NetworkMultiArray::NetworkMultiArray(int length)
{
          this::iterator iter3;
          typedef this::template subarray<2>::type::iterator iter2;
          typedef this::template subarray<1>::type::iterator iter1;

        for( iter1 i = *this.begin(); iter1 != *this.end(); iter1++){
                for(iter2 ii = (*i).begin(); ii != (*i).end(); ii++){
                        for(iter3 iii = (*ii).begin(); iii !=
(*ii).end(); iii++){
                                *iii = 0.0 ;
                        }
                }
        }
}
 sure this does not work - and is the result from trying to adapt the
iterator example from the documentation.

my aim is to handle the NetworkMultiArray like a boost::multi_array and
initialize it to zero - further it would be nice if somebody could tell
me how I could assign a length to the array and the subarrays.
The key-point is that I want to use my class (NetworkMultiArray) like a
multi_array by inheritance of the multi_array features of
boost:multi_array.

Thank you very much in advance.
Best regards
Stefan
 
--------------------------------------------------------
Stefan Klett (Dipl. Informatiker) | E-mail: stefan.klett_at_[hidden]
Forschungszentrum Karlsruhe / KIT | Web: http://www.fzk.de
SCC Steinbuch Centre for Computing| Phone: +49 (0)7247 828649
Hermann-von-Helmholtz-Platz 1 | Fax: +49 (0)7247 824972
D-76344 Eggenstein-Leopoldshafen | Mobile: +49 (0)176 20317250
-------------------------------------------------------------------


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net