XC Open source finite element analysis program
BJmatrix.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 // $Revision: 1.1 $
28 // $Date: 2001/08/23 16:45:50 $
29 // $Source: /usr/local/cvs/OpenSees/SRC/nDarray/BJmatrix.h,v $
30 
31 //#############################################################################
32 // #
33 // #
34 // /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\ #
35 // | |____| #
36 // | | #
37 // | | #
38 // | | #
39 // | | #
40 // | B A S E C L A S S E S | #
41 // | | #
42 // | | #
43 // | | #
44 // | | #
45 // | C + + H E A D E R | #
46 // | | #
47 // | | #
48 // | | #
49 // | | #
50 // /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ | #
51 // \_________________________________________\__/ #
52 // #
53 // #
54 //#############################################################################
55 //#############################################################################
57 //################################################################################
58 //# COPYRIGHT (C): :-)) #
59 //# PROJECT: Object Oriented Finite Element Program #
60 //# PURPOSE: #
61 //# CLASS: BJmatrix #
62 //# #
63 //# VERSION: #
64 //# LANGUAGE: C++.ver >= 2.0 ( Borland C++ ver=3.10, SUN C++ ver=2.1 ) #
65 //# TARGET OS: DOS || UNIX || . . . #
66 //# DESIGNER(S): Boris Jeremic #
67 //# PROGRAMMER(S): Boris Jeremic #
68 //# #
69 //# #
70 //# DATE: November '92 #
71 //# UPDATE HISTORY: 05 - 07 avgust '93. redefined as derived class from #
72 //# nDarray class #
73 //# january 06 '93 added BJmatrix2tensor_1, BJmatrix2tensor_2 #
74 //# August 22-29 '94 choped to separate files and worked on #
75 //# const and & issues #
76 //# August 30-31 '94 added use_def_dim to full the CC #
77 //# resolved problem with temoraries for #
78 //# operators + and - ( +=, -= ) #
79 //# #
80 //# #
81 //# #
82 //# #
83 //# #
84 //################################################################################
85 //*/
86 //
87 
88 // MATRIX.hhH: fully functional BJmatrix class based on
89 // design in chapter 9. ( Bruce Eckel: " Using C++ " )
90 // improved a lot by Boris Jeremic
91 #ifndef MATRIX_HH
92 #define MATRIX_HH
93 
94 #include "utility/matrix/nDarray/nDarray.h"
95 
96 //class vector;
97 
98 
99 namespace XC {
101 //
102 class BJmatrix : public nDarray
103  {
104  friend class BJvector; // explanation why this one should be a friend
105  // instead of inheriting all data through protected
106  // construct -> see in J. Coplien "Advanced C++ ..."
107  // page 96.
108 
109 
110  private:
111  void error(const std::string &msg1,const std::string &msg2 = ""); // private function
112 
113  public:
114  BJmatrix(int mrows = 1, int columns = 1, double initval = 0.0);
115  BJmatrix(int mrows, int columns, double *initvalues);
116  //special for vector
117  BJmatrix(int rank, int mrows, int columns, double *initvalues);
118  BJmatrix(int rank, int mrows, int columns, double initvalues);
119 
120  BJmatrix(const std::string &flag, int dimension ); // create an ident BJmatrix
121  BJmatrix(const std::string &matfile); // read from a "standard" BJmatrix file
122  BJmatrix(const std::string &matfile,const std::string &outfile); // read from a flat BJmatrix file
123  // and write test output to another mat file
124  BJmatrix(const BJmatrix &x); // copy-initializer
125  explicit BJmatrix(const nDarray &x);
126 
127 //-- ~BJmatrix( );
128 
129  int rows( void ) const; // rows in BJmatrix
130  int cols( void ) const; // cols in BJmatrix
131 
132  BJmatrix & operator=(const BJmatrix & rval); // BJmatrix assignment
133 
134 // Write a "standard" BJmatrix file:
135  void write_standard(const std::string &filename,const std::string &msg = "");
136 
137 
138  BJmatrix operator*( BJmatrix &); // BJmatrix multiplication
139  BJmatrix operator*( double rval); // scalar multiplication
140 //.... vector operator*( vector &); // vector multiplication
141 // vector operator*( double ); // vector multiplication
142 
143 //-----//forwarding definition
144 //----- virtual vector operator*( double ); // scalar multiplication
145 
146 // this is COUPLING between ordinary BJmatrix and SKYMATRIX
147 // it will be usefull in multiplying vectors with skyBJmatrix
148 //#### BJmatrix operator*(const skyBJmatrix & rval); // BJutility/matrix/skyBJmatrix multiplication
149 //#### double & val(int row, int col); // element selection;
150 
151 //####// this one is the same as mval except that it is more convinient
152 //####// to overload operator (row,col).
153 //####// THE ROW AND COL COUNTER STARTS FROM 1 ( NOT FROM 0 )
154 //#### double & operator( )(int row, int col);
155 // can be used to read or write an element.
156 
157  BJmatrix transpose( ); // transpose a square BJmatrix
158  double determinant( );
159  BJmatrix inverse( );
160  double mmin( ); // find minimum element in the BJmatrix
161  double mmax( ); // find maximum element in the BJmatrix
162  double mean( ); // average all the elements of the BJmatrix
163  double sum( ); // sum all the elements in BJmatrix
164  double variance( ); // statistical variance of all elements
165 
166  BJtensor BJmatrix2BJtensor_1( ); // convert BJmatrix back to 4th order BJtensor
167  // I_ijkl scheme
168  BJtensor BJmatrix2BJtensor_2( ); // convert BJmatrix back to 4th order BJtensor
169  // I_ikjl scheme
170  BJtensor BJmatrix2BJtensor_22( ); // convert BJmatrix back to 2th order BJtensor
171 
172  BJtensor BJmatrix2BJtensor_3( ); // convert BJmatrix back to 4th order BJtensor
173  // I_iljk scheme
174 
175 //####
176 //####// Compress columns and rows
177 //#### BJmatrix compress_col(int col1, int col2, int to_col);
178 //#### BJmatrix compress_row(int row1, int row2, int to_row);
179 //####
180 
181  private: // functions used by inverse() and determinant()
182  void switch_columns(int col1, int co12);
183  void copy_column(BJmatrix & m, int from_col, int to_col);
184  BJmatrix scale( ); // scale a BJmatrix (used in L-U decomposition)
185  void deepcopy(BJmatrix & from, BJmatrix & to); // make an image
186  BJmatrix lu_decompose(BJmatrix & indx, int & d );
187  // Returns the L-U decomposition of a BJmatrix
188  void lu_back_subst(BJmatrix & indx, BJmatrix & b);
189  // Uses L-U decomposition for BJmatrix inverse
190 
191  double & mval (int row, int col); // I am still keeping mval
192  // operator for compatibility
193  // with old BJmatrix class members
194  // and they start from 0 ###
195  // used by BJmatrix functions which KNOW they aren't
196  // exceeding the boundaries
197 
198  public:
199 // Tiejun Li Jan 2000
200  double *BJmatrixtoarray(int &);
201 
202 
203 // // prebacen u nDarray 14 oktobra 1996
204 // public:
205 // BJvector eigenvalues(void);
206 // BJmatrix eigenvectors(void);
207 
208 // // from Numerical recipes in C
209 // private:
210 // void tqli(double * d, double * e, int n, double ** z);
211 // void tred2(double ** a, int n, double * d, double * e);
212 // void eigsrt(double * d, double ** v, int n);
213 
214 };
215 } // end of XC namespace
216 #endif
Definition: BJtensor.h:110
Definition: BJvector.h:100
Definition: BJmatrix.h:102
================================================================================
Definition: ContinuaReprComponent.h:34
Definition: nDarray.h:158