source: issm/oecreview/Archive/13393-13976/ISSM-13511-13512.diff@ 13980

Last change on this file since 13980 was 13980, checked in by Mathieu Morlighem, 12 years ago

preparing oecreview for 13393-13976'

File size: 1.7 KB
  • ../trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp

     
    179179  return 0;
    180180}
    181181/*}}}*/
     182int EDF_fov_reverse_for_solverx(int m, int p, double **dpp_U, int n, double **dpp_Z, double* dp_x, double* dp_y) { /*{{{*/
     183        // copy to transpose the matrix
     184        double* transposed=xNew<double>(m*m);
     185        for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) transposed[j*m+i]=dp_x[i*m+j];
     186        gsl_matrix_view aTransposed = gsl_matrix_view_array (transposed,m,m);
     187        gsl_permutation *perm_p = gsl_permutation_alloc (m);
     188        int permSign;
     189        gsl_linalg_LU_decomp (&aTransposed.matrix, perm_p, &permSign);
     190        for (int weightsRowIndex=0;weightsRowIndex<p;++weightsRowIndex) {
     191                // the adjoint of the solution is our right-hand side
     192                gsl_vector_view x_bar=gsl_vector_view_array(dpp_U[weightsRowIndex],m);
     193                // the last m elements of dp_Z representing the adjoint of the right-hand side we want to compute:
     194                gsl_vector_view b_bar=gsl_vector_view_array(dpp_Z[weightsRowIndex]+m*m,m);
     195                gsl_linalg_LU_solve (&aTransposed.matrix, perm_p, &x_bar.vector, &b_bar.vector);
     196                // now do the adjoint of the matrix
     197                for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) dpp_Z[weightsRowIndex][i*m+j]-=dpp_Z[weightsRowIndex][m*m+i]*dp_y[j];
     198        }
     199        gsl_permutation_free(perm_p);
     200        xDelete(transposed);
     201        return 0;
     202}
     203/*}}}*/
    182204void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){/*{{{*/
    183205        // pack inputs to conform to the EDF-prescribed interface
    184206        // ensure a contiguous block of locations:
Note: See TracBrowser for help on using the repository browser.