Menu

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

Download this file

134 lines (118 with data), 3.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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*****************************************************************************/
/* noname */
/*****************************************************************************/
//=============================================================================
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "cpplapack.h"
using namespace std;
//=============================================================================
/*! main */
int main(int argc, char** argv)
{
srand(unsigned(time(NULL)));
int M(4), N(3);
CPPL::dsymatrix A(N), B(N);
CPPL::dgematrix X(N,N), Y(N,N), Z(N,N), G(M,N);
for(int i=0; i<A.n; i++){
for(int j=0; j<A.n; j++){
A(i,j) =double( rand() /(RAND_MAX/10) );
B(i,j) =double( rand() /(RAND_MAX/10) );
Z(i,j) =double( rand() /(RAND_MAX/10) );
}
}
for(int i=0; i<G.m; i++){
for(int j=0; j<G.n; j++){
G(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 << "B =\n" << B << endl;
cout << "X =\n" << X << endl;
cout << "Y =\n" << Y << endl;
cout << "Z =\n" << Z << endl;
cout << "G =\n" << G << endl;
//dge+dsy
cout << "X+A =\n" << X+A << "<-Should be zero." << endl;
//dge-dsy
cout << "Y-A =\n" << Y-A << "<-Should be zero." << endl;
//dge*dsy, t(_dge), t(dge), dsy*_dge, _dge-_dge
cout << "t(Y*A)-A*t(Y) =\n" << t(Y*A)-A*t(Y) << "<-Should be zero." << endl;
cout << "G*A-G*Y =\n" << G*A-G*Y << "<-Should be zero." << endl;
//dge/dsy
//N/A
//dge-dsy
CPPL::dgematrix W;
W =A.to_dgematrix();
cout << "W-A =\n" << W-A << "<-Should be zero." << endl;
//dge+=dsy
cout << "W+=A =\n" << (W+=A) << endl;
//dge-=dsy
cout << "W-=B =\n" << (W-=B) << endl;
//dge*=dsy, double*dsy, _dsy-dsy, _dsy*dsy, dge-_dsy
cout << "(W*=B)-((2*A-B)*B) =\n" << (W*=B)-((2*A-B)*B) << "<-Should be zero" << endl;
//N/A
//dge/=dsy
//N/A
//dge+_dsy, -dsy
cout << "Y+(-A) =\n" << Y+(-A) << "<-Should be zero." << endl;
//dge-_dsy, -dsy
cout << "X-(-A) =\n" << X-(-A) << "<-Should be zero." << endl;
//dge*_dsy, dge*dsy, _dge-_dge
cout << "X*(A+B) - X*A - X*B =\n" << X*(A+B) - X*A - X*B << "<-Should be zero." << endl;
//dge/_dsy
//N/A
//dge+=_dsy, -dsy
cout << "W+=-A =\n" << (W+=-A) << endl;
//dge-=_dsy, dsy+dsy
cout << "W-=(A+B) =\n" << (W-=(A+B)) << endl;
//dge*=_dsy, dsy*dsy, dge+_dge
cout << "(W*=B)+A*B =\n" << (W*=B)+A*B << "<-Should be zero" << endl;
//dge/=_dsy
//N/A
//_dge+dsy
cout << "(-Y)+A =\n" << (-Y)+A << "<-Should be zero." << endl;
//_dge-dsy, -dge
cout << "(-X)-A =\n" << (-X)-A << "<-Should be zero." << endl;
//_dge*dsy, -dge, dge*dsy, _dge+_dge
cout << "(-Z)*A+(Z*A) =\n" << (-Z)*A+(Z*A) << "<-Should be zero." << endl;
//_dge/dsy
//N/A
//_dge=dsy
//N/A
//_dge+=dsy
//N/A
//_dge-=dsy
//N/A
//_dge*=dsy
//N/A
//_dge/=dsy
//N/A
//_dge+_dsy, -dge, -dsy
cout << "(-X)+(-A) =\n" << (-X)+(-A) << "<-Should be zero." << endl;
//_dge-_dsy, -dge, -dsy
cout << "(-Y)-(-A) =\n" << (-Y)-(-A) << "<-Should be zero." << endl;
//_dge*_dsy, -dge, -dsy, dge*dsy, _dge-_dge
cout << "(-Z)*(-A)-(Z*A) =\n" << (-Z)*(-A)-(Z*A) << "<-Should be zero." << endl;
//_dge/_dsy
//N/A
//_dge=_dsy
//N/A
//_dge+=_dsy
//N/A
//_dge-=_dsy
//N/A
//_dge*=_dsy
//N/A
//_dge/=_dsy
//N/A
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.