source: Sophya/trunk/SophyaProg/Tests/tblitz.cc@ 4003

Last change on this file since 4003 was 3077, checked in by cmv, 19 years ago

remplacement nbrandom.h (obsolete) -> srandgen.h cmv 14/09/2006

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