#include #include #include #include "quern.h" // TO-DO: use BLAS versions of these smaller kernels, if available double two_norm(int n, const double* x) { double r=0; for(int i=0; imax_iterations) break; std::memcpy(u, r, n*sizeof(double)); check=QUERN_solve_with_r_transpose_in_place(n, R_row_start, R_column_index, R_value, u); if(check){ std::free(working_vectors); return check; } check=QUERN_solve_with_r(n, R_row_start, R_column_index, R_value, u, z); if(check){ std::free(working_vectors); return check; } double rho_new=two_norm_squared(n, u); double beta=rho_new/rho; scale_and_add(n, beta, s, z); rho=rho_new; } std::free(working_vectors); return QUERN_OK; }