| [224] | 1 | #include <stdio.h> | 
|---|
| [2322] | 2 | #include <iostream> | 
|---|
| [2615] | 3 | #include "sopnamsp.h" | 
|---|
| [224] | 4 | #include "nbrandom.h" | 
|---|
|  | 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" | 
|---|
|  | 12 | using namespace blitz ; | 
|---|
|  | 13 |  | 
|---|
|  | 14 | main(int narg, char *arg[]) | 
|---|
|  | 15 | { | 
|---|
| [768] | 16 | SophyaInit(); | 
|---|
| [224] | 17 | InitTim(); | 
|---|
|  | 18 |  | 
|---|
|  | 19 | char strg[128]; | 
|---|
|  | 20 | int N1,N2, k, kk, i, j; | 
|---|
|  | 21 | N1 = 1; | 
|---|
|  | 22 | N2 = 10; | 
|---|
|  | 23 | if (narg > 1)  N1 = atoi(arg[1]); | 
|---|
|  | 24 | if (narg > 2)  N2 = atoi(arg[2]); | 
|---|
|  | 25 |  | 
|---|
|  | 26 | cout << N1 << " Tests avec " << N2 << " multiplications" << endl; | 
|---|
|  | 27 |  | 
|---|
|  | 28 | int sx = 300; | 
|---|
|  | 29 | int sy = 200; | 
|---|
|  | 30 |  | 
|---|
|  | 31 | ImageR4  img(sx, sy), i2(sx, sy), ir(sx, sy); | 
|---|
|  | 32 | for(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 |  | 
|---|
|  | 47 | Array<float,2> a1(sy, sx), a2(sy, sx), a3(sy, sx); | 
|---|
|  | 48 | firstIndex ii; | 
|---|
|  | 49 | secondIndex jj; | 
|---|
|  | 50 |  | 
|---|
|  | 51 | for(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; | 
|---|
|  | 61 | NDataBlock<r_4> b1(sx*sy), b2(sx*sy), b3(sx*sy); | 
|---|
|  | 62 | for(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 |  | 
|---|
|  | 73 | exit(0); | 
|---|
|  | 74 | } | 
|---|