skymatr.cppGo to the documentation of this file.00001 //############################################################################ 00002 //# # 00003 //# /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\ # 00004 //# | |____| # 00005 //# | | # 00006 //# | | # 00007 //# | B A S E | # 00008 //# | | # 00009 //# | | # 00010 //# | C L A S S E S | # 00011 //# | | # 00012 //# | | # 00013 //# | C + + S O U R C E | # 00014 //# | | # 00015 //# | | # 00016 //# | | # 00017 //# | | # 00018 //# | | # 00019 //# /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ | # 00020 //# | | | # 00021 //# \_________________________________________\__/ # 00022 //# # 00023 //# # 00024 //############################################################################ 00025 // 00026 // "C makes it easy to shoot yourself in the foot, C++ makes it harder, 00027 // but when you do, it blows away your whole leg" -- Bjarne Stroustrup 00028 // 00029 //############################################################################## 00030 //# COPY-YES (C): :-)) # 00031 //# PROJECT: Object Oriented Finite Element Program # 00032 //# PURPOSE: # 00033 //# CLASS: skymatrix class # 00034 //# # 00035 //# VERSION: # 00036 //# LANGUAGE: C++.ver >= 2.0 ( Borland C++ ver=3.00, SUN C++ ver=2.1 )# 00037 //# TARGET OS: DOS || UNIX || . . . # 00038 //# PROGRAMMER(S): Boris Jeremic ( with parts of fortran COLSOL which # 00039 //# is ported to C++ by BJ # 00040 //# # 00041 //# DATE: Nov. 12. 1992. # 00042 //# UPDATE HISTORY: Nov. 14. 1992. Improved operator= # 00043 //# Nov. 16. 1992. More print options ( upper, lower, full)# 00044 //# ___. __. 199_. derived class from nDarray class # 00045 //# August 22-29 '94 choped to separate files and worked on # 00046 //# const and & issues # 00047 //# August 30-31 '94 added use_def_dim to full the CC # 00048 //# resolved problem with temoraries for # 00049 //# operators + and - ( +=, -= ) # 00050 //# # 00051 //# September 09 '94 starting to rewrite things after a talk# 00052 //# by Stephen Jonson " Objecting the Objects". The point is# 00053 //# to forget about inheriting skymatrix from nDarray and # 00054 //# start from separate branch! # 00055 //# September 11 '94 it works # 00056 //# September 12-13 '94 looking for the solver for symmetric# 00057 //# and unsymmetric sparse matrices. # 00058 //# One solution is Taylor's profile # 00059 //# solver ( see FEM4ed by O.Z. and R.T.# 00060 //# September 27 '94 profile solver for symmetric and # 00061 //# Nonsymmetric systems works! # 00062 //# (from FEM4ed by O.Z. and R.T.) # 00063 //# # 00064 //############################################################################## 00065 #ifndef SKYMATRIX_CC 00066 #define SKYMATRIX_CC 00067 00068 #include "skymatr.h" 00069 00070 // SYMSKYMATRIX.CC Symmetric Skyline Sparse Matrix Class 00071 00072 00073 00074 //.. //########################################################################## 00075 //.. // empty constructor ( with default values ) 00076 //.. skymatrix::skymatrix( int matrix_order, double init_val) 00077 //.. { 00078 //.. // create the structure: 00079 //.. pc_skymatrix_rep = new skymatrix_rep; // this 'new' is overloaded 00080 //.. 00081 //.. 00082 //.. pc_skymatrix_rep->square_dim = matrix_order; 00083 //.. 00084 //.. // get space for the MAXA vector 00085 //.. pc_skymatrix_rep->p_maxa = new int[matrix_order]; 00086 //.. // put all 1 in the MAXA ( somewhat superficial! ) 00087 //.. for ( int j=0 ; j<pc_skymatrix_rep->square_dim ; j++ ) 00088 //.. pc_skymatrix_rep->p_maxa[j] = 1; 00089 //.. 00090 //.. pc_skymatrix_rep->total_numb = total_numb; 00091 //.. 00092 //.. // allocate memory for the actual skymatrix as skymatrix 00093 //.. pc_skymatrix_rep->pd_nDdata = new double [(size_t) pc_skymatrix_rep->total_numb]; 00094 //.. if (!pc_skymatrix_rep->pd_nDdata) 00095 //.. { 00096 //.. ::printf("\a\nInsufficient memory for skymatrix_rep\n"); 00097 //.. ::exit(1); 00098 //.. } 00099 //.. 00100 //.. pc_skymatrix_rep->n = 1; // so far, there's one reference 00101 //.. 00102 //.. for ( int i=0 ; i<pc_skymatrix_rep->total_numb ; i++ ) 00103 //.. pc_skymatrix_rep->pd_nDdata[i] = init_val; 00104 //.. } 00105 //.. 00106 //tempout//########################################################################## 00107 //tempoutskymatrix::skymatrix(FEModelData & FEMD, Brick3D * b3d, Node * node) 00108 //tempout//skymatrix::skymatrix(FEModelData & FEMD, Finite_Element & FE) 00109 //tempout { 00110 //tempout// create the structure: 00111 //tempout pc_skymatrix_rep = new skymatrix_rep; // this 'new' is overloaded 00112 //tempout 00113 //tempout 00114 //tempout int Number_of_DOFs = FEMD.get_number_of_DOFs(); 00115 //tempout pc_skymatrix_rep->square_dim = Number_of_DOFs; 00116 //tempout// create ColumnHeight _________________________________________________ 00117 //tempout pc_skymatrix_rep->columnheight = new int [Number_of_DOFs+1]; 00118 //tempout if (!pc_skymatrix_rep->columnheight) 00119 //tempout { 00120 //tempout ::printf("\a\nInsufficient memory for pc_skymatrix_rep->columnheight\n"); 00121 //tempout ::exit(1); 00122 //tempout } 00123 //tempout for (int count = 1 ; count <= Number_of_DOFs ; count++) 00124 //tempout 00125 //tempout //**** Changing 1 to 0 to set initial value of colheight. 00126 //tempout pc_skymatrix_rep->columnheight[count]=0; 00127 //tempout 00128 //tempout int Number_of_Elements = FEMD.get_number_of_Bricks(); 00129 //tempout 00130 //tempout int II = 0; 00131 //tempout int *LM = NULL; 00132 //tempout int ME = 0; 00133 //tempout 00134 //tempout int Number_of_DOFs_for_brick = 24; 00135 //tempout 00136 //tempout for (int el_count = 1 ; el_count <= Number_of_Elements ; el_count++) 00137 //tempout { 00138 //tempout b3d[el_count].set_LM(node); 00139 //tempout // b3d[el_count].reportLM("LM"); 00140 //tempout } 00141 //tempout 00142 //tempout// KJBathe: Page 1002 sub COLHT 00143 //tempout int LS = 1000000; 00144 //tempout int temp=0; 00145 //tempout 00146 //tempout for (int el_cnt =1 ; el_cnt <= Number_of_Elements ; el_cnt++) 00147 //tempout { 00148 //tempout LS = 1000000; 00149 //tempout LM = b3d[el_cnt].get_LM(); 00150 //tempout for (int count01 = 0 ; count01 < Number_of_DOFs_for_brick ; count01++) 00151 //tempout { 00152 //tempout if (LM[count01] !=0 ) 00153 //tempout { 00154 //tempout// ::printf("+++++++ LM[%d]= %d LS = %d \n", count01, LM[count01], LS); 00155 //tempout temp = LS; 00156 //tempout// ::printf("temp = %d LM[%d]= %d \n", temp, count01, LM[count01]); 00157 //tempout temp = LM[count01] - temp; 00158 //tempout// ::printf("temp = %d LM[%d]= %d LS = %d \n", temp, count01, LM[count01], LS); 00159 //tempout if ( temp < 0 ) 00160 //tempout { 00161 //tempout LS = LM[count01]; 00162 //tempout// ::printf("(LM[count01]-LS)<0->> LM[%d]= %d LS = %d \n", count01, LM[count01], LS); 00163 //tempout } 00164 //tempout 00165 //tempout } 00166 //tempout // getchar(); 00167 //tempout 00168 //tempout } 00169 //tempout 00170 //tempout 00171 //tempout for (int count02 = 0 ; count02 < Number_of_DOFs_for_brick ; count02++) 00172 //tempout { 00173 //tempout II = LM[count02]; 00174 //tempout // ::printf("II= %d LM[%d] = %d \n", II,count02, LM[count02] ); 00175 //tempout 00176 //tempout if (II!=0) 00177 //tempout { 00178 //tempout ME = II-LS; 00179 //tempout // ::printf("ME= %d II = %d LS = %d \n", ME, II, LS ); 00180 //tempout 00181 //tempout // ::printf("ME= %d II = %d ColumnHeight[%d] = %d \n", ME, II, II, ColumnHeight[II]); 00182 //tempout if (ME > pc_skymatrix_rep->columnheight[II]) 00183 //tempout { 00184 //tempout pc_skymatrix_rep->columnheight[II] = ME; 00185 //tempout // ::printf("ME > ColumnHeight[II] ->> ME= %d ColumnHeight[%d] = %d \n", ME, II, ColumnHeight[II]); 00186 //tempout // getchar(); 00187 //tempout } 00188 //tempout } 00189 //tempout } 00190 //tempout 00191 //tempout //::printf("IN colheigth = \n"); 00192 //tempout 00193 //tempout // for (int count03 = 1 ; count03 <= Number_of_DOFs ; count03++) 00194 //tempout // { 00195 //tempout // ::printf(" %d ", pc_skymatrix_rep->columnheight[count03] ); 00196 //tempout // } 00197 //tempout// getchar(); 00198 //tempout 00199 //tempout } 00200 //tempout 00201 //tempout 00202 //tempout 00203 //tempout 00204 //tempout ::printf(" \n ------+------ \n "); 00205 //tempout 00206 //tempout// create MAXA ______________________________________________ 00207 //tempout// pc_skymatrix_rep->maxa = new int [Number_of_DOFs+1]; 00208 //tempout pc_skymatrix_rep->maxa = new int [Number_of_DOFs]; 00209 //tempout if (!pc_skymatrix_rep->maxa) 00210 //tempout { 00211 //tempout ::printf("\a\nInsufficient memory for maxa\n"); 00212 //tempout ::exit(1); 00213 //tempout } 00214 //tempout for (int count05 = 0 ; count05 < Number_of_DOFs ; count05++) 00215 //tempout pc_skymatrix_rep->maxa[count05]=0; 00216 //tempout 00217 //tempout// For the convience of calculating full_val from skymatrix: maxa[col]-maxa[col-1], adding 00218 //tempout// pc_skymatrix_rep->maxa[0] = 1; 00219 //tempout 00220 //tempout// pc_skymatrix_rep->maxa[1] = 1; 00221 //tempout// pc_skymatrix_rep->maxa[2] = 2; 00222 //tempout pc_skymatrix_rep->maxa[0] = 1; 00223 //tempout pc_skymatrix_rep->maxa[1] = 2; 00224 //tempout //KJBathe pp 1002 00225 //tempout int MK = 0; 00226 //tempout 00227 //tempout for (int count07 = 1 ; count07 <= Number_of_DOFs ; count07++) 00228 //tempout { 00229 //tempout if (pc_skymatrix_rep->columnheight[count07] > MK ) 00230 //tempout { 00231 //tempout MK = pc_skymatrix_rep->columnheight[count07]; 00232 //tempout } 00233 //tempout 00234 //tempout// pc_skymatrix_rep->maxa[count07+1] = 00235 //tempout// pc_skymatrix_rep->maxa[count07]+pc_skymatrix_rep->columnheight[count07] + 1; 00236 //tempout pc_skymatrix_rep->maxa[count07] = 00237 //tempout pc_skymatrix_rep->maxa[count07-1]+pc_skymatrix_rep->columnheight[count07] + 1; 00238 //tempout } 00239 //tempout 00240 //tempout // ::printf("MAXA = \n"); 00241 //tempout // for (int count = 0 ; count < Number_of_DOFs+1 ; count++) 00242 //tempout // { 00243 //tempout // ::printf("Col %d MAXA = %d \n", count, pc_skymatrix_rep->maxa[count] ); 00244 //tempout // } 00245 //tempout 00246 //tempout 00247 //tempout 00248 //tempout 00249 //tempout 00250 //tempout int Total_K_length = pc_skymatrix_rep->maxa[Number_of_DOFs+1]; 00251 //tempout 00252 //tempout pc_skymatrix_rep->data = new double [Total_K_length+1]; 00253 //tempout 00254 //tempout if (!pc_skymatrix_rep->data) 00255 //tempout { 00256 //tempout ::printf("\a\nInsufficient memory for pc_skymatrix_rep->data\n"); 00257 //tempout ::exit(1); 00258 //tempout } 00259 //tempout //ZHaohui Feb. 11, 2000 SOmething wrong with this statememt! 00260 //tempout for (int count08 = 1 ; count08 <= Number_of_DOFs ; count08++) 00261 //tempout pc_skymatrix_rep->data[count08]=0; 00262 //tempout 00263 //tempout 00264 //tempout 00265 //tempout } 00266 //tempout 00267 //########################################################################## 00268 //########################################################################## 00269 skymatrix::skymatrix(int Number_of_DOFs, int *MAXA, double *initval) 00270 { 00271 // create the structure: 00272 pc_skymatrix_rep = new skymatrix_rep; // this 'new' is overloaded 00273 00274 pc_skymatrix_rep->square_dim = Number_of_DOFs; 00275 00276 // get space for the MAXA vector 00277 pc_skymatrix_rep->maxa = new int[Number_of_DOFs+1]; 00278 // put all maxa's in the MAXA 00279 for ( int j=0 ; j<=Number_of_DOFs ; j++ ) 00280 // pc_skymatrix_rep->maxa[0] = 1; 00281 // for ( int j=1 ; j<=Number_of_DOFs+1 ; j++ ) 00282 pc_skymatrix_rep->maxa[j] = MAXA[j]; 00283 00284 int Total_K_length = pc_skymatrix_rep->maxa[Number_of_DOFs]; 00285 // allocate memory for the actual skymatrix as skymatrix 00286 pc_skymatrix_rep->data = new double [(size_t) Total_K_length]; 00287 if (!pc_skymatrix_rep->data) 00288 { 00289 ::printf("\a\nInsufficient memory for skymatrix_rep\n"); 00290 ::exit(1); 00291 } 00292 00293 for ( int i=0 ; i<Total_K_length ; i++ ) 00294 pc_skymatrix_rep->data[i] = initval[i]; 00295 } 00296 00297 //outOLD//############################################################################## 00298 //outOLDskymatrix::skymatrix(const skymatrix & x) // copy initializer 00299 //outOLD { 00300 //outOLD x.pc_skymatrix_rep->n++; // we're adding another reference. 00301 //outOLD pc_skymatrix_rep = x.pc_skymatrix_rep; // point to the new skymatrix_rep. 00302 //outOLD } 00303 00304 00305 00306 //oldDestructor//########################################################################## 00307 //oldDestructorskymatrix::~skymatrix() 00308 //oldDestructor { 00309 //oldDestructor if (--pc_skymatrix_rep->n == 0) // if reference count goes to 0 00310 //oldDestructor { 00311 //oldDestructor// DEallocate memory of the actual nDarray 00312 //oldDestructor// delete [pc_nDarray_rep->pc_nDarray_rep->total_numb] pc_nDarray_rep->pd_nDdata; 00313 //oldDestructor// see ELLIS & STROUSTRUP $18.3 00314 //oldDestructor// and note on the p.65($5.3.4) 00315 //oldDestructor// and the page 276 ($12.4) 00316 //oldDestructor delete [] pc_skymatrix_rep->pd_nDdata; 00317 //oldDestructor delete [] pc_skymatrix_rep->p_maxa; 00318 //oldDestructor delete pc_skymatrix_rep; 00319 //oldDestructor } 00320 //oldDestructor} 00321 00322 //########################################################################## 00323 skymatrix::~skymatrix() 00324 { 00325 ::printf(" ------------ skymatrix::~skymatrix() \n "); 00326 delete [] pc_skymatrix_rep->columnheight; 00327 delete [] pc_skymatrix_rep->maxa; 00328 delete [] pc_skymatrix_rep->data; 00329 } 00330 //outOLD////########################################################################## 00331 //outOLDskymatrix & skymatrix::operator=(const skymatrix & rval) 00332 //outOLD { 00333 //outOLD rval.pc_skymatrix_rep->n++; // we're adding another reference. 00334 //outOLD// rval.reference_count(+1); // tell the rval it has another reference 00335 //outOLD// It is important to increment the reference_counter in the new 00336 //outOLD// tensor before decrementing the reference_counter in the 00337 //outOLD// old tensor_rep to ensure proper operation when assigning a 00338 //outOLD// tensor_rep to itself ( after ARKoenig JOOP May/June '90 ) 00339 //outOLD// clean up current value; 00340 //outOLD if( reference_count(-1) == 0) // if nobody else is referencing us. 00341 //outOLD { 00342 //outOLD delete [] pc_skymatrix_rep->pd_nDdata; 00343 //outOLD delete [] pc_skymatrix_rep->p_maxa; 00344 //outOLD delete pc_skymatrix_rep; 00345 //outOLD } 00346 //outOLD// connect to new value 00347 //outOLD pc_skymatrix_rep = rval.pc_skymatrix_rep;// point at the rval skymatrix_rep 00348 //outOLD 00349 //outOLD return *this; 00350 //outOLD } 00351 //outOLD 00352 //outOLD 00353 00354 00356 // Assemble global stiffness matrix from local contributions 00357 00358 // ::printf("ColHeigth = \n"); 00359 // for (int count = 1 ; count <= Number_of_DOFs ; count++) 00360 // { 00361 // ::printf("Col %d height = %d \n", count, ColumnHeight[count] ); 00362 // } 00363 00364 //########################################################################## 00365 int skymatrix::dimension_of_sky_M(void) const // dimension of sky matrix 00366 { 00367 return pc_skymatrix_rep->square_dim; 00368 } 00369 00370 //########################################################################## 00371 int * skymatrix::get_MAXA(void) const // get pointer to array of 00372 { // Locations of Diagonals 00373 return pc_skymatrix_rep->maxa; 00374 } 00375 00376 00377 //outOLD//############################################################################## 00378 //outOLD// skymatrix addition 00379 //outOLDskymatrix& skymatrix::operator+=(const skymatrix & rval) 00380 //outOLD { 00381 //outOLD long int this_total_numb = this->pc_skymatrix_rep->total_numb; 00382 //outOLD long int rval_total_numb = rval.pc_skymatrix_rep->total_numb; 00383 //outOLD 00384 //outOLD if(this_total_numb != rval_total_numb) 00385 //outOLD { 00386 //outOLD ::printf("\a\nskymatrixs of different sizes: += not YET possible\n"); 00387 //outOLD ::exit ( 1 ); 00388 //outOLD } 00389 //outOLD 00390 //outOLD// Copy *this if necessary 00391 //outOLD if ( this->pc_skymatrix_rep->n > 1 )// see ARK in JOOP may/june '90 00392 //outOLD { // "Letter From a Newcomer" 00393 //outOLD// create the structure: 00394 //outOLD skymatrix_rep * New_pc_skymatrix_rep = new skymatrix_rep; // this 'new' is overloaded 00395 //outOLD 00396 //outOLD New_pc_skymatrix_rep->square_dim = this->pc_skymatrix_rep->square_dim; 00397 //outOLD 00398 //outOLD// get space for the MAXA vector 00399 //outOLD New_pc_skymatrix_rep->p_maxa = new int[this->pc_skymatrix_rep->square_dim]; 00400 //outOLD// put all maxa's in the MAXA 00401 //outOLD for ( int j=0 ; j<this->pc_skymatrix_rep->square_dim ; j++ ) 00402 //outOLD New_pc_skymatrix_rep->p_maxa[j] = this->pc_skymatrix_rep->p_maxa[j]; 00403 //outOLD 00404 //outOLD New_pc_skymatrix_rep->total_numb = this->pc_skymatrix_rep->total_numb; 00405 //outOLD 00406 //outOLD // allocate memory for the actual skymatrix as skymatrix 00407 //outOLD New_pc_skymatrix_rep->pd_nDdata = new double [(size_t) pc_skymatrix_rep->total_numb]; 00408 //outOLD if (!New_pc_skymatrix_rep->pd_nDdata) 00409 //outOLD { 00410 //outOLD ::printf("\a\nInsufficient memory for New_skymatrix_rep\n"); 00411 //outOLD ::exit(1); 00412 //outOLD } 00413 //outOLD 00414 //outOLD New_pc_skymatrix_rep->n = 1; // so far, there's one reference 00415 //outOLD 00416 //outOLD for ( int i=0 ; i<New_pc_skymatrix_rep->total_numb ; i++ ) 00417 //outOLD New_pc_skymatrix_rep->pd_nDdata[i] = this->pc_skymatrix_rep->pd_nDdata[i]; 00418 //outOLD 00419 //outOLD this->pc_skymatrix_rep->total_numb--; 00420 //outOLD this->pc_skymatrix_rep = New_pc_skymatrix_rep; 00421 //outOLD//.............................................................................. 00422 //outOLD } 00423 //outOLD// I can add this two skymatrices just as a simple vectors: 00424 //outOLD for (int k=0 ; k<this->pc_skymatrix_rep->total_numb ; k++) 00425 //outOLD this->pc_skymatrix_rep->pd_nDdata[k] += rval.pc_skymatrix_rep->pd_nDdata[k]; 00426 //outOLD 00427 //outOLD return *this; 00428 //outOLD } 00429 //outOLD 00430 //outOLD 00431 //outOLD//############################################################################## 00432 //outOLD// skymatrix addition 00433 //outOLDskymatrix operator+(const skymatrix & lval, const skymatrix & rval) 00434 //outOLD { 00435 //outOLD skymatrix result(lval); 00436 //outOLD result += rval; 00437 //outOLD return result; 00438 //outOLD } 00439 //outOLD 00440 //outOLD 00441 //outOLD//############################################################################## 00442 //outOLD// scalar addition 00443 //outOLDskymatrix skymatrix::operator+( double rval) 00444 //outOLD { 00445 //outOLD// construct skymatrix using the same control numbers as for the 00446 //outOLD// original one. 00447 //outOLD skymatrix add(pc_skymatrix_rep->square_dim, 00448 //outOLD pc_skymatrix_rep->p_maxa, 00449 //outOLD pc_skymatrix_rep->pd_nDdata); 00450 //outOLD 00451 //outOLD for ( int i1=0 ; i1<this->pc_skymatrix_rep->total_numb ; i1++ ) 00452 //outOLD { 00453 //outOLD add.pc_skymatrix_rep->pd_nDdata[i1] += rval; 00454 //outOLD } 00455 //outOLD return add; 00456 //outOLD } 00457 //outOLD 00458 //outOLD 00459 //outOLD 00460 //outOLD//############################################################################## 00461 //outOLD// skymatrix substraction 00462 //outOLDskymatrix& skymatrix::operator-=(const skymatrix & rval) 00463 //outOLD { 00464 //outOLD long int this_total_numb = this->pc_skymatrix_rep->total_numb; 00465 //outOLD long int rval_total_numb = rval.pc_skymatrix_rep->total_numb; 00466 //outOLD 00467 //outOLD if(this_total_numb != rval_total_numb) 00468 //outOLD { 00469 //outOLD ::printf("\a\nskymatrixs of different sizes: -= not YET possible\n"); 00470 //outOLD ::exit ( 1 ); 00471 //outOLD } 00472 //outOLD 00473 //outOLD// Copy *this if necessary 00474 //outOLD if ( this->pc_skymatrix_rep->n > 1 )// see ARK in JOOP may/june '90 00475 //outOLD { // "Letter From a Newcomer" 00476 //outOLD//.............................................................................. 00477 //outOLD // create the structure: 00478 //outOLD // create the structure: 00479 //outOLD skymatrix_rep * New_pc_skymatrix_rep = new skymatrix_rep; // this 'new' is overloaded 00480 //outOLD 00481 //outOLD New_pc_skymatrix_rep->square_dim = this->pc_skymatrix_rep->square_dim; 00482 //outOLD 00483 //outOLD// get space for the MAXA vector 00484 //outOLD New_pc_skymatrix_rep->p_maxa = new int[this->pc_skymatrix_rep->square_dim]; 00485 //outOLD// put all maxa's in the MAXA 00486 //outOLD for ( int j=0 ; j<this->pc_skymatrix_rep->square_dim ; j++ ) 00487 //outOLD New_pc_skymatrix_rep->p_maxa[j] = this->pc_skymatrix_rep->p_maxa[j]; 00488 //outOLD 00489 //outOLD New_pc_skymatrix_rep->total_numb = this->pc_skymatrix_rep->total_numb; 00490 //outOLD 00491 //outOLD // allocate memory for the actual skymatrix as skymatrix 00492 //outOLD New_pc_skymatrix_rep->pd_nDdata = new double [(size_t) pc_skymatrix_rep->total_numb]; 00493 //outOLD if (!New_pc_skymatrix_rep->pd_nDdata) 00494 //outOLD { 00495 //outOLD ::printf("\a\nInsufficient memory for New_skymatrix_rep\n"); 00496 //outOLD ::exit(1); 00497 //outOLD } 00498 //outOLD 00499 //outOLD New_pc_skymatrix_rep->n = 1; // so far, there's one reference 00500 //outOLD 00501 //outOLD for ( int i=0 ; i<New_pc_skymatrix_rep->total_numb ; i++ ) 00502 //outOLD New_pc_skymatrix_rep->pd_nDdata[i] = this->pc_skymatrix_rep->pd_nDdata[i]; 00503 //outOLD 00504 //outOLD this->pc_skymatrix_rep->total_numb--; 00505 //outOLD this->pc_skymatrix_rep = New_pc_skymatrix_rep; 00506 //outOLD//.............................................................................. 00507 //outOLD } 00508 //outOLD// I can add this two skymatrices just as a simple vectors: 00509 //outOLD for (int k=0 ; k<this->pc_skymatrix_rep->total_numb ; k++) 00510 //outOLD this->pc_skymatrix_rep->pd_nDdata[k] -= rval.pc_skymatrix_rep->pd_nDdata[k]; 00511 //outOLD 00512 //outOLD return *this; 00513 //outOLD } 00514 //outOLD 00515 //outOLD 00516 //outOLD//############################################################################## 00517 //outOLD// skymatrix substraction 00518 //outOLDskymatrix operator-(const skymatrix & lval, const skymatrix & rval) 00519 //outOLD { 00520 //outOLD skymatrix result(lval); 00521 //outOLD result -= rval; 00522 //outOLD return result; 00523 //outOLD } 00524 //outOLD 00525 //outOLD 00526 //outOLD//############################################################################## 00527 //outOLD// scalar substraction 00528 //outOLDskymatrix skymatrix::operator-( double rval) 00529 //outOLD { 00530 //outOLD// construct skymatrix using the same control numbers as for the 00531 //outOLD// original one. 00532 //outOLD skymatrix substract(pc_skymatrix_rep->square_dim, 00533 //outOLD pc_skymatrix_rep->p_maxa, 00534 //outOLD pc_skymatrix_rep->pd_nDdata); 00535 //outOLD 00536 //outOLD for ( int i1=0 ; i1<this->pc_skymatrix_rep->total_numb ; i1++ ) 00537 //outOLD { 00538 //outOLD substract.pc_skymatrix_rep->pd_nDdata[i1] -= rval; 00539 //outOLD } 00540 //outOLD return substract; 00541 //outOLD } 00542 //outOLD 00543 //outOLD 00544 //outOLD//############################################################################## 00545 //outOLD// scalar multiplication 00546 //outOLDskymatrix skymatrix::operator*( double rval) 00547 //outOLD { 00548 //outOLD// construct skymatrix using the same control numbers as for the 00549 //outOLD// original one. 00550 //outOLD skymatrix mult(pc_skymatrix_rep->square_dim, 00551 //outOLD pc_skymatrix_rep->p_maxa, 00552 //outOLD pc_skymatrix_rep->pd_nDdata); 00553 //outOLD 00554 //outOLD for ( int i1=0 ; i1<this->pc_skymatrix_rep->total_numb ; i1++ ) 00555 //outOLD { 00556 //outOLD mult.pc_skymatrix_rep->pd_nDdata[i1] *= rval; 00557 //outOLD } 00558 //outOLD return mult; 00559 //outOLD } 00560 //outOLD 00561 //outOLD 00562 //outOLD 00563 //outOLD 00564 //outOLD 00565 //outOLD 00566 //outOLD 00567 //outOLD 00568 //outOLD 00569 //outOLD//########################################################################## 00570 //outOLD// this one is the same as mval except that it is more convinient 00571 //outOLD// to overload operator (row,col). 00572 //outOLDdouble & skymatrix::operator( )(int row, int col) const 00573 //outOLD { 00574 //outOLD if( row>col ) // Now we can call the matrix 00575 //outOLD { // as if it is full matrix. 00576 //outOLD int temp = row; // This makes small overhead 00577 //outOLD row = col; // and it will be removed latter on. 00578 //outOLD col = temp; 00579 //outOLD } 00580 //outOLD int diagonal_member_n = *(pc_skymatrix_rep->p_maxa+col-1); //-1:starts from 0 00581 //outOLD int member_of_sky_n = diagonal_member_n + col - row -1; //-1:starts from 0 00582 //outOLD double * member_of_sky = &(pc_skymatrix_rep->pd_nDdata[member_of_sky_n]) ; 00583 //outOLD return( * member_of_sky ); 00584 //outOLD } 00585 00586 //########################################################################## 00587 double & skymatrix::mval(int row, int col) const 00588 { 00589 if( row>col ) // Now we can call the matrix 00590 { // as if it is full matrix. 00591 int temp = row; // This makes small overhead 00592 row = col; // and it will be removed latter on. 00593 col = temp; 00594 } 00595 int diagonal_member_n = *(pc_skymatrix_rep->maxa+col-1); //-1:starts from 0 00596 int member_of_sky_n = diagonal_member_n + col - row -1; //-1:starts from 0 00597 double * member_of_sky = &(pc_skymatrix_rep->data[member_of_sky_n]) ; 00598 return( * member_of_sky ); 00599 // put this latter after debugging 00600 // return(*( ps_sky_m_rep->pd_nDdata[*(ps_sky_m_rep->p_maxa+col)+col-row-1])); 00601 } 00602 00603 00604 00605 //########################################################################## 00606 // full_val function allows you to treat skymatrix as if it is full 00607 // float matrix. The function will calculate position inside sky matrix 00608 // and return appropriate number if row and col are bellow skyline or 00609 // return zero (0) if row and col are above sky line 00610 double skymatrix::full_val(int row, int col) const 00611 { 00612 if( row>col ) 00613 { 00614 int temp = row; 00615 row = col; 00616 col = temp; 00617 } 00618 int total_column_height = col; 00619 int actual_column_position = total_column_height - row + 1; 00620 int real_column_height = pc_skymatrix_rep->maxa[col]-pc_skymatrix_rep->maxa[col-1]; 00621 int how_much_above_skyline=actual_column_position-real_column_height; // adding -1 -Zhaohui 00622 if ( how_much_above_skyline > 0 ) 00623 { 00624 double back = 0.0; 00625 return ( back ); 00626 } 00627 else 00628 { 00629 int diagonal_member_n = *(pc_skymatrix_rep->maxa+col-1); //-1:starts from 0 // deleting -1 --Zhaohui 00630 int member_of_sky_n = diagonal_member_n + col - row-1 ; //-1:starts from 0 // deleting -1 --Zhaohui 00631 double member_of_sky = pc_skymatrix_rep->data[member_of_sky_n] ; 00632 return( member_of_sky ); 00633 // put this latter after debugging 00634 // return(*( ps_sky_m_rep->pd_nDdata[*(ps_sky_m_rep->p_maxa+col)+col-row-1])); 00635 } 00636 } 00637 // used by skymatrix functions which KNOW they aren't 00638 // exceeding the boundaries 00639 00640 00641 00642 00643 00644 //########################################################################## 00645 double & skymatrix::val(int row, int col) 00646 { 00647 // double zero=0.0; 00648 if ( row<=0 && row>=dimension_of_sky_M() && col>=dimension_of_sky_M() ) 00649 { 00650 error("index out of range"); 00651 // return zero; 00652 } 00653 // else 00654 return (mval(row,col)); 00655 } 00656 00657 //########################################################################## 00658 double skymatrix::cval(int row, int col) const 00659 { 00660 double zero=0.0; 00661 if ( row<=0 && row>=dimension_of_sky_M() && col>=dimension_of_sky_M() ) 00662 { 00663 error("index out of range"); 00664 return zero; 00665 } 00666 // else 00667 return (mval(row,col)); 00668 } 00669 00670 00671 //########################################################################## 00672 double skymatrix::mmin() 00673 { 00674 double temp = 0.0; 00675 if ( dimension_of_sky_M()<=0 ) 00676 { 00677 error("bad skymatrix size for min ()"); 00678 return 0.0; 00679 } 00680 double minimum = mval(1,1); 00681 for ( int row=1 ; row<=dimension_of_sky_M() ; row++ ) 00682 for ( int col=1 ; col<=dimension_of_sky_M() ; col++ ) 00683 if ( (temp=mval(row,col)) < minimum ) 00684 minimum = temp; 00685 return minimum; 00686 } 00687 00688 //########################################################################## 00689 double skymatrix::mmax() 00690 { 00691 double temp = 0.0; 00692 if( dimension_of_sky_M()<=0 ) 00693 { 00694 error("bad skymatrix size for max()"); 00695 double zero=0.0; 00696 return zero; 00697 } 00698 double maximum = mval(1,1); 00699 for ( int row=1 ; row<=dimension_of_sky_M() ; row++ ) 00700 for ( int col=1 ; col<=dimension_of_sky_M() ; col++ ) 00701 { 00702 if ( (temp=mval(row,col)) > maximum ) 00703 maximum = temp; 00704 } 00705 return maximum; 00706 } 00707 00708 //outOLD//########################################################################## 00709 //outOLDdouble skymatrix::mean() 00710 //outOLD { 00711 //outOLD int col = 0; 00712 //outOLD int row = 1; 00713 //outOLD double sum = 0; 00714 //outOLD for ( row=1 ; row<=dimension_of_sky_M() ; row++ ) 00715 //outOLD for ( col=1 ; col<=dimension_of_sky_M() ; col++ ) 00716 //outOLD sum += fabs(mval(row,col)); 00717 //outOLD return sum/(row*col); 00718 //outOLD } 00719 //outOLD 00720 //outOLD 00721 //########################################################################## 00722 void skymatrix::lower_print(char *msg) 00723 { 00724 if (*msg) printf("%s\n",msg); 00725 for ( int row=1 ; row<=dimension_of_sky_M() ; row++ ) 00726 { 00727 int total_column_height = row; 00728 int real_column_height = pc_skymatrix_rep->maxa[row] - pc_skymatrix_rep->maxa[row-1]; 00729 int numb_of_voids = total_column_height - real_column_height; 00730 int n_of_voids_to_reach_number = numb_of_voids; 00731 for ( int col=1 ; col<=row ; col++ ) 00732 { 00733 if( n_of_voids_to_reach_number > 0 ) 00734 { 00735 for(int void_count=1; void_count<=numb_of_voids; void_count++) 00736 { 00737 printf("********* "); 00738 col++; 00739 n_of_voids_to_reach_number--; 00740 } 00741 } 00742 printf( "%+6.2e ", cval(row,col) ); 00743 } 00744 printf("\n"); 00745 } 00746 } 00747 00748 //########################################################################## 00749 void skymatrix::upper_print(char *msg) 00750 { 00751 if (*msg) printf("%s\n",msg); 00752 for ( int row=1 ; row<=dimension_of_sky_M() ; row++ ) 00753 { 00754 for ( int voids=0 ; voids<row-1 ; voids++ ) printf(" "); 00755 for ( int col=row ; col<=dimension_of_sky_M() ; col++ ) 00756 { 00757 int total_column_height = col; 00758 int actual_column_position = total_column_height - row + 1; 00759 int real_column_height = pc_skymatrix_rep->maxa[col] - pc_skymatrix_rep->maxa[col-1]; 00760 int how_much_above_skyline=actual_column_position-real_column_height; 00761 if ( how_much_above_skyline > 0 ) 00762 { 00763 printf("********* "); 00764 } 00765 else 00766 { 00767 printf( "%+6.2e ", cval(col,row) ); 00768 } 00769 } 00770 printf("\n"); 00771 } 00772 } 00773 00774 00775 //########################################################################## 00776 void skymatrix::full_print(char *msg) 00777 { 00778 if (*msg) printf("%s\n",msg); 00779 for ( int row=1 ; row<=dimension_of_sky_M() ; row++ ) 00780 { 00781 for ( int col=1 ; col<=dimension_of_sky_M() ; col++ ) 00782 { 00783 printf( "%+6.2e ", full_val(row,col) ); 00784 } 00785 printf("\n"); 00786 } 00787 } 00788 00789 00790 //########################################################################## 00791 void skymatrix::error(char * msg1, char * msg2) const 00792 { 00793 ::fprintf(stderr,"skymatrix error: %s %s\n", msg1, msg2); 00794 exit( 1 ); 00795 } 00796 00797 00798 00799 //outOLD 00800 00801 00802 //tempout//############################################################################# 00803 //tempout// Assemble global stiffness matrix from local contributions 00804 //tempoutskymatrix & skymatrix::AssembleBricksInSkyMatrix(stiffness_matrix & Ke, 00805 //tempout Brick3D * b3d, 00806 //tempout Node * node 00807 //tempout ) 00808 //tempout { 00809 //tempout// int BrickNumber = b3d->get_Brick_Number(); 00810 //tempout// b3d->reportshort(""); 00811 //tempout 00812 //tempout// for element numbered BrickNumber create LM array (see Bathe pp984 00813 //tempout// for (int LocalNodeNumber = 1 ; LocalNodeNumber<=20 ; LocalNodeNumber++ ) 00814 //tempout 00815 //tempout 00816 //tempout//-- for (int LocalNodeNumber = 1 ; LocalNodeNumber<=8 ; LocalNodeNumber++ )// for 8noded brick 00817 //tempout//-- { 00818 //tempout//--// int global_node_number = b3d[BrickNumber-1].get_global_number_of_node(LocalNodeNumber-1); 00819 //tempout//-- int global_node_number = b3d->get_global_number_of_node(LocalNodeNumber-1); 00820 //tempout//-- LM[3*LocalNodeNumber-3] = node[global_node_number].eqn_tx(); 00821 //tempout//-- LM[3*LocalNodeNumber-2] = node[global_node_number].eqn_ty(); 00822 //tempout//-- LM[3*LocalNodeNumber-1] = node[global_node_number].eqn_tz(); 00823 //tempout//-- } 00824 //tempout 00825 //tempout ::printf("\n\n"); 00826 //tempout//..for (int count01=1;count01<=8;count01++) 00827 //tempout//.. { 00828 //tempout//..::printf("element %4d localNode %4d Globalnode %4d LM %4d %4d %4d\n", BrickNumber, count01,b3d->get_global_number_of_node(count01-1), LM[count01*3-3], LM[count01*3-2], LM[count01*3-1] ); 00829 //tempout//.. } 00830 //tempout 00831 //tempout int *lm = b3d->get_LM(); 00832 //tempout 00833 //tempout 00834 //tempout// KJBathe pp1003 ADDBAN 00835 //tempout 00836 //tempout int DOF_count_for_Brick = 24; 00837 //tempout int ND = DOF_count_for_Brick; 00838 //tempout int NDI = 0; 00839 //tempout int II = 0; 00840 //tempout int MI = 0; 00841 //tempout int KS = 0; 00842 //tempout int KSS = 0; 00843 //tempout int JJ = 0; 00844 //tempout int IJ = 0; 00845 //tempout int KK = 0; 00846 //tempout for (int I = 1 ; I <= DOF_count_for_Brick ; I++) 00847 //tempout { 00848 //tempout II = lm[I-1]; 00849 //tempout if (II > 0) 00850 //tempout { 00851 //tempout MI = pc_skymatrix_rep->maxa[II-1]; //II-1--> II 00852 //tempout 00853 //tempout KS = I; 00854 //tempout for (int J = 1 ; J <= DOF_count_for_Brick ; J++) 00855 //tempout { 00856 //tempout JJ = lm[J-1]; 00857 //tempout if (JJ > 0) 00858 //tempout { 00859 //tempout IJ = II - JJ; 00860 //tempout if (IJ >= 0 ) 00861 //tempout { 00862 //tempout KK = MI + IJ; 00863 //tempout KSS = KS; 00864 //tempout if ( J >= I ) 00865 //tempout { 00866 //tempout KSS = J + NDI; 00867 //tempout } 00868 //tempout pc_skymatrix_rep->data[KK-1] = 00869 //tempout pc_skymatrix_rep->data[KK-1] + Ke.val(I,J); // J-->KSS 00870 //tempout } 00871 //tempout } 00872 //tempout KS = KS + ND -J; 00873 //tempout 00874 //tempout } 00875 //tempout 00876 //tempout } 00877 //tempout NDI = NDI + ND - I; 00878 //tempout } 00879 //tempout 00880 //tempout 00881 //tempout return * this; 00882 //tempout } 00883 //tempout 00884 //tempout 00885 00886 00888 //* COPY-YES (C): 1990,1991,1992 00889 //* PROJECT: 00890 //* FILE: 00891 //* FUNCTION: 00892 //* PURPOSE: 00893 //* VERSION 00894 //* LANGUAGE: Microsoft C 6.0 , Borland C++ 3.1 00895 //* TARGET OS: DOS 00896 //* PROGRAMMER: Jeremic Boris 00897 //* DATE: 00898 //* UPDATE HISTORY: Nov. 12. 1992. C++ ver 00899 //****************************************************************************/ 00952 skymatrix & skymatrix::v_ldl_factorize() 00953 { 00954 int kn = 0; 00955 int kl = 0; 00956 int ku = 0; 00957 int kh = 0; 00958 int k = 0; 00959 int ic = 0; 00960 int klt = 0; 00961 int ki = 0; 00962 int nd = 0; 00963 int kk = 0; 00964 int n = 0; 00965 int j = 0; 00966 int l = 0; 00967 double c = 0.0; 00968 double b = 0.0; 00969 ::printf(" \n\n* * * Equations to factorize : "); 00970 for ( n=1 ; n<=pc_skymatrix_rep->square_dim ; n++ ) 00971 { 00972 printf(" %5d\b\b\b\b\b", pc_skymatrix_rep->square_dim - n); 00973 kn=*(pc_skymatrix_rep->maxa-1+n); 00974 kl=kn+1; 00975 ku=*(pc_skymatrix_rep->maxa-1+n+1)-1; 00976 kh=ku-kl; // changes ######## from colsol.c 00977 if ( kh>0 ) // *(pd_ldl_a. . . ) --> *(pc_skymatrix_rep->pd_nDdata-1. . . ) 00978 { // *(pi_ldl_maxa. . . ) --> *(pc_skymatrix_rep->p_maxa-1. . .) 00979 k=n-kh; // *(pi_ldl_nn) --> pc_skymatrix_rep->square_dim 00980 ic=0; 00981 klt=ku; 00982 for ( j=1 ; j<=kh ; j++ ) 00983 { 00984 ic=ic+1; 00985 klt=klt-1; 00986 ki=*(pc_skymatrix_rep->maxa-1+k); 00987 nd=*(pc_skymatrix_rep->maxa-1+k+1)-ki-1; 00988 if ( nd>0 ) 00989 { 00990 kk=( (ic<nd) ? ic : nd ); 00991 c=0.0; 00992 for ( l=1 ; l<=kk ; l++ ) 00993 c=c+(*(pc_skymatrix_rep->data-1+ki+l))*(*(pc_skymatrix_rep->data-1+klt+l)); 00994 *(pc_skymatrix_rep->data-1+klt)=*(pc_skymatrix_rep->data-1+klt)-c; 00995 } 00996 k=k+1; 00997 } 00998 } 00999 if ( kh>=0 ) 01000 { 01001 k=n; 01002 b=0.0; 01003 for ( kk=kl ; kk<=ku ; kk++ ) 01004 { 01005 k=k-1; 01006 ki=*(pc_skymatrix_rep->maxa-1+k); 01007 c=(*(pc_skymatrix_rep->data-1+kk))/(*(pc_skymatrix_rep->data-1+ki)); 01008 b=b+c*(*(pc_skymatrix_rep->data-1+kk)); 01009 *(pc_skymatrix_rep->data-1+kk)=c; 01010 } 01011 *(pc_skymatrix_rep->data-1+kn)=*(pc_skymatrix_rep->data-1+kn)-b; 01012 } 01013 if ( *(pc_skymatrix_rep->data-1+kn)<=0 ) 01014 { 01015 printf("\n Colsol Stoped - Stiffness Matrix not positive definite \n"); 01016 printf(" non positive pivot for equation, %d\n ", n); 01017 printf(" pivot, %.12e \n", *(pc_skymatrix_rep->data-1+kn) ); 01018 exit(1); 01019 } 01020 // printf("-------------------------- %d\n",n); 01021 // for( int i=0 ; i<=11 ; i++ ) 01022 // { 01023 // printf("pc_skymatrix_rep->pd_nDdata[%d] = %8.4f\n",i, pc_skymatrix_rep->pd_nDdata[i]); 01024 // } 01025 // getch(); 01026 01027 01028 } 01029 printf("\n"); 01030 return(*this); 01031 } 01032 01034 //* COPY-YES (C): 1990,1991 Jeremic Boris, 01035 //* PROJECT: 01036 //* FILE: 01037 //* FUNCTION: 01038 //* PURPOSE: 01039 //* VERSION 01040 //* LANGUAGE: Microsoft C 6.0 01041 //* TARGET OS: DOS 01042 //* PROGRAMMER: Jeremic Boris 01043 //* DATE: 01044 //* UPDATE HISTORY: 01045 //****************************************************************************/ 01060 double * skymatrix::d_reduce_r_h_s_l_v ( double *pd_rhs ) 01061 { 01062 int kl = 0; 01063 int ku = 0; 01064 int k = 0; 01065 int n = 0; 01066 int kk = 0; 01067 double c = 0.0; 01068 printf("\n * * * Right hand side loads to reduce :"); 01069 for ( n=1 ; n<=pc_skymatrix_rep->square_dim ; n++ ) 01070 { 01071 printf(" %5d\b\b\b\b\b", pc_skymatrix_rep->square_dim - n); 01072 kl=*(pc_skymatrix_rep->maxa-1+n)+1; 01073 ku=*(pc_skymatrix_rep->maxa-1+n+1)-1; // changes ######## from colsol.c 01074 if ( ku>=kl ) // *(pd_red_a. . . ) --> *(pc_skymatrix_rep->pd_nDdata-1. . . ) 01075 { // *(pi_red_maxa. . . ) --> *(pc_skymatrix_rep->p_maxa-1. . .) 01076 k=n; // *(pi_red_nn) --> pc_skymatrix_rep->square_dim 01077 c=0.0; // *(pd_rhs. . .) --> *(pd_rhs-1 . . . ) 01078 for ( kk=kl ; kk<=ku ; kk++ ) 01079 { 01080 k=k-1; 01081 c=c+(*(pc_skymatrix_rep->data-1+kk))*(*(pd_rhs-1+k)); 01082 } 01083 *(pd_rhs-1+n)=*(pd_rhs-1+n)-c; //pd_rhs[-1+n]==*(pd_rhs-1+n) 01084 } 01085 } 01086 printf("\n"); 01087 return( pd_rhs ); 01088 } 01089 01091 //* COPY-YES (C): 1990,1991 Jeremic Boris, 01092 //* PROJECT: 01093 //* FILE: 01094 //* FUNCTION: 01095 //* PURPOSE: 01096 //* VERSION 01097 //* LANGUAGE: MicroSoft C 6.0 01098 //* TARGET OS: DOS 01099 //* PROGRAMMER: Jeremic Boris (J_P_S_B) 01100 //* DATE: 01101 //* UPDATE HISTORY: 01102 //* 01103 //* 01104 //* 01105 //****************************************************************************/ 01120 double * skymatrix::d_back_substitute ( double *pd_rhs ) 01121 { 01122 int k = 0; 01123 int n = 0; 01124 int kl = 0; 01125 int ku = 0; 01126 int l = 0; 01127 int kk = 0; 01128 printf(" \n * * * Equations to back substitute :"); 01129 for ( n=1 ; n<=pc_skymatrix_rep->square_dim ; n++ ) 01130 { 01131 printf(" %5d\b\b\b\b\b", pc_skymatrix_rep->square_dim - n); 01132 k=*(pc_skymatrix_rep->maxa-1+n); 01133 *(pd_rhs-1+n)=(*(pd_rhs-1+n))/(*(pc_skymatrix_rep->data-1+k)); 01134 } 01135 if ( pc_skymatrix_rep->square_dim==1 ) return(pd_rhs); 01136 n=pc_skymatrix_rep->square_dim ; 01137 for ( l=2 ; l<=pc_skymatrix_rep->square_dim ; l++ ) 01138 { // changes ######## from colsol.c 01139 kl=*(pc_skymatrix_rep->maxa-1+n)+1; // *(pd_bac_a. . . ) --> *(pc_skymatrix_rep->pd_nDdata-1. . . ) 01140 ku=*(pc_skymatrix_rep->maxa-1+n+1)-1; // *(pi_bac_maxa. . . ) --> *(pc_skymatrix_rep->p_maxa-1. . .) 01141 if( ku>=kl ) // *(pi_bac_nn) --> pc_skymatrix_rep->square_dim 01142 { // *(pd_rhs. . .) --> *(pd_rhs-1 . . . ) 01143 k=n; 01144 for ( kk=kl ; kk<=ku ; kk++ ) 01145 { 01146 k=k-1; 01147 *(pd_rhs-1+k)=*(pd_rhs-1+k)-(*(pc_skymatrix_rep->data-1+kk))*(*(pd_rhs-1+n)); 01148 } 01149 n=n-1; 01150 } 01151 } 01152 printf("\n"); 01153 return (pd_rhs); 01154 } 01155 01157 01158 01159 //outOLD//############################################################################## 01160 //outOLD// very private part 01161 //outOLD//############################################################################## 01162 //outOLD double * skymatrix::data(void) const 01163 //outOLD { 01164 //outOLD return this->pc_skymatrix_rep->pd_nDdata; 01165 //outOLD } 01166 //outOLD 01167 //outOLD void skymatrix::set_data_pointer(double * data_pointer) 01168 //outOLD { 01169 //outOLD this->pc_skymatrix_rep->pd_nDdata = data_pointer; 01170 //outOLD } 01171 //outOLD// 01172 //outOLD// int skymatrix::rank(void) const 01173 //outOLD// { 01174 //outOLD// return this->pc_skymatrix_rep->skymatrix_rank; 01175 //outOLD// } 01176 //outOLD 01177 //outOLD// void skymatrix::rank(int skymatrix_rank) 01178 //outOLD// { 01179 //outOLD// this->pc_skymatrix_rep->skymatrix_rank = skymatrix_rank; 01180 //outOLD// } 01181 //outOLD// 01182 //outOLD long int skymatrix::total_number(void) const 01183 //outOLD { 01184 //outOLD return this->pc_skymatrix_rep->total_numb; 01185 //outOLD } 01186 //outOLD 01187 //outOLD void skymatrix::total_number(long int number) 01188 //outOLD { 01189 //outOLD this->pc_skymatrix_rep->total_numb = number; 01190 //outOLD } 01191 //outOLD 01192 //outOLD// int * skymatrix::dim(void) const 01193 //outOLD// { 01194 //outOLD// return this->pc_skymatrix_rep->dim; 01195 //outOLD// } 01196 //outOLD// 01197 //outOLD// int & skymatrix::get_dim_pointer(void) const 01198 //outOLD// { 01199 //outOLD// return this->pc_skymatrix_rep->dim[0]; 01200 //outOLD// } 01201 //outOLD// 01202 //outOLD// void skymatrix::set_dim_pointer(int * dim_pointer) 01203 //outOLD// { 01204 //outOLD// this->pc_skymatrix_rep->dim = dim_pointer; 01205 //outOLD// } 01206 //outOLD// 01207 //outOLD// int skymatrix::dim(int which) const 01208 //outOLD// { 01209 //outOLD// return this->pc_skymatrix_rep->dim[which-1]; 01210 //outOLD// } 01211 //outOLD// 01212 //outOLD int skymatrix::reference_count(int up_down) 01213 //outOLD { 01214 //outOLD this->pc_skymatrix_rep->n += up_down; 01215 //outOLD return(this->pc_skymatrix_rep->n); 01216 //outOLD } 01217 //outOLD 01218 //outOLD void skymatrix::set_reference_count(int ref_count) 01219 //outOLD { 01220 //outOLD this->pc_skymatrix_rep->n=ref_count; 01221 //outOLD } 01222 //outOLD 01223 //outOLD 01224 //outOLD//############################################################################## 01225 //outOLD// TENSOR_REP_CC 01226 //outOLD// ####################### 01227 //outOLD// memory manager part 01228 //outOLD// overloading operator new in skymatrix::skymatrix_rep class ################## 01229 //outOLDvoid * skymatrix_rep::operator new(size_t s) 01230 //outOLD { // see C++ reference manual by 01231 //outOLD void *void_pointer; // ELLIS and STROUSTRUP page 283. 01232 //outOLD void_pointer = ::operator new(s); // and ECKEL page 529. 01233 //outOLD// ::printf("\nnew pointer %p of size %d\n",void_pointer,s); 01234 //outOLD if (!void_pointer) 01235 //outOLD { 01236 //outOLD ::printf("\a\nInsufficient memory\n"); 01237 //outOLD ::exit(1); 01238 //outOLD } 01239 //outOLD return void_pointer; 01240 //outOLD } 01241 //outOLD 01242 //outOLD// overloading operator delete in skymatrix::skymatrix_rep class ################## 01243 //outOLDvoid skymatrix_rep::operator delete(void *p) 01244 //outOLD { // see C++ reference manual by 01245 //outOLD // ELLIS and STROUSTRUP page 283. 01246 //outOLD // and ECKEL page 529. 01247 //outOLD// ::printf("deleted pointer %p\n",p); 01248 //outOLD ::operator delete(p); 01249 //outOLD } 01250 //outOLD 01251 01252 #endif 01253 |