Menu

[r31]: / trunk / test / dsymatrix / dsymatrix-dsymatrix / main.cpp  Maximize  Restore  History

Download this file

80 lines (66 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*****************************************************************************/
/* noname */
/*****************************************************************************/
//====================================================================[include]
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "cpplapack.h"
using namespace std;
//=======================================================================[main]
/*! main */
int main(int argc, char** argv)
{
srand(time(NULL));
int N(3);
CPPL::dsymatrix A(N), X(N), Y(N), Z(N);
for(int i=0; i<A.n; i++){ for(int j=0; j<=i; j++){
A(i,j) =double( rand() /(RAND_MAX/10) );
X(i,j) = -A(i,j);
Y(i,j) = A(i,j);
Z(i,j) =double( rand() /(RAND_MAX/10) );
}}
cout << "A =\n" << A << endl;
cout << "X =\n" << X << endl;
cout << "Y =\n" << Y << endl;
cout << "Z =\n" << Z << endl;
//dsy+dsy
cout << "A+X =\n" << A+X << "<-Should be zero." << endl;
//dsy-dsy
cout << "A-Y =\n" << A-Y << "<-Should be zero." << endl;
//dsy*dsy
cout << "t(A*Z)-Z*A =\n" << t(A*Z)-Z*A << "<-Should be zero." << endl;
//dsy=dsy, dsy-dsy
CPPL::dsymatrix B;
cout << "(B=A)-A =\n" << (B=A)-A << "<-Should be zero." << endl;
//dsy+=dsy
cout << "(B+=Z) =\n" << (B+=Z) << endl;
//dsy-=dsy
cout << "(B-=A) =\n" << (B-=A) << endl;
//dsy+_dsy, -dsy
cout << "A+(-Y) =\n" << A+(-Y) << "<-Should be zero." << endl;
//dsy-_dsy, -dsy
cout << "A-(-X) =\n" << A-(-X) << "<-Should be zero." << endl;
//dsy*_dsy, dsy+dsy, dsy*dsy, _dge+_dge, _dge-_dge
cout << "A*(X+Z) - (A*X+A*Z) =\n" << A*(X+Z) - (A*X+A*Z) << "<-Should be zero." << endl;
//dsy=_dsy
cout << "(B=-A)+A =\n" << (B=-A)+A << "<-Should be zero." << endl;
//dsy+=_dsy
cout << "(B+=-Z) =\n" << (B+=-Z) << endl;
//dsy-=_dsy
cout << "(B-=-A) =\n" << (B-=-A) << endl;
//_dsy+dsy, -dsy
cout << "(-A)+Y =\n" << (-A)+Y << "<-Should be zero." << endl;
//_dsy-dsy, -dsy
cout << "(-A)-X =\n" << (-A)-X << "<-Should be zero." << endl;
//_dsy*dsy, -dsy, dsy*dsy, _dge+_dge
cout << "(-A)*Z+(A*Z) =\n" << ((-A)*Z+(A*Z)) << "<-Should be zero." << endl;
//_dsy+_dsy, -dsy, -dsy
cout << "(-A)+(-X) =\n" << (-A)+(-X) << "<-Should be zero." << endl;
//_dsy-_dsy, -dsy, -dsy
cout << "(-A)-(-Y) =\n" << (-A)-(-Y) << "<-Should be zero." << endl;
//_dsy*_dsy, -dsy, -dsy, dsy*dsy, _dge-_dge
cout << "(-A)*(-Z)-(A*Z) =\n" << (-A)*(-Z)-(A*Z) << "<-Should be zero." << endl;
return 0;
}
/*****************************************************************************/
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.