[13980] | 1 | Index: ../trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp (revision 13511)
|
---|
| 4 | +++ ../trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp (revision 13512)
|
---|
| 5 | @@ -179,6 +179,28 @@
|
---|
| 6 | return 0;
|
---|
| 7 | }
|
---|
| 8 | /*}}}*/
|
---|
| 9 | +int EDF_fov_reverse_for_solverx(int m, int p, double **dpp_U, int n, double **dpp_Z, double* dp_x, double* dp_y) { /*{{{*/
|
---|
| 10 | + // copy to transpose the matrix
|
---|
| 11 | + double* transposed=xNew<double>(m*m);
|
---|
| 12 | + for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) transposed[j*m+i]=dp_x[i*m+j];
|
---|
| 13 | + gsl_matrix_view aTransposed = gsl_matrix_view_array (transposed,m,m);
|
---|
| 14 | + gsl_permutation *perm_p = gsl_permutation_alloc (m);
|
---|
| 15 | + int permSign;
|
---|
| 16 | + gsl_linalg_LU_decomp (&aTransposed.matrix, perm_p, &permSign);
|
---|
| 17 | + for (int weightsRowIndex=0;weightsRowIndex<p;++weightsRowIndex) {
|
---|
| 18 | + // the adjoint of the solution is our right-hand side
|
---|
| 19 | + gsl_vector_view x_bar=gsl_vector_view_array(dpp_U[weightsRowIndex],m);
|
---|
| 20 | + // the last m elements of dp_Z representing the adjoint of the right-hand side we want to compute:
|
---|
| 21 | + gsl_vector_view b_bar=gsl_vector_view_array(dpp_Z[weightsRowIndex]+m*m,m);
|
---|
| 22 | + gsl_linalg_LU_solve (&aTransposed.matrix, perm_p, &x_bar.vector, &b_bar.vector);
|
---|
| 23 | + // now do the adjoint of the matrix
|
---|
| 24 | + 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];
|
---|
| 25 | + }
|
---|
| 26 | + gsl_permutation_free(perm_p);
|
---|
| 27 | + xDelete(transposed);
|
---|
| 28 | + return 0;
|
---|
| 29 | +}
|
---|
| 30 | +/*}}}*/
|
---|
| 31 | void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){/*{{{*/
|
---|
| 32 | // pack inputs to conform to the EDF-prescribed interface
|
---|
| 33 | // ensure a contiguous block of locations:
|
---|