void lis_vector_pmul_f(LIS_VECTOR_F *x, LIS_VECTOR_F *y, LIS_VECTOR_F *z, LIS_INT *ierr) { LIS_DEBUG_FUNC_IN; *ierr = lis_vector_pmul((LIS_VECTOR)LIS_V2P(x),(LIS_VECTOR)LIS_V2P(y),(LIS_VECTOR)LIS_V2P(z)); if( *ierr ) return; LIS_DEBUG_FUNC_OUT; return; }
LIS_INT lis_jacobi(LIS_SOLVER solver) { LIS_MATRIX A; LIS_VECTOR b,x; LIS_VECTOR d,r,t,s; LIS_REAL bnrm2,nrm2,tol; LIS_INT iter,maxiter,output; double time,ptime; LIS_DEBUG_FUNC_IN; A = solver->A; b = solver->b; x = solver->x; maxiter = solver->options[LIS_OPTIONS_MAXITER]; output = solver->options[LIS_OPTIONS_OUTPUT]; tol = solver->params[LIS_PARAMS_RESID-LIS_OPTIONS_LEN]; ptime = 0.0; r = solver->work[0]; t = solver->work[1]; s = solver->work[2]; d = solver->work[3]; lis_vector_nrm2(b,&bnrm2); bnrm2 = 1.0 / bnrm2; lis_matrix_get_diagonal(A,d); lis_vector_reciprocal(d); for( iter=1; iter<=maxiter; iter++ ) { /* x += D^{-1}(b - Ax) */ time = lis_wtime(); lis_psolve(solver,x,s); ptime += lis_wtime() - time; lis_matvec(A,s,t); /* lis_matvec(A,x,t);*/ lis_vector_axpyz(-1,t,b,r); lis_vector_nrm2(r,&nrm2); lis_vector_pmul(r,d,r); lis_vector_axpy(1,r,x); /* convergence check */ nrm2 = nrm2 * bnrm2; if( output ) { if( output & LIS_PRINT_MEM ) solver->rhistory[iter] = nrm2; if( output & LIS_PRINT_OUT && A->my_rank==0 ) lis_print_rhistory(iter,nrm2); } if( tol >= nrm2 ) { time = lis_wtime(); lis_psolve(solver,x,s); ptime += lis_wtime() - time; lis_vector_copy(s,x); solver->retcode = LIS_SUCCESS; solver->iter = iter; solver->resid = nrm2; solver->ptime = ptime; LIS_DEBUG_FUNC_OUT; return LIS_SUCCESS; } } lis_psolve(solver,x,s); lis_vector_copy(s,x); solver->retcode = LIS_MAXITER; solver->iter = iter; solver->resid = nrm2; LIS_DEBUG_FUNC_OUT; return LIS_MAXITER; }