# Just Launched: You can now import projects and releases from Google Code onto SourceForge

We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps.

## #33 constructing a 2D array with a 3D ctor...

closed-invalid
nobody
None
5
2011-12-06
2011-11-30
Sylwester Arabas
No

The following code:

#include <blitz/array.h>
using namespace blitz;
int main()
{
{
Array<float, 3> a_3D(1,1,1);
Array<float, 3> b_3D(Range(0,0), Range(1,1), Range(2,2));
cerr << "C a:" << a_3D.columns() << " b:" << b_3D.columns() << endl;
cerr << "R a:" << a_3D.rows() << " b:" << b_3D.rows() << endl;
cerr << "D a:" << a_3D.depth() << " b:" << b_3D.depth() << endl;
}

{
Array<float, 2> a_2D(1,1,1);
Array<float, 2> b_2D(Range(0,0), Range(1,1), Range(2,2));
cerr << "C a:" << a_2D.columns() << " b:" << b_2D.columns() << endl;
cerr << "R a:" << a_2D.rows() << " b:" << b_2D.rows() << endl;
cerr << "D a:" << a_2D.depth() << " b:" << b_2D.depth() << endl;
}
}

gives the following result with the current hg version of Blitz:

C a:1 b:1
R a:1 b:1
D a:1 b:1
C a:1 b:1
R a:1 b:2
D a:1 b:1

what apparently means that:
- Blitz does not complain if a 2D array is initialised using a 3D constructor and
- in such case the rows() function returns different values if it was a Range- or int-constructor

Hope that helps,
Sylwester

## Discussion

• Patrik Jonsson
2011-12-06

When compiled with -DBZ_DEBUG, which enables range checking, this code results in:

C a:1 b:1
R a:1 b:1
D a:1 b:1
a.out: include/blitz/array-impl.h:195: blitz::Array<P_numtype, N_rank>::Array(int, int, int, blitz::GeneralArrayStorage<N_rank>) [with P_numtype = float, N_rank = 2]: Assertion `N_rank >= 3' failed.
Aborted (core dumped)

For performance reasons, such checks are not done without the debug flag.

• Patrik Jonsson
2011-12-06

• status: open --> closed-invalid