source: Sophya/trunk/Poubelle/DPC:FitsIOServer/Tests/tblitz.cc@ 658

Last change on this file since 658 was 658, checked in by ansari, 26 years ago

no message

File size: 1.7 KB
RevLine 
[658]1#include <stdio.h>
2#include <iostream.h>
3#include "nbrandom.h"
4#include "timing.h"
5#include "cimage.h"
6#include "outilsinit.h"
7// Test des NDataBlock
8#include "ndatablock.h"
9
10#include "blitz/array.h"
11using namespace blitz ;
12
13main(int narg, char *arg[])
14{
15PeidaInit();
16InitTim();
17
18char strg[128];
19int N1,N2, k, kk, i, j;
20N1 = 1;
21N2 = 10;
22if (narg > 1) N1 = atoi(arg[1]);
23if (narg > 2) N2 = atoi(arg[2]);
24
25cout << N1 << " Tests avec " << N2 << " multiplications" << endl;
26
27int sx = 300;
28int sy = 200;
29
30ImageR4 img(sx, sy), i2(sx, sy), ir(sx, sy);
31for(kk=0; kk<N1; kk++) {
32 cout << kk << " - Remplissage image (" << sx << "x" << sy << ") , " << N2 << " mult. " << endl;
33 for(i=0; i<sx; i++)
34 for(j=0; j<sy; j++) img(i,j) = frand01()*10.*j+20.*i;
35 for(i=0; i<sx; i++)
36 for(j=0; j<sy; j++) i2(i,j) = frand01()*10.*j+20.*i;
37
38 for(k=0; k<N2; k++) ir = img * i2;
39 sprintf(strg, "Img T[%d] ", kk);
40 PrtTim(strg);
41}
42
43
44 cout << "\n ==== Test avec Blitz++ " << endl;
45
46Array<float,2> a1(sy, sx), a2(sy, sx), a3(sy, sx);
47firstIndex ii;
48secondIndex jj;
49
50for(kk=0; kk<N1; kk++) {
51 cout << kk << " BlitzArray (" << sx << "x" << sy << ") , " << N2 << " mult. " << endl;
52 a1 = frand01()*10.*jj+20.*ii;
53 a2 = frand01()*10.*jj+20.*ii;
54 for(k=0; k<N2; k++) a3 = a1*a2;
55 sprintf(strg, "Blitz-Array T[%d] ", kk);
56 PrtTim(strg);
57}
58
59 cout << "\n ==== Test avec NDataBlock<float> " << endl;
60NDataBlock<r_4> b1(sx*sy), b2(sx*sy), b3(sx*sy);
61for(kk=0; kk<N1; kk++) {
62 cout << kk << " NDataBlock<float> (" << sx*sy << ") , " << N2 << " mult. " << endl;
63 for(k=0; k<sx*sy; k++) {
64 b1(k) = frand01()*10.*k;
65 b2(k) = frand01()*10.*k;
66 }
67 for(k=0; k<N2; k++) b3 = b1*b2;
68 sprintf(strg, "NDataBlock<float> T[%d] ", kk);
69 PrtTim(strg);
70}
71
72exit(0);
73}
Note: See TracBrowser for help on using the repository browser.