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