Hi Florian,

1. Yes. When you generate an Array "view" of preexisting data, the storage option tells blitz how the data is mapped. So when you say the data in memory is a fortran-array, that's what it will use. For a given set of data in memory, this means that when you turn it into a blitz array, specifying fortran storage will result in an array that is transposed compared to one using C storage. The entire point behind being able to specify the storage order is to maintain compatibility with various existing ways of storing arrays.

The explanation about storage orders in the manual has a lot of info about this.

Cheers,

/Patrik
 



On Fri, Oct 11, 2013 at 4:11 AM, Florian Oswald <florian.oswald@gmail.com> wrote:
Hi all,

I have got a very basic question. I noted that when initializing a blitz array as a fortranArray the data get mapped differently. (At least when I print the array with cout it appears so.) I wanted to make sure I understand this correctly and whether the way I deal with it is right. so, questions about the code below:

1) allocating a fortranArray maps preexisting data differently? (it's not an artifact of cout that I see the array differently when I print it)
2) given 1), one needs to order the data accordingly.

Thanks for your help!
Florian

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

int main(int argc, char *argv[])
{
// directly allocate an array
Array<double,2> G(2,2);
G = 0.3,0.7,0.4,0.6;
cout << "G = " << endl;
cout << G << endl;

// map an array from existing data
double trans[] = {0.3,0.7,0.4,0.6};
Array<double,2> Gmapped(trans,shape(2,2),neverDeleteData);
cout << "Gmapped = " << endl;
cout << Gmapped << endl;

// map an array from existing data as a fortran array
Array<double,2> Gfort(trans,shape(2,2),neverDeleteData,FortranArray<2>());
cout << "Gfort = " << endl;
cout << Gfort << endl;

cout << "it seems FortranArray maps the data rowwise." << endl;

// reorder data and map an array from existing data as a fortran array
double trans2[] = {0.3,0.4,0.7,0.6};
Array<double,2> Gfort2(trans2,shape(2,2),neverDeleteData,FortranArray<2>());
cout << "Gfort2 = " << endl;
cout << Gfort2 << endl;

return(0) ;

 }

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Blitz-support mailing list
Blitz-support@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/blitz-support