Changeset 17328


Ignore:
Timestamp:
02/20/14 20:14:39 (11 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added GslTriple solve to have a faster solution of Kriging

Location:
issm/trunk-jpl/src/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/kriging/Observations.cpp

    r17327 r17328  
    401401        /*Solve the three linear systems*/
    402402#if _HAVE_GSL_
    403         DenseGslSolve(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0
    404         DenseGslSolve(&Ginv1, Gamma,ones,n_obs);   // Gamma^-1 ones
    405         DenseGslSolve(&GinvZ, Gamma,obs,n_obs);    // Gamma^-1 Z
     403        DenseGslTripleSolve(&GinvG0,&Ginv1,&GinvZ,Gamma,Gamma,ones,obs,n_obs);
     404        //DenseGslSolve(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0
     405        //DenseGslSolve(&Ginv1, Gamma,ones,n_obs);   // Gamma^-1 ones
     406        //DenseGslSolve(&GinvZ, Gamma,obs,n_obs);    // Gamma^-1 Z
    406407#else
    407408        _error_("GSL is required");
  • issm/trunk-jpl/src/c/toolkits/gsl/DenseGslSolve.cpp

    r15070 r17328  
    3232}
    3333/*}}}*/
    34 void DenseGslSolve(/*output*/ IssmPDouble** px,/*stiffness matrix:*/ IssmPDouble* Kff, int Kff_M, int Kff_N, /*right hand side load vector: */ IssmPDouble* pf, int pf_M, Parameters* parameters){ /*{{{*/
     34void DenseGslSolve(IssmPDouble** px,IssmPDouble* Kff,int Kff_M,int Kff_N,IssmPDouble* pf,int pf_M,Parameters* parameters){ /*{{{*/
    3535
    3636        /*Intermediary: */
     
    4444        /*allocate output pointers: */
    4545        *px=x;
     46}
     47/*}}}*/
     48void DenseGslTripleSolve(IssmPDouble** pX1,IssmPDouble** pX2,IssmPDouble** pX3,IssmPDouble* A,IssmPDouble* B1,IssmPDouble* B2,IssmPDouble* B3,int n){/*{{{*/
     49
     50        /*Allocate output: */
     51        IssmPDouble *X1 = xNew<IssmPDouble>(n);
     52        IssmPDouble *X2 = xNew<IssmPDouble>(n);
     53        IssmPDouble *X3 = xNew<IssmPDouble>(n);
     54
     55#ifdef _HAVE_GSL_
     56        /*GSL Matrices and vectors: */
     57        int s;
     58
     59        double* Acopy = xNew<double>(n*n);
     60        xMemCpy(Acopy,A,n*n);
     61
     62        /*Initialize gsl matrices and vectors: */
     63        gsl_matrix_view a = gsl_matrix_view_array(Acopy,n,n);
     64        gsl_vector_view b1= gsl_vector_view_array(B1,n);
     65        gsl_vector_view b2= gsl_vector_view_array(B2,n);
     66        gsl_vector_view b3= gsl_vector_view_array(B3,n);
     67        gsl_vector_view x1= gsl_vector_view_array(X1,n);
     68        gsl_vector_view x2= gsl_vector_view_array(X2,n);
     69        gsl_vector_view x3= gsl_vector_view_array(X3,n);
     70
     71        /*Run LU and solve: */
     72        gsl_permutation* p = gsl_permutation_alloc (n);
     73        gsl_linalg_LU_decomp(&a.matrix,p,&s);
     74
     75        gsl_linalg_LU_solve(&a.matrix,p,&b1.vector,&x1.vector);
     76        gsl_linalg_LU_solve(&a.matrix,p,&b2.vector,&x2.vector);
     77        gsl_linalg_LU_solve(&a.matrix,p,&b3.vector,&x3.vector);
     78
     79        /*Clean up and assign output pointer*/
     80        xDelete(Acopy);
     81        gsl_permutation_free(p);
     82#endif
     83
     84        /*allocate output pointers: */
     85        *pX1=X1;
     86        *pX2=X2;
     87        *pX3=X3;
    4688}
    4789/*}}}*/
  • issm/trunk-jpl/src/c/toolkits/gsl/gslincludes.h

    r14915 r17328  
    2121
    2222void DenseGslSolve(IssmPDouble** pX,IssmPDouble* A,IssmPDouble* B, int n);
    23 void DenseGslSolve(IssmDouble** px, IssmDouble* Kff,int Kff_M, int Kff_N, IssmDouble* pf, int pf_M, Parameters* parameters);
     23void DenseGslSolve(IssmDouble** pX,IssmDouble* Kff,int Kff_M,int Kff_N,IssmDouble* pf,int pf_M,Parameters* parameters);
     24void DenseGslTripleSolve(IssmPDouble** pX1,IssmPDouble** pX2,IssmPDouble** pX3,IssmPDouble* A,IssmPDouble* B1,IssmPDouble* B2,IssmPDouble* B3,int n);
    2425
    2526void SolverxSeq(IssmPDouble *X, IssmPDouble *A, IssmPDouble *B,int n);
Note: See TracChangeset for help on using the changeset viewer.