Menu

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

Download this file

78 lines (64 with data), 2.5 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
/*****************************************************************************/
/* 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(5), N(5), KL(2), KU(2);
CPPL::dsymatrix A(N);
CPPL::dgbmatrix X(M,N,KL,KU), Y(M,N,KL,KU), Z(M,N,KL,KU);
A.zero();
for(int i=0; i<X.m; i++){
for(int j=std::max(0l,i-X.kl); j<std::min(X.n,i+X.ku+1); j++){
if(i>=j){
A(i,j) = double( rand() /(RAND_MAX/10) );
X(i,j) =X(j,i) =-A(i,j);
Y(i,j) =Y(j,i) =+A(i,j);
}
}
}
for(int i=0; i<Z.m; i++){
for(int j=std::max(0l,i-Z.kl); j<std::min(Z.n,i+Z.ku+1); 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+dgb
cout << "A+X = (Should be zero)\n" << A+X << endl;
//dsy-dgb
cout << "A-Y = (Should be zero)\n" << A-Y << endl;
//dsy*dgb, t(_dge), t(dgb), _dgb*dsy, _dge-_dge
cout << "t(A*Z)-t(Z)*A = (Should be zero)\n" << t(A*Z)-t(Z)*A << endl;
//dsy+_dgb, -dgb
cout << "A+(-Y) = (Should be zero)\n" << A+(-Y) << endl;
//dsy-_dgb, -dgb
cout << "A-(-X) = (Should be zero)\n" << A-(-X) << endl;
//dsy*_dgb, dgb+dgb, dsy*dgb, _dge+_dge, _dge-_dge
cout << "A*(X+Z) - (A*X+A*Z) = (Should be zero)\n"
<< A*(X+Z) - (A*X+A*Z) << endl;
//_dsy+dgb, -dsy
cout << "(-A)+Y = (Should be zero)\n" << (-A)+Y << endl;
//_dsy-dgb, -dsy
cout << "(-A)-X = (Should be zero)\n" << (-A)-X << endl;
//_dsy*dgb, -dsy, dsy*dgb, _dge+_dge
cout << "(-A)*Z+(A*Z) = (Should be zero)\n" << ((-A)*Z+(A*Z)) << endl;
//_dsy+_dgb, -dsy, -dgb
cout << "(-A)+(-X) = (Should be zero)\n" << (-A)+(-X) << endl;
//_dsy-_dgb, -dsy, -dgb
cout << "(-A)-(-Y) = (Should be zero)\n" << (-A)-(-Y) << endl;
//_dsy*_dgb, -dsy, -dgb, dsy*dgb, _dge-_dge
cout << "(-A)*(-Z)-(A*Z) = (Should be zero)\n" << (-A)*(-Z)-(A*Z) << 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.