BJmatrix.h

Go to the documentation of this file.
00001 // $Revision: 1.1 $                                                              
00002 // $Date: 2001/08/23 16:45:50 $                                                                  
00003 // $Source: /usr/local/cvs/OpenSees/SRC/nDarray/BJmatrix.h,v $                                                                
00004 
00005 //#############################################################################
00006 //                                                                            #
00007 //                                                                            #
00008 //             /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\                #
00009 //            |                                          |____|               #
00010 //            |                                          |                    #
00011 //            |                                          |                    #
00012 //            |                                          |                    #
00013 //            |                                          |                    #
00014 //            |        B A S E   C L A S S E S           |                    #
00015 //            |                                          |                    #
00016 //            |                                          |                    #
00017 //            |                                          |                    #
00018 //            |                                          |                    #
00019 //            |          C + +     H E A D E R           |                    #
00020 //            |                                          |                    #
00021 //            |                                          |                    #
00022 //            |                                          |                    #
00023 //            |                                          |                    #
00024 //         /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/   |                    #
00025 //         \_________________________________________\__/                     #
00026 //                                                                            #
00027 //                                                                            #
00028 //#############################################################################
00029 //#############################################################################
00031 //################################################################################
00032 //# COPYRIGHT (C):     :-))                                                      #
00033 //# PROJECT:           Object Oriented Finite Element Program                    #
00034 //# PURPOSE:                                                                     #
00035 //# CLASS:             BJmatrix                                                    #
00036 //#                                                                              #
00037 //# VERSION:                                                                     #
00038 //# LANGUAGE:          C++.ver >= 2.0 ( Borland C++ ver=3.10, SUN C++ ver=2.1 )  #
00039 //# TARGET OS:         DOS || UNIX || . . .                                      #
00040 //# DESIGNER(S):       Boris Jeremic                                             #
00041 //# PROGRAMMER(S):     Boris Jeremic                                             #
00042 //#                                                                              #
00043 //#                                                                              #
00044 //# DATE:              November '92                                              #
00045 //# UPDATE HISTORY:    05 - 07 avgust '93.  redefined as derived class from      #
00046 //#                                 nDarray class                                #
00047 //#                    january 06 '93  added BJmatrix2tensor_1, BJmatrix2tensor_2    #
00048 //#                    August 22-29 '94 choped to separate files and worked on   #
00049 //#                                   const and & issues                         #
00050 //#                    August 30-31 '94 added use_def_dim to full the CC         #
00051 //#                                   resolved problem with temoraries for       #
00052 //#                                   operators + and - ( +=, -= )               #
00053 //#                                                                              #
00054 //#                                                                              #
00055 //#                                                                              #
00056 //#                                                                              #
00057 //#                                                                              #
00058 //################################################################################
00059 //*/
00060 //
00061 
00062 // MATRIX.hhH: fully functional BJmatrix class based on
00063 // design in chapter 9.   ( Bruce Eckel: " Using C++ " )
00064 // improved a lot by Boris Jeremic
00065 #ifndef MATRIX_HH
00066 #define MATRIX_HH
00067 
00068 #include "nDarray.h"
00069 #include "BJtensor.h"
00070 
00071 //class vector;
00072 
00073 
00074 class BJmatrix : public nDarray
00075   {
00076     friend class BJvector; // explanation why this one should be a friend
00077                          // instead of inheriting all data through protected
00078                          // construct -> see in J. Coplien "Advanced C++ ..."
00079                          // page 96.
00080 
00081 
00082     private:
00083       void error(char *msg1, char *msg2 = ""); // private function
00084 
00085     public:
00086       BJmatrix(int mrows = 1, int columns = 1, double initval = 0.0);
00087       BJmatrix(int mrows, int columns, double *initvalues);
00088  //special for vector
00089       BJmatrix(int rank, int mrows, int columns, double *initvalues);
00090       BJmatrix(int rank, int mrows, int columns, double initvalues);
00091 
00092       BJmatrix(char *flag, int dimension ); // create an ident BJmatrix
00093       BJmatrix(char *matfile); // read from a "standard" BJmatrix file
00094       BJmatrix(char *matfile, char *outfile); // read from a flat BJmatrix file
00095                                             // and write test output to another mat file
00096       BJmatrix(const BJmatrix & x);  // copy-initializer
00097       BJmatrix(const nDarray & x);
00098 
00099 //--      ~BJmatrix( );
00100 
00101       int rows( void ) const;  // rows in BJmatrix
00102       int cols( void ) const;  // cols in BJmatrix
00103 
00104       BJmatrix & operator=(const BJmatrix & rval); // BJmatrix assignment
00105 
00106 // Write a "standard" BJmatrix file:
00107       void write_standard(char *filename, char *msg = "");
00108 
00109 
00110       BJmatrix operator*( BJmatrix &); // BJmatrix multiplication
00111       BJmatrix operator*( double rval); // scalar multiplication
00112 //....      vector operator*( vector &); // vector multiplication
00113 //      vector operator*( double ); // vector multiplication
00114 
00115 //-----//forwarding definition
00116 //-----      virtual vector operator*( double ); // scalar multiplication 
00117 
00118 // this is COUPLING between ordinary BJmatrix and SKYMATRIX
00119 // it will be usefull in multiplying vectors with skyBJmatrix
00120 //####      BJmatrix operator*(const skyBJmatrix & rval);  // BJmatrix/skyBJmatrix multiplication
00121 //####      double & val(int row,  int col); // element selection;
00122 
00123 //####// this one is the same as mval except that it is more convinient
00124 //####// to overload operator (row,col).
00125 //####// THE ROW AND COL COUNTER STARTS FROM 1 ( NOT FROM 0 )
00126 //####      double & operator( )(int row, int col);
00127 // can be used to read or write an element.
00128 
00129       BJmatrix transpose( );       // transpose a square BJmatrix
00130       double determinant( );
00131       BJmatrix inverse( );
00132       double mmin( );            // find minimum element in the BJmatrix
00133       double mmax( );            // find maximum element in the BJmatrix
00134       double mean( );            // average all the elements of the BJmatrix
00135       double sum( );             // sum all the elements in BJmatrix
00136       double variance( );        // statistical variance of all elements
00137 
00138       BJtensor BJmatrix2BJtensor_1( );     // convert BJmatrix back to 4th order BJtensor
00139                                    // I_ijkl scheme
00140       BJtensor BJmatrix2BJtensor_2( );     // convert BJmatrix back to 4th order BJtensor
00141                                    // I_ikjl scheme
00142       BJtensor BJmatrix2BJtensor_22( );  // convert BJmatrix back to 2th order BJtensor
00143 
00144       BJtensor BJmatrix2BJtensor_3( );     // convert BJmatrix back to 4th order BJtensor
00145                                    // I_iljk scheme
00146 
00147 //####
00148 //####// Compress columns and rows
00149 //####      BJmatrix compress_col(int col1, int col2, int to_col);
00150 //####      BJmatrix compress_row(int row1, int row2, int to_row);
00151 //####
00152 
00153     private: // functions used by inverse() and determinant()
00154       void switch_columns(int col1, int co12);
00155       void copy_column(BJmatrix & m, int from_col, int to_col);
00156       BJmatrix scale( ); // scale a BJmatrix (used in L-U decomposition)
00157       void deepcopy(BJmatrix & from, BJmatrix & to); // make an image
00158       BJmatrix lu_decompose(BJmatrix & indx, int & d );
00159            // Returns the L-U decomposition of a BJmatrix
00160       void lu_back_subst(BJmatrix & indx, BJmatrix & b);
00161            // Uses L-U decomposition for BJmatrix inverse
00162 
00163       double & mval (int row, int col);  // I am still keeping mval
00164                                          // operator for compatibility
00165                                          // with old BJmatrix class members
00166                                          // and they start from 0 ###
00167           // used by BJmatrix functions which KNOW they aren't
00168           // exceeding the boundaries
00169 
00170                  public:
00171 // Tiejun Li Jan 2000
00172      double *  BJmatrixtoarray(int &);
00173  
00174 
00175 // // prebacen u nDarray 14 oktobra 1996
00176 //     public:
00177 //       BJvector eigenvalues(void);
00178 //       BJmatrix eigenvectors(void);
00179 
00180 // // from Numerical recipes in C
00181 //     private:
00182 //       void tqli(double * d, double * e, int n, double ** z);
00183 //       void tred2(double ** a, int n, double * d, double * e);
00184 //       void eigsrt(double * d, double ** v, int n);
00185           
00186 };
00187 #endif 

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