Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

matrixbk_test.cc

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999-2003 Bert Kampes
00003  * Copyright (c) 1999-2003 Delft University of Technology, The Netherlands
00004  *
00005  * This file is part of Doris, the Delft o-o radar interferometric software.
00006  *
00007  * Doris program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * Doris is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * Publications that contain results produced by the Doris software should
00022  * contain an acknowledgment. (For example: The interferometric processing
00023  * was performed using the freely available Doris software package developed
00024  * by the Delft Institute for Earth-Oriented Space Research (DEOS), Delft
00025  * University of Technology, or include a reference to: Bert Kampes and
00026  * Stefania Usai. \"Doris: The Delft Object-oriented Radar Interferometric
00027  * software.\" In: proceedings 2nd ITC ORS symposium, August 1999. (cdrom)).
00028  *
00029  */
00030 /****************************************************************
00031  * $Source: /users/kampes/DEVELOP/DORIS/doris/src/RCS/matrixbk_test.cc,v $      *
00032  * $Revision: 3.8 $                                             *
00033  * $Date: 2005/03/07 10:38:40 $                                 *
00034  * $Author: kampes $                                            *
00035  *                                                              *
00036  * Test program for matrix class.                               *
00037  * Compile with Doris Makefile.                                 *
00038  #%// BK 17-Aug-2000                                            *
00039  ****************************************************************/
00040 
00041 
00042 #include "constants.hh"                 // typedefs
00043 #include "matrixbk.hh"                  // matrix functions
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 // ______ used in matrix_bk.cc to keep track of total allocated ______
00053 uint totalallocated=0;  // [B] matrixdebuging
00054 
00055 
00056 
00057 
00058 
00059 /****************************************************************
00060  *    main                                                      *
00061  #%// BK 17-Aug-2000                                            *
00062  ****************************************************************/
00063 int32 main(
00064         int argc,
00065         char* argv[])
00066   {
00067   const int L = 4;      // numlines A
00068   const int P = 2;      // numcols  A
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   // ______ Show matrices for testing ______
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   // ______ Test - ______
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   // ______ Test * ______
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   // ______ Test 1d fft ______
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 //    // ______ Test operator = ______
00111 //    for (i=0; i<10; ++i)
00112 //      {
00113 //      cout << i << ": A=B\n";
00114 //      A=B;
00115 //      cout << i << ": B=B\n";
00116 //      B=B;
00117 //      cout << i << ": C=A\n";
00118 //      matrix<complr4> C=A;
00119 //      cout << "\n";
00120 //      }
00121 
00122   // ______ Test find function ______
00123   // matrix<int32> indexNaN = A.find(2);
00124 
00125   // ______ Test mypow function ______
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 // ?? but does B*= A^C work?
00136 // ?? but does B*= A.mypow(C) work?
00137 
00138   // ______ Test CR4*R4 function ______
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   // ______ Test smooth function ______
00150   // R.smooth(1);
00151   // ______ Test pow ^ operator ______
00152   // R = R^2.0;
00153 
00154   // ______ Test wshift function ______
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   // ______ Test diagxmat R4*CR4 ______
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   // ______ Test cos/sin complr4 operator ______
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);  // rad
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   } // END main
00204 

Generated on Fri Apr 22 15:57:55 2005 for Doris by doxygen 1.3.6