00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "constants.hh"
00043 #include "matrixbk.hh"
00044 bk_messages TRACE;
00045 bk_messages DEBUG;
00046 bk_messages INFO;
00047 bk_messages PROGRESS;
00048 bk_messages WARNING;
00049 bk_messages ERROR;
00050 bk_messages matDEBUG;
00051 bk_messages matERROR;
00052
00053 uint totalallocated=0;
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 int32 main(
00064 int argc,
00065 char* argv[])
00066 {
00067 const int L = 4;
00068 const int P = 2;
00069 int i,j;
00070
00071 matrix<complr4> A(L,P);
00072 matrix<complr4> B(P,L+1);
00073 for (i=0; i<A.lines(); ++i)
00074 for (j=0; j<A.pixels(); ++j)
00075 A(i,j) = complr4(float(i)/2.3+j,float(j)/2+i);
00076 for (i=0; i<B.lines(); ++i)
00077 for (j=0; j<B.pixels(); ++j)
00078 B(i,j) = complr4(float(j+i)/2.3+i,float(i)/(2.2+i-j*j));
00079
00080
00081 cout << "matrix A(" << A.lines() << "," << A.pixels() << "):\n";
00082 A.showdata();
00083 cout << "matrix B(" << B.lines() << "," << B.pixels() << "):\n";
00084 B.showdata();
00085 cout << "\n\n---------------------\n\n";
00086
00087
00088 B = complr4(2.) * -B;
00089 cout << "matrix 2*-B(" << B.lines() << "," << B.pixels() << "):\n";
00090 B.showdata();
00091 cout << "\n\n---------------------\n\n";
00092
00093 matrix<complr4> Bconj = conj(B);
00094 cout << "conjugated:\n";
00095 Bconj.showdata();
00096 cout << "\n\n---------------------\n\n";
00097
00098
00099 matrix<complr4> C = A*B;
00100 cout << "matrix C(" << C.lines() << "," << C.pixels() << ") = A*B\n";
00101 C.showdata();
00102 cout << "\n\n---------------------\n\n";
00103
00104
00105 fft(A,1);
00106 cout << "1d fft over columns of matrix A(" << A.lines() << "," << A.pixels() << "):\n";
00107 A.showdata();
00108 cout << "\n\n---------------------\n\n";
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 matrix<float> R(L,P);
00127 for (i=0; i<R.lines(); ++i)
00128 for (j=0; j<R.pixels(); ++j)
00129 R(i,j) = float(i/2.3+j*i*j);
00130
00131 cout << "\n\n-RRRRRRRRRRRRRRRRRRR-\n\n";
00132 R.showdata();
00133 R.mypow(1.5);
00134 R.showdata();
00135
00136
00137
00138
00139 cout << "\n\n-RRRRRRRRRRRRRRRRRRR-\n\n";
00140 matrix<complr4> Q(L,P);
00141 for (i=0; i<Q.lines(); ++i)
00142 for (j=0; j<Q.pixels(); ++j)
00143 Q(i,j) = complr4(float(i)/2.3+j,float(j)/2+i);
00144 Q.showdata();
00145 R.showdata();
00146 Q*=R;
00147 Q.showdata();
00148
00149
00150
00151
00152
00153
00154
00155 matrix<real4> AA(1,7);
00156 for (i=0; i<AA.lines(); ++i)
00157 for (j=0; j<AA.pixels(); ++j)
00158 AA(i,j) = i+j;
00159 AA.showdata();
00160 cout << "wshift AA, -2\n";
00161 wshift(AA,-2);
00162 AA.showdata();
00163
00164
00165 matrix<complr4> QQ(7,7);
00166 for (i=0; i<QQ.lines(); ++i)
00167 for (j=0; j<QQ.pixels(); ++j)
00168 QQ(i,j) = complr4(float(i)/2.3+j,float(j)/2+i);
00169 QQ.showdata();
00170 matrix<complr4> BB = diagxmat(AA,QQ);
00171 cout << "BB=diagxmat(AA,QQ)\n";
00172 BB.showdata();
00173
00174
00175 cout << "VVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n";
00176 matrix<real8> r8A(3,5);
00177 r8A = 5.3;
00178 cout << "r8A=5.3:\n";
00179 r8A.showdata();
00180
00181 for (i=0; i<r8A.lines(); ++i)
00182 for (j=0; j<r8A.pixels(); ++j)
00183 r8A(i,j) = (3.14/180.0)*((0.5+i-j)*100);
00184 cout << "r8A=radians:\n";
00185 r8A.showdata();
00186 matrix<real8> cosr8A = cos(r8A);
00187 cout << "\ncosr8A:\n";
00188 cosr8A.showdata();
00189
00190 matrix<real8> r8B = r8A+0.2;
00191 matrix<real8> sinr8B = sin(r8B);
00192 cout << "\nsinr8B:\n";
00193 sinr8B.showdata();
00194
00195 matrix<complr4> cr4AB = mat2cr4(r8A,r8B);
00196 cout << "\ncomplr4(r8A,r8B):\n";
00197 cr4AB.showdata();
00198
00199
00200
00201 cout << "\n\nNormal termination.\n\n";
00202 return 0;
00203 }
00204