Blitz logo

Blitz Support :

From: Faheem Mitha (faheem_at_[hidden])
Date: 2005-05-20 15:55:29


Hi,

This code seems quite happy to return a value for a non-existent 3rd
dimension extent. Even if A is declared as

Array<int, 3> A(8, 8);

it still returns 8. Shouldn't it throw an exception in both cases?

Also, I notice that the compiler does not force the number of constructor
arguments to be equal to the dimension of the array. I presume this is by
design, but what is the reason?

Thanks in advance.
                                                                 Faheem.

#include <blitz/array.h>
using namespace blitz;

int main()
{
    Array<int,2> A(8,8);
    A = 0;

    cout << "Rows = " << A.rows() << endl;
    cout << "Cols = " << A.cols() << endl;
    // bug in blitz? depth() is equivalent to extent(thirdDim)
    // but A.depth returns 8 instead of 1
    cout << "Depth = " << A.depth() << endl;
    cout << "Dim = " << A.rank() << endl;

    return 0;
}