Changeset 18435
- Timestamp:
- 08/18/14 16:21:52 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/gravity/vfsa.cpp
r18434 r18435 131 131 double misfit(Matrix* m0,Matrix* evalid,Matrix* gobs,int dlevel,Matrix* Pobs,Matrix* xobs,Matrix* yobs,Matrix* Pp,Matrix* rho1, Matrix* rho2,int dx,int dy,int dn,int nx,int ny, int mx,int my); 132 132 void GSLsquarefit(Matrix** pX,Matrix* A,Matrix* B); 133 double signe(double a); 134 void filtergrav(Matrix* A,Matrix* Ain,double ctr,double sd,int mx,int my); 133 135 /*}}}*/ 134 136 … … 281 283 M->Echo(); 282 284 o->Echo();*/ 283 285 double a; 286 a=signe(-9); 287 cout<<a; 284 288 return 0; 285 289 }/*}}}*/ … … 491 495 return e; 492 496 }/*}}}*/ 497 void newmodelgen(Matrix* m0,Matrix* m1,Matrix* bathy,Matrix* icethick,int mx,int my,double T,double ptval,double mmax,double mmax2,double ctr,double sd){/*{{{*/ 498 Matrix* m1gr=new Matrix(my,mx); 499 Matrix* m1grsm=new Matrix(my,mx); 500 Matrix* m1col=new Matrix(mx*my,1); 501 double u=0; 502 double y=0; 503 m1->MatrixEqual(m0); 504 for (int i=0;i<mx*my;i++){ 505 if(icethick->GetValue(i,0)==0){ 506 u=double (rand())/ double(RAND_MAX); 507 y=signe(u-0.5)*T*(pow(1+1/T,fabs(2*u-1))-1); 508 m1->SetValue(i,1,m0->GetValue(i,1)+y*ptval); 509 if(m1->GetValue(i,1)<=m1->GetValue(i,0)){ 510 m1->SetValue(i,1,m1->GetValue(i,0)+1e-10); 511 } 512 if(m1->GetValue(i,1)>=m1->GetValue(i,0)+mmax){ 513 m1->SetValue(i,1,m1->GetValue(i,0)+mmax); 514 } 515 } 516 } 517 m1->ExtractColumn(m1col,1); 518 vec2gridsimple(m1col,m1gr,mx,my); 519 filtergrav(m1grsm,m1gr,ctr,sd,mx,my); 520 reshape(m1grsm,m1col,mx,my); 521 for (int i=0;i<mx*my;i++){ 522 if(icethick->GetValue(i,0)==0){ 523 m1->SetValue(i,1,m1col->GetValue(i,0)); 524 } 525 else{ 526 m1->SetValue(i,1,m0->GetValue(i,1)); 527 } 528 if(m1->GetValue(i,1)<=m1->GetValue(i,0)){ 529 m1->SetValue(i,1,m1->GetValue(i,0)+1e-10); 530 } 531 } 532 533 for (int i=0;i<mx*my;i++){ 534 if(bathy->GetValue(i,0)==0){ 535 u=double (rand())/ double(RAND_MAX); 536 y=signe(u-0.5)*T*(pow(1+1/T,fabs(2*u-1))-1); 537 m1->SetValue(i,2,m0->GetValue(i,2)+y*ptval); 538 if(m1->GetValue(i,2)<=m1->GetValue(i,1)){ 539 m1->SetValue(i,2,m1->GetValue(i,1)+1e-10); 540 } 541 if(m1->GetValue(i,2)>=m1->GetValue(i,1)+mmax2){ 542 m1->SetValue(i,2,m1->GetValue(i,1)+mmax2); 543 } 544 } 545 } 546 m1->ExtractColumn(m1col,2); 547 vec2gridsimple(m1col,m1gr,mx,my); 548 filtergrav(m1grsm,m1gr,ctr,sd,mx,my); 549 reshape(m1grsm,m1col,mx,my); 550 for (int i=0;i<mx*my;i++){ 551 if(bathy->GetValue(i,0)==0){ 552 m1->SetValue(i,2,m1col->GetValue(i,0)); 553 } 554 else{ 555 m1->SetValue(i,2,m0->GetValue(i,2)); 556 } 557 if(m1->GetValue(i,2)<=m1->GetValue(i,1)){ 558 m1->SetValue(i,2,m1->GetValue(i,1)+1e-10); 559 } 560 } 561 delete m1gr; 562 delete m1grsm; 563 delete m1col; 564 }/*}}}*/ 565 double signe(double a){/*{{{*/ 566 if(a<0){return -1;} 567 else{return 1;} 568 }/*}}}*/ 569 void filtergrav(Matrix* A,Matrix* Ain,double ctr,double sd,int mx,int my){/*{{{*/ 570 for (int i=1;i<my-1;i++){ 571 for(int j=1;j<mx-1;j++){ 572 A->SetValue(i,j,(ctr*Ain->GetValue(i,j)+sd*(Ain->GetValue(i-1,j)+Ain->GetValue(i+1,j)+Ain->GetValue(i,j-1)+Ain->GetValue(i,j+1)))/(ctr+4*sd)); 573 } 574 } 575 }/*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.