Changeset 13196
- Timestamp:
- 08/30/12 12:54:28 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/modules/Solverx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/Solverx/Solverx.h
r13195 r13196 24 24 25 25 void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf,Parameters* parameters); 26 void SolverxSeq(IssmPDouble ** pX,IssmPDouble* A,IssmPDouble*B,int n);26 void SolverxSeq(IssmPDouble *X, IssmPDouble *A, IssmPDouble *B,int n); 27 27 28 28 #ifdef _HAVE_ADOLC_ 29 void SolverxSeq(IssmDouble ** pX,IssmDouble* A,IssmDouble*B,int n, Parameters* parameters);29 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters); 30 30 ADOLC_ext_fct EDF_for_solverx; 31 31 #endif -
issm/trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp
r13195 r13196 29 29 int M,N,N2,s; 30 30 SeqVec *uf = NULL; 31 IssmDouble *x = NULL;32 31 33 32 Kff->GetSize(&M,&N); … … 36 35 if(N!=N2)_error_("Right hand side vector of size " << N2 << ", when matrix is of size " << M << "-" << N << " !"); 37 36 if(M!=N)_error_("Stiffness matrix should be square!"); 38 37 IssmDouble *x = xNew<IssmDouble>(N); 39 38 #ifdef _HAVE_ADOLC_ 40 SolverxSeq( &x,Kff->matrix,pf->vector,N,parameters);39 SolverxSeq(x,Kff->matrix,pf->vector,N,parameters); 41 40 #else 42 SolverxSeq( &x,Kff->matrix,pf->vector,N);41 SolverxSeq(x,Kff->matrix,pf->vector,N); 43 42 #endif 44 uf=new SeqVec(x,N); 43 uf=new SeqVec(x,N); 44 xDelete(x); 45 45 46 46 /*Assign output pointers:*/ … … 56 56 int EDF_for_solverx(int n, IssmPDouble *x, int m, IssmPDouble *y) { 57 57 if(m*(m+1)!=n)_error_("Stiffness matrix should be square!"); 58 SolverxSeq( &y,x, x+m*m, m);58 SolverxSeq(y,x, x+m*m, m); 59 59 return 0; 60 60 } 61 61 62 void SolverxSeq(IssmDouble ** pX,IssmDouble* A,IssmDouble*B,int n, Parameters* parameters){//{{{62 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){//{{{ 63 63 // pack inputs to conform to the EDF-prescribed interface 64 IssmDouble* adoubleEDF _X=xNew<IssmDouble>(n*(n+1)); // packed inputs, i.e. matrix and right hand side65 for(int i=0; i<n*n;i++)adoubleEDF _X[i] =A[i]; // pack matrix66 for(int i=0; i<n; i++)adoubleEDF _X[i+n*n]=B[i]; // pack the right hand side67 IssmPDouble* pdoubleEDF _X=xNew<IssmPDouble>(n*(n+1)); // provide space to transfer inputs during call_ext_fct68 IssmPDouble* pdoubleEDF _Y=xNew<IssmPDouble>(n); // provide space to transfer outputs during call_ext_fct64 IssmDouble* adoubleEDFin=xNew<IssmDouble>(n*(n+1)); // packed inputs, i.e. matrix and right hand side 65 for(int i=0; i<n*n;i++)adoubleEDFin[i] =A[i]; // pack matrix 66 for(int i=0; i<n; i++)adoubleEDFin[i+n*n]=B[i]; // pack the right hand side 67 IssmPDouble* pdoubleEDFin=xNew<IssmPDouble>(n*(n+1)); // provide space to transfer inputs during call_ext_fct 68 IssmPDouble* pdoubleEDFout=xNew<IssmPDouble>(n); // provide space to transfer outputs during call_ext_fct 69 69 // call the wrapped solver through the registry entry we retrieve from parameters 70 70 call_ext_fct(dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p, 71 n*(n+1), pdoubleEDF _X, adoubleEDF_X,72 n, pdoubleEDF _Y, B);73 xDelete(adoubleEDF _X);74 xDelete(pdoubleEDF _X);75 xDelete(pdoubleEDF _Y);71 n*(n+1), pdoubleEDFin, adoubleEDFin, 72 n, pdoubleEDFout,X); 73 xDelete(adoubleEDFin); 74 xDelete(pdoubleEDFin); 75 xDelete(pdoubleEDFout); 76 76 } 77 77 /*}}}*/ 78 78 #endif 79 void SolverxSeq(IssmPDouble ** pX,IssmPDouble* A,IssmPDouble* B,int n){ //{{{79 void SolverxSeq(IssmPDouble * X, IssmPDouble * A, IssmPDouble * B,int n){ //{{{ 80 80 #ifdef _HAVE_GSL_ 81 81 /*GSL Matrices and vectors: */ … … 87 87 /*A will be modified by LU decomposition. Use copy*/ 88 88 double* Acopy = xNew<double>(n*n); 89 xMemCpy <double>(Acopy,A,n*n);89 xMemCpy(Acopy,A,n*n); 90 90 91 91 /*Initialize gsl matrices and vectors: */ … … 103 103 104 104 /*Copy result*/ 105 double* X = xNew<double>(n); 106 memcpy(X,gsl_vector_ptr(x,0),n*sizeof(double)); 105 xMemCpy(X,gsl_vector_ptr(x,0),n); 107 106 108 107 /*Clean up and assign output pointer*/ 109 xDelete <double>(Acopy);108 xDelete(Acopy); 110 109 gsl_permutation_free(p); 111 110 gsl_vector_free(x); 112 *pX=X;113 111 #endif 114 112 }
Note:
See TracChangeset
for help on using the changeset viewer.