Menu

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

Download this file

70 lines (58 with data), 2.4 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
/*****************************************************************************/
/* 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);
CPPL::dgematrix X(N,N), Y(N,N), Z(N,N);
for(int i=0; i<A.n; i++){ for(int j=0; j<=i; j++){
A(i,j) =double( rand() /(RAND_MAX/10) );
}}
for(int i=0; i<A.n; i++){ for(int j=0; j<A.n; j++){
Z(i,j) =double( rand() /(RAND_MAX/10) );
}}
for(int i=0; i<A.n; i++){ for(int j=0; j<A.n; j++){
X(i,j) = -A(i,j);
Y(i,j) = A(i,j);
}}
cout << "A =\n" << A << endl;
cout << "X =\n" << X << endl;
cout << "Y =\n" << Y << endl;
cout << "Z =\n" << Z << endl;
//dsy+dge
cout << "A+X =\n" << A+X << "<-Should be zero." << endl;
//dsy-dge
cout << "A-Y =\n" << A-Y << "<-Should be zero." << endl;
//dsy*dge, t(_dge), t(dge), _dge*dsy, _dge-_dge
cout << "A*Y =\n" << t(A*Y)-t(Y)*A << "<-Should be zero." << endl;
//dsy+_dge, -dge
cout << "A+(-Y) =\n" << A+(-Y) << "<-Should be zero." << endl;
//dsy-_dge, -dge
cout << "A-(-X) =\n" << A-(-X) << "<-Should be zero." << endl;
//dsy*_dge, dge+dge, dsy*dge, _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+dge, -dsy
cout << "(-A)+Y =\n" << (-A)+Y << "<-Should be zero." << endl;
//_dsy-dge, -dsy
cout << "(-A)-X =\n" << (-A)-X << "<-Should be zero." << endl;
//_dsy*dge, -dsy, dsy*dge, _dge+_dge
cout << "(-A)*Z+(A*Z) =\n" << ((-A)*Z+(A*Z)) << "<-Should be zero." << endl;
//_dsy+_dge, -dsy, -dge
cout << "(-A)+(-X) =\n" << (-A)+(-X) << "<-Should be zero." << endl;
//_dsy-_dge, -dsy, -dge
cout << "(-A)-(-Y) =\n" << (-A)-(-Y) << "<-Should be zero." << endl;
//_dsy*_dge, -dsy, -dge, dsy*dge, _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.