Thank you for your reply Ronald,

I'm including the code I'm using just in case I did something wrong...
class MatrixAlgorithm3D {
public:
    /////////////////////////////////////////////////
    //in an other class I have a utility function that gets the maximum values for every z vector in the array
    //and returns the resulting plane of values
    static array_type2D_ref maxPlan(array_type3D_const_ref matrix)
    {
        array_type2D resultMatrix(boost::extents[matrix.shape()[0]][matrix.shape()[1]]);

        array_type3D_const_ref::index_gen indices;      
       
        for (unsigned int x = 0; x < matrix.shape()[0]; x++) {
            for (unsigned int y = 0; y < matrix.shape()[1]; y++) {
                // get the z vector for these coordinates
                array_type3D_const_ref::const_array_view<1>::type dimensionZmatrix =  matrix[ indices[x][y][range()] ];
                resultMatrix[x][y] = std::max_element(dimensionZmatrix.begin(), dimensionZmatrix.end());
            }
        }
        return resultMatrix;
    }
    /////////////////////////////////////////////////
}

typedef boost::multi_array < double, 3 > array_type3D;
typedef boost::const_multi_array_ref < double, 3 > array_type3D_const_ref;
typedef boost::multi_array < double, 2 > array_type2D;
typedef boost::multi_array_ref < double, 2 > array_type2D_ref;

int main(void) {
    array_type3D matrix(boost::extents[775][775][100]);

    // lets say I initialise it this way (I usually get the values from a flat file)
    for (unsigned int x = 0; x < 775; x++) {
        for (unsigned int y = 0; y < 775; y++) {
            for (unsigned int z = 0; z < 100; z++) {
                matrix[x][y][z] = avalue;
            }
        }
    }


    // then I call the function in my main program
    array_type2D a= MatrixAlgorithm3D
::maxPlan(matrix);
    // should I use an array_type2D_ref
for the return value instead?

    // then I write the results to a flat file
    ...

  return 0;
}


Ronald Garcia wrote:

Hello Sebastien,

Ideally, you should be able to work with an array of doubles, rather than an array of pointers to double. I can create an multi_array with the dimensions you mention.  

To answer your questions, multi_array uses a standard library allocator to allocate a contiguous block of memory in which to hold the array data.  I'm afraid I do not know why you cannot exceed these limits.

ron



I'm currently using multi_array to represent 3D matrices of doubles, I
was wondering which would be the best use since the array has to hold a
very large amount of data. I' currently testing whith a multi_array of
800x800x100 to hold double or pointers to double and I have memory
problems. When I declare the multi_array whith pointers to doubles I can
usually go up to 775x775x100 without problems but when I try the same
thing with a multi_array of doubles I get a bad alloc error. My real
needs for the moment are for a multi_array of 800x600x57 but I will need
bigger storage capacity in the near future, what are your sugesstions. 

Is the multi_array a pointer itself?
How is memory management handled?
How can go beyond these limits? 


-- 
Sébastien Fortier


_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users


--

Sébastien Fortier