main.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.3 $
00022 // $Date: 2005/12/14 23:49:48 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/matrix/main.cpp,v $
00024                                                                         
00025                                                                         
00026 #include "Vector.h"
00027 #include "ID.h"
00028 #include "Matrix.h"
00029 #include <OPS_Globals.h>
00030 #include <ConsoleErrorHandler.h>
00031 #include <StandardStream.h>
00032 
00033 StandardStream sserr;
00034 OPS_Stream *opserrPtr = &sserr;
00035 
00036 int main()
00037 {
00038 
00039   ID data(0);
00040 
00041   opserr << data << endln;
00042   opserr << data.insert(1) << endln;
00043   opserr << data << endln;
00044   opserr << data.insert(2) << endln;
00045   opserr << data << endln;
00046   opserr << data.insert(4) << endln;
00047   opserr << data << endln;
00048   opserr << data.insert(5) << endln;
00049   opserr << data << endln;
00050   opserr << data.insert(6) << endln;
00051   opserr << data << endln;
00052   opserr << data.insert(3) << endln;
00053   opserr << data << endln;
00054   opserr << data.insert(-1) << endln;
00055   opserr << data << endln;
00056 
00057   opserr << data.insert(3) << endln;
00058   opserr << data << endln;
00059   exit(0);
00060 
00061   opserr.setPrecision(14);
00062   opserr.setFloatField(SCIENTIFIC);
00063 
00064   Matrix a(3,3);
00065   a(0,0)= 1.35691200000000e+08; a(0,1)= 1.49035621973463e+07; a(0,2) =  -3.72529029846191e-09;
00066   a(1,0) = 1.49035621973463e+07; a(1,1)= 1.63692388430620e+06; a(1,2)= -4.65661287307739e-10;
00067   a(2,0) =-3.72529029846191e-09; a(2,1)=  -4.65661287307739e-10; a(2,2)= 3.19209024960000e+07;
00068 
00069   opserr << a;
00070 
00071   Matrix b(3,3);
00072 
00073   a.Invert(b);
00074   opserr << b;
00075 
00076   opserr << a*b;
00077 
00078   Matrix I(3,3);
00079   for (int i=0; i<3; i++)
00080     I(i,i) = 1.0;
00081 
00082   opserr << a.Solve(I,b);
00083   
00084   opserr << b;
00085   opserr << a*b;
00086   opserr << I;
00087 
00088   /*
00089     // Vector  TEST
00090     cout << "\n***** Vector TEST *****  \n";
00091     Vector a;
00092     cout << "Vector a;     a -> " << a;
00093     Vector b(5);
00094     cout << "Vector b(5);  b -> " << b;    
00095     Vector c(b);
00096     cout << "Vector c(b);  c -> " << c;        
00097     Vector d = a;
00098     cout << "Vector d = a; d -> " << d;        
00099     d = c;
00100     cout << "       d = c; d -> " << d;            
00101     d+=5.0;
00102     cout << "       d +=5.0; d -> " << d;                
00103     cout << "                c -> " << c;
00104     d-=3.0;
00105     cout << "       d -=3.0; d -> " << d;                    
00106     d*=6.0;
00107     cout << "       d *=6.0; d -> " << d;                    
00108     d/=4.0;
00109     cout << "       d /=4.0; d -> " << d;                        
00110     c = d + 2;
00111     cout << "     c = d + 2; c -> " << c;                            
00112     cout << "                d -> " << d;
00113 
00114     c = c * 2;
00115     cout << "     c = c * 2; c -> " << c;                            
00116     c = c - 2;
00117     cout << "     c = c - 2; c -> " << c;                            
00118     c = c / 2;
00119     cout << "     c = c / 2; c -> " << c;                            
00120     double x = c^c;
00121     cout << "double x = c^c; x -> " << x << "\n";
00122     x = c^d;
00123     cout << "       x = c^d; x -> " << x << "\n";                                
00124     a = c * (c^d);
00125     cout << "   a = c*(c^d); a -> " << a;
00126 
00127     cout << "\n\n\n***** ID TEST ***** \n";         
00128     ID id1(2);
00129     cout << "     ID id1(2): id1 -> " << id1;
00130     ID id2(3);
00131     cout << "     ID id2(3): id2 -> " << id2;    
00132 
00133     id2(0) = 2; id2(1) = 0; id2(2) = 3;
00134     cout << "      revised : id2 -> " << id2;        
00135     Vector y(5); y(0) = 1.0; y(1) = 2.0; y(2) = 3.0; y(3) = 4.0; y(4) = 5.0;
00136     cout << "              : y ->   " << y;
00137     
00138     Vector z = y(id2);
00139     cout << "Vector &z=y(id2): z ->   " << z;
00140 
00141   */
00142 
00143   /*
00144     Matrix ZA = A(id2,id2);
00145     cout << "Matrix &ZA=A(id2,id2): ZA -> " << ZA;
00146     Matrix &ZB = A(id1,id2);
00147     cout << "Matrix &ZB=A(id1,id2): ZB -> " << ZB;    
00148     ZB = A(id2,id1);
00149     cout << "        ZB=A(id2,id1): ZB -> " << ZB;    
00150     ZB = A(id1,id1);
00151     cout << "        ZB=A(id1,id1): ZB -> " << ZB;        
00152     */
00153 
00154   /*
00155     cout << "\n\n\n***** Matrix TEST ***** \n";         
00156     Matrix A(2,2);
00157     cout << "      Matrix A; A -> " << A;
00158     Matrix B(3,2);
00159     cout << " Matrix B(3,2); B -> " << B;    
00160     Matrix C(B);
00161     cout << "   Matrix C(B); C -> " << C;        
00162     
00163     C+=2.0;
00164     cout << "       C +=2.0; C -> " << C;
00165     C*=6.0;
00166     cout << "       C *=6.0; C -> " << C;
00167     C/=4.0;
00168     cout << "       C /=4.0; C -> " << C;
00169     C-=1.0;
00170     cout << "       C -=1.0; C -> " << C;
00171     B = C *2.0;
00172     cout << "     B = C*2.0; B -> " << B;    
00173     B = C /2.0;
00174     cout << "     B = C/2.0; B -> " << B;    
00175     B = C -2.0;
00176     cout << "     B = C-2.0; B -> " << B;    
00177     B = C +2.0;
00178     cout << "     B = C+2.0; B -> " << B;    
00179     A = C^B;
00180     cout << "       A = C^B; A -> " << A;        
00181     A(1,1) += 6;
00182     cout << "     A(1,1)+=6; A -> " << A;            
00183     
00184     Vector e(2); e(0) = 72; e(1) = 84;
00185     cout << "                e -> " << e;
00186     //    a = e / A;
00187     //    cout << "      a= e / A: a -> " << a;
00188     cout << "                A -> " << A;
00189     
00190     Matrix E(2,5);
00191     E += 2.0;
00192     E(1,3) = 5.0;
00193     cout << "               E -> " << E;
00194 
00195     cout << " A * E -> " << A*E;
00196 
00197     Matrix G(2,5);
00198     cout << " G -> " << G;
00199     G.addMatrixProduct(1.0,A,E,-1.0);
00200     cout << " G.addMatrixProduct(A,E,-1.0) -> " << G;
00201     G.addMatrixProduct(1.0,A,E,-1.0);
00202     cout << " G.addMatrixProduct(A,E,-1.0) -> " << G;
00203 
00204     Matrix F(5,5);
00205     F = E^A*E;
00206     cout << "    F = E^A*E: F -> " << F;    
00207 
00208     F.addMatrixTripleProduct(0.0,E,A,1.0);
00209     cout << "    F.addMatrixTripleProduct(0.0,E,A,1.0): F -> " << F;    
00210     F.addMatrixTripleProduct(1.0,E,A,1.0);
00211     cout << "    F.addMatrixTripleProduct(E,A,1.0): F -> " << F;    
00212 
00213     Matrix AA(2,2); AA(0,0) = 1; AA(0,1) = 2; AA(1,0) = 4; AA(1,1) = 9;
00214     Vector b(2), x(2); b(0) = 1; b(1) = 2;
00215 
00216     opserr << " AA -> " << AA;
00217     opserr << "  b -> " << b;
00218 
00219     AA.Solve(b,x);
00220 
00221     opserr << "AA.solve(b,x) x-> " << x;
00222     opserr << "AA * x -> " << AA*x;
00223 
00224 
00225 
00226     Matrix bb(2,3); bb(0,0) = 1; bb(1,0) = 2;
00227     bb(0,1) = 2; bb(1,1) = 4;
00228     bb(0,2) = 11; bb(1,2) = 12;
00229     Matrix xx(2,3);
00230 
00231     opserr << " AA -> " << AA;
00232     opserr << " bb -> " << bb;
00233 
00234     AA.Solve(bb,xx);
00235 
00236     opserr << "AA.solve(bb,xx) xx-> " << xx;
00237     opserr << "AA * xx -> " << AA*xx;
00238   */
00239 }
00240 
00241 
00242 

Generated on Mon Oct 23 15:05:00 2006 for OpenSees by doxygen 1.5.0