Changeset 12441
- Timestamp:
- 06/18/12 09:17:08 (13 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/objects/Numerics/ElementMatrix.cpp
r12365 r12441 78 78 79 79 /*Initialize itransformation matrix Ke[P[i]] = Ke2[i]*/ 80 P= (int*)xmalloc(Ke2->nrows*sizeof(int));80 P=xNew<int>(Ke2->nrows); 81 81 82 82 /*1: Get the new numbering of Ke2 and get size of the new matrix*/ … … 100 100 101 101 /*Gset and values*/ 102 this->gglobaldoflist= (int*)xmalloc(this->nrows*sizeof(int));103 this->values= (double*)xcalloc(this->nrows*this->ncols,sizeof(double));102 this->gglobaldoflist=xNew<int>(this->nrows); 103 this->values=xNewInit<double>(this->nrows*this->ncols,0.0); 104 104 for(i=0;i<Ke1->nrows;i++){ 105 105 for(j=0;j<Ke1->ncols;j++){ … … 122 122 this->row_fsize=fsize; 123 123 if(fsize){ 124 this->row_flocaldoflist = (int*)xmalloc(fsize*sizeof(int));125 this->row_fglobaldoflist= (int*)xmalloc(fsize*sizeof(int));124 this->row_flocaldoflist =xNew<int>(fsize); 125 this->row_fglobaldoflist=xNew<int>(fsize); 126 126 for(i=0;i<Ke1->row_fsize;i++){ 127 127 this->row_flocaldoflist[i] =Ke1->row_flocaldoflist[i]; … … 149 149 this->row_ssize=ssize; 150 150 if(ssize){ 151 this->row_slocaldoflist = (int*)xmalloc(ssize*sizeof(int));152 this->row_sglobaldoflist= (int*)xmalloc(ssize*sizeof(int));151 this->row_slocaldoflist =xNew<int>(ssize); 152 this->row_sglobaldoflist=xNew<int>(ssize); 153 153 for(i=0;i<Ke1->row_ssize;i++){ 154 154 this->row_slocaldoflist[i] =Ke1->row_slocaldoflist[i]; … … 178 178 179 179 /*clean-up*/ 180 x free((void**)&P);180 xDelete<int>(P); 181 181 } 182 182 /*}}}*/ … … 205 205 206 206 /*fill values with 0: */ 207 this->values= (double*)xcalloc(this->nrows*this->ncols,sizeof(double));207 this->values=xNewInit<double>(this->nrows*this->ncols,0.0); 208 208 209 209 /*g list*/ … … 231 231 ElementMatrix::~ElementMatrix(){ 232 232 233 x free((void**)&this->values);234 x free((void**)&this->gglobaldoflist);235 x free((void**)&this->row_flocaldoflist);236 x free((void**)&this->row_fglobaldoflist);237 x free((void**)&this->row_slocaldoflist);238 x free((void**)&this->row_sglobaldoflist);239 x free((void**)&this->col_flocaldoflist);240 x free((void**)&this->col_fglobaldoflist);241 x free((void**)&this->col_slocaldoflist);242 x free((void**)&this->col_sglobaldoflist);233 xDelete<double>(this->values); 234 xDelete<int>(this->gglobaldoflist); 235 xDelete<int>(this->row_flocaldoflist); 236 xDelete<int>(this->row_fglobaldoflist); 237 xDelete<int>(this->row_slocaldoflist); 238 xDelete<int>(this->row_sglobaldoflist); 239 xDelete<int>(this->col_flocaldoflist); 240 xDelete<int>(this->col_fglobaldoflist); 241 xDelete<int>(this->col_slocaldoflist); 242 xDelete<int>(this->col_sglobaldoflist); 243 243 } 244 244 /*}}}*/ … … 265 265 if(this->row_fsize){ 266 266 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 267 localvalues= (double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));267 localvalues=xNew<double>(this->row_fsize*this->row_fsize); 268 268 for(i=0;i<this->row_fsize;i++){ 269 269 for(j=0;j<this->row_fsize;j++){ … … 275 275 276 276 /*Free ressources:*/ 277 x free((void**)&localvalues);277 xDelete<double>(localvalues); 278 278 } 279 279 … … 281 281 if((this->row_ssize!=0) && (this->row_fsize!=0)){ 282 282 /*first, retrieve values that are in the f and s-set from the g-set values matrix: */ 283 localvalues= (double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double));283 localvalues=xNew<double>(this->row_fsize*this->row_ssize); 284 284 for(i=0;i<this->row_fsize;i++){ 285 285 for(j=0;j<this->row_ssize;j++){ … … 291 291 292 292 /*Free ressources:*/ 293 x free((void**)&localvalues);293 xDelete<double>(localvalues); 294 294 } 295 295 } … … 317 317 if(this->row_fsize){ 318 318 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 319 localvalues= (double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));319 localvalues=xNew<double>(this->row_fsize*this->row_fsize); 320 320 for(i=0;i<this->row_fsize;i++){ 321 321 for(j=0;j<this->row_fsize;j++){ … … 327 327 328 328 /*Free ressources:*/ 329 x free((void**)&localvalues);329 xDelete<double>(localvalues); 330 330 } 331 331 … … 428 428 this->dofsymmetrical=Ke->dofsymmetrical; 429 429 430 this->values= (double*)xmalloc(this->nrows*this->ncols*sizeof(double));430 this->values=xNew<double>(this->nrows*this->ncols); 431 431 memcpy(this->values,Ke->values,this->nrows*this->ncols*sizeof(double)); 432 432 433 this->gglobaldoflist= (int*)xmalloc(this->nrows*sizeof(int));433 this->gglobaldoflist=xNew<int>(this->nrows); 434 434 memcpy(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows*sizeof(int)); 435 435 436 436 this->row_fsize=Ke->row_fsize; 437 437 if(this->row_fsize){ 438 this->row_flocaldoflist= (int*)xmalloc(this->row_fsize*sizeof(int));438 this->row_flocaldoflist=xNew<int>(this->row_fsize); 439 439 memcpy(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize*sizeof(int)); 440 this->row_fglobaldoflist= (int*)xmalloc(this->row_fsize*sizeof(int));440 this->row_fglobaldoflist=xNew<int>(this->row_fsize); 441 441 memcpy(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize*sizeof(int)); 442 442 } … … 448 448 this->row_ssize=Ke->row_ssize; 449 449 if(this->row_ssize){ 450 this->row_slocaldoflist= (int*)xmalloc(this->row_ssize*sizeof(int));450 this->row_slocaldoflist=xNew<int>(this->row_ssize); 451 451 memcpy(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize*sizeof(int)); 452 this->row_sglobaldoflist= (int*)xmalloc(this->row_ssize*sizeof(int));452 this->row_sglobaldoflist=xNew<int>(this->row_ssize); 453 453 memcpy(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize*sizeof(int)); 454 454 } … … 460 460 this->col_fsize=Ke->col_fsize; 461 461 if(this->col_fsize){ 462 this->col_flocaldoflist= (int*)xmalloc(this->col_fsize*sizeof(int));462 this->col_flocaldoflist=xNew<int>(this->col_fsize); 463 463 memcpy(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize*sizeof(int)); 464 this->col_fglobaldoflist= (int*)xmalloc(this->col_fsize*sizeof(int));464 this->col_fglobaldoflist=xNew<int>(this->col_fsize); 465 465 memcpy(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize*sizeof(int)); 466 466 } … … 472 472 this->col_ssize=Ke->col_ssize; 473 473 if(this->col_ssize){ 474 this->col_slocaldoflist= (int*)xmalloc(this->col_ssize*sizeof(int));474 this->col_slocaldoflist=xNew<int>(this->col_ssize); 475 475 memcpy(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize*sizeof(int)); 476 this->col_sglobaldoflist= (int*)xmalloc(this->col_ssize*sizeof(int));476 this->col_sglobaldoflist=xNew<int>(this->col_ssize); 477 477 memcpy(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize*sizeof(int)); 478 478 } -
issm/trunk-jpl/src/c/objects/Numerics/ElementVector.cpp
r12365 r12441 54 54 55 55 /*Initialize itransformation matrix pe[P[i]] = pe2[i]*/ 56 P= (int*)xmalloc(pe2->nrows*sizeof(int));56 P=xNew<int>(pe2->nrows); 57 57 58 58 /*1: Get the new numbering of pe2 and get size of the new matrix*/ … … 74 74 75 75 /*Gset and values*/ 76 this->gglobaldoflist= (int*)xmalloc(this->nrows*sizeof(int));77 this->values= (double*)xcalloc(this->nrows,sizeof(double));76 this->gglobaldoflist=xNew<int>(this->nrows); 77 this->values=xNewInit<double>(this->nrows,0.0); 78 78 for(i=0;i<pe1->nrows;i++){ 79 79 this->values[i] += pe1->values[i]; … … 92 92 this->fsize=fsize; 93 93 if(fsize){ 94 this->flocaldoflist = (int*)xmalloc(fsize*sizeof(int));95 this->fglobaldoflist= (int*)xmalloc(fsize*sizeof(int));94 this->flocaldoflist =xNew<int>(fsize); 95 this->fglobaldoflist=xNew<int>(fsize); 96 96 for(i=0;i<pe1->fsize;i++){ 97 97 this->flocaldoflist[i] =pe1->flocaldoflist[i]; … … 113 113 114 114 /*clean-up*/ 115 x free((void**)&P);115 xDelete<int>(P); 116 116 } 117 117 /*}}}*/ … … 138 138 139 139 /*fill values with 0: */ 140 this->values= (double*)xcalloc(this->nrows,sizeof(double));140 this->values=xNewInit<double>(this->nrows,0.0); 141 141 142 142 /*g list*/ … … 152 152 ElementVector::~ElementVector(){ 153 153 154 x free((void**)&this->values);155 x free((void**)&this->gglobaldoflist);156 x free((void**)&this->flocaldoflist);157 x free((void**)&this->fglobaldoflist);154 xDelete<double>(this->values); 155 xDelete<int>(this->gglobaldoflist); 156 xDelete<int>(this->flocaldoflist); 157 xDelete<int>(this->fglobaldoflist); 158 158 } 159 159 /*}}}*/ … … 171 171 if(this->fsize){ 172 172 /*first, retrieve values that are in the f-set from the g-set values vector: */ 173 localvalues= (double*)xmalloc(this->fsize*sizeof(double));173 localvalues=xNew<double>(this->fsize); 174 174 for(i=0;i<this->fsize;i++){ 175 175 localvalues[i]=this->values[this->flocaldoflist[i]]; … … 179 179 180 180 /*Free ressources:*/ 181 x free((void**)&localvalues);181 xDelete<double>(localvalues); 182 182 } 183 183 … … 192 192 if(this->fsize){ 193 193 /*first, retrieve values that are in the f-set from the g-set values vector: */ 194 localvalues= (double*)xmalloc(this->fsize*sizeof(double));194 localvalues=xNew<double>(this->fsize); 195 195 for(i=0;i<this->fsize;i++){ 196 196 localvalues[i]=this->values[this->flocaldoflist[i]]; … … 200 200 201 201 /*Free ressources:*/ 202 x free((void**)&localvalues);202 xDelete<double>(localvalues); 203 203 } 204 204 … … 245 245 this->nrows =pe->nrows; 246 246 247 this->values= (double*)xmalloc(this->nrows*sizeof(double));247 this->values=xNew<double>(this->nrows); 248 248 memcpy(this->values,pe->values,this->nrows*sizeof(double)); 249 249 250 this->gglobaldoflist= (int*)xmalloc(this->nrows*sizeof(int));250 this->gglobaldoflist=xNew<int>(this->nrows); 251 251 memcpy(this->gglobaldoflist,pe->gglobaldoflist,this->nrows*sizeof(int)); 252 252 253 253 this->fsize=pe->fsize; 254 254 if(this->fsize){ 255 this->flocaldoflist= (int*)xmalloc(this->fsize*sizeof(int));255 this->flocaldoflist=xNew<int>(this->fsize); 256 256 memcpy(this->flocaldoflist,pe->flocaldoflist,this->fsize*sizeof(int)); 257 this->fglobaldoflist= (int*)xmalloc(this->fsize*sizeof(int));257 this->fglobaldoflist=xNew<int>(this->fsize); 258 258 memcpy(this->fglobaldoflist,pe->fglobaldoflist,this->fsize*sizeof(int)); 259 259 } -
issm/trunk-jpl/src/c/objects/Numerics/Matrix.cpp
r12365 r12441 45 45 #endif 46 46 #ifdef _HAVE_ADOLC_ 47 this->amatrix= (adouble*)xmalloc(M*N*sizeof(adouble));47 this->amatrix=xNew<adouble>(M*N); 48 48 #endif 49 49 } … … 58 58 #endif 59 59 #ifdef _HAVE_ADOLC_ 60 this->amatrix= (adouble*)xmalloc(M*N*sizeof(adouble));60 this->amatrix=xNew<adouble>; 61 61 #endif 62 62 } … … 69 69 70 70 71 int* idxm= (int*)xmalloc(M*sizeof(int));72 int* idxn= (int*)xmalloc(N*sizeof(int));71 int* idxm=xNew<int>(M); 72 int* idxn=xNew<int>(N); 73 73 for(i=0;i<M;i++)idxm[i]=i; 74 74 for(i=0;i<N;i++)idxn[i]=i; … … 79 79 MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY); 80 80 81 x free((void**)&idxm);82 x free((void**)&idxn);81 xDelete<int>(idxm); 82 xDelete<int>(idxn); 83 83 #else 84 84 this->matrix=new SeqMat(serial_mat,M,N,sparsity); 85 85 #endif 86 86 #ifdef _HAVE_ADOLC_ 87 this->amatrix= (adouble*)xmalloc(M*N*sizeof(adouble));87 this->amatrix=xNew<adouble>(M*N); 88 88 #endif 89 89 } … … 98 98 #endif 99 99 #ifdef _HAVE_ADOLC_ 100 this->amatrix= (adouble*)xmalloc(M*N*sizeof(adouble));100 this->amatrix=xNew<adouble>(M*N); 101 101 #endif 102 102 } … … 111 111 #endif 112 112 #ifdef _HAVE_ADOLC_ 113 x free((void**)&this->amatrix);113 xDelete<adouble>(this->amatrix); 114 114 #endif 115 115 } -
issm/trunk-jpl/src/c/objects/Numerics/Vector.cpp
r12365 r12441 44 44 #endif 45 45 #ifdef _HAVE_ADOLC_ 46 this->avector= (adouble*)xmalloc(pM*sizeof(adouble));46 this->avector=xNew<adouble>(pM); 47 47 #endif 48 48 } … … 52 52 53 53 #ifdef _HAVE_PETSC_ 54 int* idxm= (int*)xmalloc(M*sizeof(int));54 int* idxm=xNew<int>(M); 55 55 for(int i=0;i<M;i++) idxm[i]=i; 56 56 … … 60 60 VecAssemblyEnd(this->vector); 61 61 62 x free((void**)&idxm);62 xDelete<int>(idxm); 63 63 #else 64 64 this->vector=new SeqVec(serial_vec,M); 65 65 #endif 66 66 #ifdef _HAVE_ADOLC_ 67 this->avector= (adouble*)xmalloc(M*sizeof(adouble));67 this->avector=xNew<adouble>(M); 68 68 #endif 69 69 } … … 109 109 #endif 110 110 #ifdef _HAVE_ADOLC_ 111 x free((void**)&this->avector);111 xDelete<adouble>(this->avector); 112 112 #endif 113 113 } -
issm/trunk-jpl/src/c/shared/Matrix/MatrixUtils.cpp
r12440 r12441 188 188 ncol=nrow; 189 189 det=1.; 190 pivrc =(int(*)[2])xNew<int>(nrow*2); 190 pivrc1 =xNew<int>(nrow); 191 pivrc2 =xNew<int>(nrow); 191 192 pindx =xNew<int>(nrow); 192 193 … … 210 211 211 212 if (fabs(pivot) < DBL_EPSILON) { 212 xfree((void**)&pivrc); 213 xDelete<int>(pivrc1); 214 xDelete<int>(pivrc2); 213 215 xDelete<int>(pindx); 214 216 _error_("Pivot %f less than machine epsilon",pivot); … … 325 327 } 326 328 327 if (pdet) 328 *pdet=det; 329 330 xfree((void**)&pivrc); 329 if (pdet) *pdet=det; 330 xDelete<int>(pivrc1); 331 xDelete<int>(pivrc2); 331 332 xDelete<int>(pindx); 332 333 return noerr;
Note:
See TracChangeset
for help on using the changeset viewer.