1 | #include "machdefs.h"
|
---|
2 |
|
---|
3 | #include <math.h>
|
---|
4 | #include <iostream.h>
|
---|
5 |
|
---|
6 | #include "nbrandom.h"
|
---|
7 | #include "tarrinit.h"
|
---|
8 | #include "tarray.h"
|
---|
9 | #include "tvector.h"
|
---|
10 | #include "timing.h"
|
---|
11 | #include "intflapack.h"
|
---|
12 |
|
---|
13 |
|
---|
14 | int main(int narg, char* arg[])
|
---|
15 | {
|
---|
16 |
|
---|
17 | SophyaInit();
|
---|
18 | InitTim(); // Initializing the CPU timer
|
---|
19 |
|
---|
20 |
|
---|
21 | int n = 5;
|
---|
22 | int i,j,k;
|
---|
23 |
|
---|
24 | if (narg > 1) n = atoi(arg[1]);
|
---|
25 | cout << "rztest_lapack - Size=" << n << endl;
|
---|
26 | try {
|
---|
27 | TArray<r_4> a(n,n);
|
---|
28 | for(i=0; i<n; i++)
|
---|
29 | for(j=0; j<n; j++) a(i,j,0) = GauRnd(0., 1.);
|
---|
30 |
|
---|
31 | TArray<r_4> x(1,n), b(1,n);
|
---|
32 | r_4 sum ;
|
---|
33 | for(i=0; i<n; i++) x(0,i,0) = GauRnd(2., 1.5);
|
---|
34 | for(i=0; i<n; i++) {
|
---|
35 | sum = 0.;
|
---|
36 | for(j=0; j<n; j++) sum += a(j,i,0)*x(0,j,0);
|
---|
37 | b(0,i,0) = sum;
|
---|
38 | }
|
---|
39 |
|
---|
40 | cout << " ------------ Matrix A = \n " << a << "\n" << endl;
|
---|
41 | cout << " ------------ Matrix X = \n " << x << "\n" << endl;
|
---|
42 | cout << " ------------ Matrix B = \n " << b << "\n" << endl;
|
---|
43 |
|
---|
44 | cout << "\n Calling rztest_lapack ... " << endl;
|
---|
45 |
|
---|
46 | rztest_lapack(a, b);
|
---|
47 |
|
---|
48 | cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl;
|
---|
49 |
|
---|
50 | PrtTim(" End of lpk (rztest_lapack) ");
|
---|
51 | }
|
---|
52 | catch (PThrowable exc) {
|
---|
53 | cerr << " catched Exception (rztest_lapack) " << exc.Msg() << endl;
|
---|
54 | }
|
---|
55 | catch (...) {
|
---|
56 | cerr << " catched unknown (...) exception (rztest_lapack) " << endl;
|
---|
57 | }
|
---|
58 |
|
---|
59 | try {
|
---|
60 | cout << "\n -----> Testing TArray <---- " << endl;
|
---|
61 | TArray<int_4> ia(6,4);
|
---|
62 | TArray<int_4> ib(2,3);
|
---|
63 | Sequence seq(10., 2.);
|
---|
64 | ia = seq;
|
---|
65 | ib = 5;
|
---|
66 | cout << " ----- matrix IA = \n " << ia << endl;
|
---|
67 | cout << " ----- matrix IB = \n " << ib << endl;
|
---|
68 | uint_4 pos[5];
|
---|
69 | uint_4 sz[5];
|
---|
70 | pos[0] = 3; pos[1] = 1;
|
---|
71 | sz[0] = 3; sz[1] = 2;
|
---|
72 | TArray<int_4> ic = ia.SubArray(2, sz, pos);
|
---|
73 | cout << " ----- matrix IC IA(3,2,3,1) = \n " << ic << endl;
|
---|
74 | ic = 0;
|
---|
75 | cout << " ----- matrix IA = \n " << ia << endl;
|
---|
76 | }
|
---|
77 | catch (PThrowable exc) {
|
---|
78 | cerr << " catched Exception " << exc.Msg() << endl;
|
---|
79 | }
|
---|
80 | catch (...) {
|
---|
81 | cerr << " catched unknown (...) exception " << endl;
|
---|
82 | }
|
---|
83 | cout << " --------------- END of Programme -------------- " << endl;
|
---|
84 | }
|
---|