diff --git a/benchmarks/advection_reaction_3D/kokkos/rhs3D.hpp b/benchmarks/advection_reaction_3D/kokkos/rhs3D.hpp index b6cd22fa3d..8e62830f97 100644 --- a/benchmarks/advection_reaction_3D/kokkos/rhs3D.hpp +++ b/benchmarks/advection_reaction_3D/kokkos/rhs3D.hpp @@ -321,7 +321,7 @@ static int AdvectionReactionResidual(sunrealtype t, N_Vector y, N_Vector ydot, if (check_retval((void*)&retval, "Reaction", 1, udata->myid)) { return (-1); } /* F = ydot - h(t,y) = ydot + c y_x - g(t,y) */ - N_VLinearSum(1.0, ydot, -1.0, F, F); + N_VLinearSum(-1.0, F, 1.0, ydot, F); /* return success */ return (0); diff --git a/benchmarks/advection_reaction_3D/raja/rhs3D.hpp b/benchmarks/advection_reaction_3D/raja/rhs3D.hpp index 9821ed4087..f9c46a0dc6 100644 --- a/benchmarks/advection_reaction_3D/raja/rhs3D.hpp +++ b/benchmarks/advection_reaction_3D/raja/rhs3D.hpp @@ -422,7 +422,7 @@ static int AdvectionReactionResidual(sunrealtype t, N_Vector y, N_Vector ydot, if (check_retval((void*)&retval, "Reaction", 1, udata->myid)) { return (-1); } /* F = ydot - h(t,y) = ydot + c y_x - g(t,y) */ - N_VLinearSum(1.0, ydot, -1.0, F, F); + N_VLinearSum(-1.0, F, 1.0, ydot, F); /* return success */ return (0); diff --git a/benchmarks/diffusion_2D/diffusion_2D.cpp b/benchmarks/diffusion_2D/diffusion_2D.cpp index ee2186f76f..8e175ba854 100644 --- a/benchmarks/diffusion_2D/diffusion_2D.cpp +++ b/benchmarks/diffusion_2D/diffusion_2D.cpp @@ -71,7 +71,7 @@ int diffusion(sunrealtype t, N_Vector u, N_Vector up, N_Vector res, if (check_flag(&flag, "laplacian", 1)) return -1; // Compute the residual - N_VLinearSum(ONE, up, -ONE, res, res); + N_VLinearSum(-ONE, res, ONE, up, res); return 0; } @@ -893,7 +893,7 @@ int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/benchmarks/nvector/test_nvector_performance.c b/benchmarks/nvector/test_nvector_performance.c index 5cb3781dce..aeef6d7fca 100644 --- a/benchmarks/nvector/test_nvector_performance.c +++ b/benchmarks/nvector/test_nvector_performance.c @@ -91,7 +91,7 @@ int Test_N_VLinearSum(N_Vector X, sunindextype local_length, int ntests) ClearCache(); start_time = get_time(); - N_VLinearSum(ONE, X, ONE, Y, Y); + N_VLinearSum(ONE, Y, ONE, X, Y); sync_device(X); stop_time = get_time(); @@ -114,7 +114,7 @@ int Test_N_VLinearSum(N_Vector X, sunindextype local_length, int ntests) ClearCache(); start_time = get_time(); - N_VLinearSum(NEG_ONE, X, ONE, Y, Y); + N_VLinearSum(ONE, Y, NEG_ONE, X, Y); sync_device(X); stop_time = get_time(); @@ -138,7 +138,7 @@ int Test_N_VLinearSum(N_Vector X, sunindextype local_length, int ntests) ClearCache(); start_time = get_time(); - N_VLinearSum(a, X, ONE, Y, Y); + N_VLinearSum(ONE, Y, a, X, Y); sync_device(X); stop_time = get_time(); @@ -1573,7 +1573,7 @@ int Test_N_VScaleAddMulti(N_Vector X, sunindextype local_length, int nvecs, { ClearCache(); start_time = get_time(); - for (j = 0; j < nvecs; j++) { N_VLinearSum(c[j], X, ONE, Y[j], Y[j]); } + for (j = 0; j < nvecs; j++) { N_VLinearSum(ONE, Y[j], c[j], X, Y[j]); } sync_device(X); stop_time = get_time(); @@ -2270,7 +2270,7 @@ int Test_N_VScaleAddMultiVectorArray(N_Vector V, sunindextype local_length, { for (j = 0; j < nsums; j++) { - N_VLinearSum(c[j], X[k], ONE, Y[j][k], Y[j][k]); + N_VLinearSum(ONE, Y[j][k], c[j], X[k], Y[j][k]); } } sync_device(V); @@ -2344,7 +2344,7 @@ int Test_N_VScaleAddMultiVectorArray(N_Vector V, sunindextype local_length, { for (j = 0; j < nsums; j++) { - N_VLinearSum(c[j], X[k], ONE, Y[j][k], Z[j][k]); + N_VLinearSum(ONE, Y[j][k], c[j], X[k], Z[j][k]); } } sync_device(V); diff --git a/doc/shared/nvectors/NVector_Operations.rst b/doc/shared/nvectors/NVector_Operations.rst index 25e2cf7357..d0258c0d78 100644 --- a/doc/shared/nvectors/NVector_Operations.rst +++ b/doc/shared/nvectors/NVector_Operations.rst @@ -204,7 +204,7 @@ operations below. .. math:: z_i = a x_i + b y_i, \quad i=0,\ldots,n-1. - The output vector *z* can be the same as either of the input vectors (*x* or *y*). + The output vector *z* can be the same as the input vector (*x*). Usage: diff --git a/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp b/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp index b1fce22049..3f5d5bbc94 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp @@ -1418,7 +1418,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp index 716024ce22..5a4348d046 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp @@ -1552,7 +1552,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp index 3d3fdf00c5..270fc9c12b 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp @@ -1842,7 +1842,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp index 928980ead2..11a7ec3045 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp @@ -2457,7 +2457,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_serial/ark_heat2D.cpp b/examples/arkode/CXX_serial/ark_heat2D.cpp index 83e39e8823..1c0f83a3d9 100644 --- a/examples/arkode/CXX_serial/ark_heat2D.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D.cpp @@ -860,7 +860,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index f7de7638fe..86565ba2bd 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -721,7 +721,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp index fbcd62e06e..41f4814049 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp @@ -2771,7 +2771,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp index 8bdfd1e4b1..6de24c320d 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp @@ -1927,7 +1927,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp index 6a429b888d..eb7ef62624 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp @@ -1234,7 +1234,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/arkode/C_serial/ark_harmonic_symplectic.c b/examples/arkode/C_serial/ark_harmonic_symplectic.c index acc4ddf6ea..59fbfbde6e 100644 --- a/examples/arkode/C_serial/ark_harmonic_symplectic.c +++ b/examples/arkode/C_serial/ark_harmonic_symplectic.c @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) Solution(tret, y, solution, &udata); /* Compute L2 error */ - N_VLinearSum(SUN_RCONST(1.0), y, -SUN_RCONST(1.0), solution, solution); + N_VLinearSum(-SUN_RCONST(1.0), solution, SUN_RCONST(1.0), y, solution); err = sqrt(N_VDotProd(solution, solution)); /* Output current integration status */ diff --git a/examples/arkode/C_serial/ark_onewaycouple_mri.c b/examples/arkode/C_serial/ark_onewaycouple_mri.c index 408b68b3a7..6e11113efb 100644 --- a/examples/arkode/C_serial/ark_onewaycouple_mri.c +++ b/examples/arkode/C_serial/ark_onewaycouple_mri.c @@ -309,7 +309,7 @@ static int ans(sunrealtype t, N_Vector ytrue, void* user_data) static int err(N_Vector y, N_Vector ytrue, sunrealtype* e) { /* compute the error and store it in ytrue */ - N_VLinearSum(SUN_RCONST(1.0), y, SUN_RCONST(-1.0), ytrue, ytrue); + N_VLinearSum(SUN_RCONST(-1.0), ytrue, SUN_RCONST(1.0), y, ytrue); /* compute the max norm of the error */ *e = N_VMaxNorm(ytrue); diff --git a/examples/arkode/C_serial/ark_robertson.c b/examples/arkode/C_serial/ark_robertson.c index 0e189d27cf..7303f3af95 100644 --- a/examples/arkode/C_serial/ark_robertson.c +++ b/examples/arkode/C_serial/ark_robertson.c @@ -327,7 +327,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/arkode/C_serial/ark_robertson_constraints.c b/examples/arkode/C_serial/ark_robertson_constraints.c index 9fc93455f3..5ced5096f4 100644 --- a/examples/arkode/C_serial/ark_robertson_constraints.c +++ b/examples/arkode/C_serial/ark_robertson_constraints.c @@ -369,7 +369,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/cvode/CXX_parallel/cv_heat2D_p.cpp b/examples/cvode/CXX_parallel/cv_heat2D_p.cpp index f6fa704e76..eaedb941eb 100644 --- a/examples/cvode/CXX_parallel/cv_heat2D_p.cpp +++ b/examples/cvode/CXX_parallel/cv_heat2D_p.cpp @@ -1462,7 +1462,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp index 49d9a25b05..3bc883292e 100644 --- a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp +++ b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp @@ -1784,7 +1784,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp index f9decdfbe4..6c33f1c68a 100644 --- a/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp +++ b/examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp @@ -2296,7 +2296,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/cvode/CXX_serial/cv_heat2D.hpp b/examples/cvode/CXX_serial/cv_heat2D.hpp index 8945443769..ea0d09b6ff 100644 --- a/examples/cvode/CXX_serial/cv_heat2D.hpp +++ b/examples/cvode/CXX_serial/cv_heat2D.hpp @@ -143,7 +143,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp b/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp index fa5eeb2286..7160e79bbb 100644 --- a/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp +++ b/examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp @@ -212,7 +212,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata) if (flag != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/cvode/serial/cvParticle_dns.c b/examples/cvode/serial/cvParticle_dns.c index 19e7482794..cc98ca4583 100644 --- a/examples/cvode/serial/cvParticle_dns.c +++ b/examples/cvode/serial/cvParticle_dns.c @@ -506,7 +506,7 @@ static int ComputeError(sunrealtype t, N_Vector y, N_Vector e, sunrealtype* ec, /* solution error */ retval = ComputeSolution(t, e, udata); if (check_retval(&retval, "ComputeSolution", 1)) { return (1); } - N_VLinearSum(ONE, y, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, y, e); /* constraint error */ *ec = ydata[0] * ydata[0] + ydata[1] * ydata[1] - ONE; diff --git a/examples/cvode/serial/cvRoberts_dns.c b/examples/cvode/serial/cvRoberts_dns.c index d480f37285..aa9f217d57 100644 --- a/examples/cvode/serial/cvRoberts_dns.c +++ b/examples/cvode/serial/cvRoberts_dns.c @@ -409,7 +409,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/cvode/serial/cvRoberts_dns_constraints.c b/examples/cvode/serial/cvRoberts_dns_constraints.c index 927e8e36cf..f7c4690dfd 100644 --- a/examples/cvode/serial/cvRoberts_dns_constraints.c +++ b/examples/cvode/serial/cvRoberts_dns_constraints.c @@ -459,7 +459,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/cvodes/serial/cvsParticle_dns.c b/examples/cvodes/serial/cvsParticle_dns.c index b8d2cb22cd..8077cacada 100644 --- a/examples/cvodes/serial/cvsParticle_dns.c +++ b/examples/cvodes/serial/cvsParticle_dns.c @@ -506,7 +506,7 @@ static int ComputeError(sunrealtype t, N_Vector y, N_Vector e, sunrealtype* ec, /* solution error */ retval = ComputeSolution(t, e, udata); if (check_retval(&retval, "ComputeSolution", 1)) { return (1); } - N_VLinearSum(ONE, y, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, y, e); /* constraint error */ *ec = ydata[0] * ydata[0] + ydata[1] * ydata[1] - ONE; diff --git a/examples/cvodes/serial/cvsRoberts_dns.c b/examples/cvodes/serial/cvsRoberts_dns.c index 8b88621efb..2b5761d556 100644 --- a/examples/cvodes/serial/cvsRoberts_dns.c +++ b/examples/cvodes/serial/cvsRoberts_dns.c @@ -409,7 +409,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/cvodes/serial/cvsRoberts_dns_constraints.c b/examples/cvodes/serial/cvsRoberts_dns_constraints.c index 1db5f29cf1..ce889c2674 100644 --- a/examples/cvodes/serial/cvsRoberts_dns_constraints.c +++ b/examples/cvodes/serial/cvsRoberts_dns_constraints.c @@ -459,7 +459,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/ida/serial/idaAnalytic_mels.c b/examples/ida/serial/idaAnalytic_mels.c index 2cd01d06c5..dab93d96ce 100644 --- a/examples/ida/serial/idaAnalytic_mels.c +++ b/examples/ida/serial/idaAnalytic_mels.c @@ -380,7 +380,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ytrue, ytrue); + N_VLinearSum(-ONE, ytrue, ONE, y, ytrue); err = N_VWrmsNorm(ytrue, ewt); /* is the solution within the tolerances? */ diff --git a/examples/ida/serial/idaRoberts_dns.c b/examples/ida/serial/idaRoberts_dns.c index 4284395e3c..410c50e4fe 100644 --- a/examples/ida/serial/idaRoberts_dns.c +++ b/examples/ida/serial/idaRoberts_dns.c @@ -458,7 +458,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/idas/serial/idasAnalytic_mels.c b/examples/idas/serial/idasAnalytic_mels.c index c15314b9e9..fd05cf49a2 100644 --- a/examples/idas/serial/idasAnalytic_mels.c +++ b/examples/idas/serial/idasAnalytic_mels.c @@ -380,7 +380,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ytrue, ytrue); + N_VLinearSum(-ONE, ytrue, ONE, y, ytrue); err = N_VWrmsNorm(ytrue, ewt); /* is the solution within the tolerances? */ diff --git a/examples/idas/serial/idasRoberts_dns.c b/examples/idas/serial/idasRoberts_dns.c index 1c88050692..7913cc1dd8 100644 --- a/examples/idas/serial/idasRoberts_dns.c +++ b/examples/idas/serial/idasRoberts_dns.c @@ -458,7 +458,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol) N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, y, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, y, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp index 7e89a7d7bf..669b8d84b0 100644 --- a/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp +++ b/examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp @@ -620,13 +620,13 @@ static int FPFunction(N_Vector u, N_Vector f, void* user_data) // Add c(u) retval = c(u, udata->vtemp, user_data); if (check_retval(&retval, "c(u)", 1)) { return 1; } - N_VLinearSum(ONE, udata->vtemp, ONE, f, f); + N_VLinearSum(ONE, f, ONE, udata->vtemp, f); // Add u - N_VLinearSum(ONE, u, ONE, f, f); + N_VLinearSum(ONE, f, ONE, u, f); // Subtract b - N_VLinearSum(-ONE, udata->b, ONE, f, f); + N_VLinearSum(ONE, f, -ONE, udata->b, f); // Stop timer double t2 = MPI_Wtime(); @@ -746,7 +746,7 @@ static int SetupRHS(void* user_data) if (check_retval(&retval, "c(u)", 1)) { return 1; } // b = kx u_xx (u_exact) + ky u_yy (u_exact) + c(u_exact) - N_VLinearSum(ONE, udata->vtemp, ONE, udata->b, udata->b); + N_VLinearSum(ONE, udata->b, ONE, udata->vtemp, udata->b); // Return success return 0; @@ -1284,7 +1284,7 @@ static int SolutionError(N_Vector u, N_Vector e, UserData* udata) if (retval != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp b/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp index 7b06cc7877..8c42dab6b5 100644 --- a/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp +++ b/examples/kinsol/CXX_parhyp/kin_heat2D_nonlin_hypre_pfmg.cpp @@ -642,7 +642,7 @@ static int SetupRHS(void* user_data) if (check_retval(&retval, "c(u)", 1)) { return 1; } // b = Au_exact + c(u_xact) - N_VLinearSum(ONE, udata->vtemp, ONE, udata->b, udata->b); + N_VLinearSum(ONE, udata->b, ONE, udata->vtemp, udata->b); // Return success return 0; @@ -1762,7 +1762,7 @@ static int SolutionError(N_Vector u, N_Vector e, UserData* udata) if (retval != 0) { return -1; } // Compute absolute error - N_VLinearSum(ONE, u, -ONE, e, e); + N_VLinearSum(-ONE, e, ONE, u, e); N_VAbs(e, e); return 0; diff --git a/examples/kinsol/serial/kinRoberts_fp.c b/examples/kinsol/serial/kinRoberts_fp.c index 37172c118b..cfda59cd80 100644 --- a/examples/kinsol/serial/kinRoberts_fp.c +++ b/examples/kinsol/serial/kinRoberts_fp.c @@ -349,7 +349,7 @@ static int check_ans(N_Vector u, sunrealtype rtol, sunrealtype atol) N_VInv(ewt, ewt); /* compute the solution error */ - N_VLinearSum(ONE, u, -ONE, ref, ref); + N_VLinearSum(-ONE, ref, ONE, u, ref); err = N_VWrmsNorm(ref, ewt); /* is the solution within the tolerances? */ diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index eefba1aee8..bb531faa80 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2603,7 +2603,7 @@ sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist) N_VAbs(ark_mem->yn, temp2); ark_mem->efun(ark_mem->yn, temp1, ark_mem->e_data); N_VInv(temp1, temp1); - N_VLinearSum(H0_UBFACTOR, temp2, ONE, temp1, temp1); + N_VLinearSum(ONE, temp1, H0_UBFACTOR, temp2, temp1); N_VAbs(ark_mem->fn, temp2); diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 0093728575..fc1a38bbe4 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -3102,7 +3102,7 @@ int arkStep_ComputeSolutions_MassFixed(ARKodeMem ark_mem, sunrealtype* dsmPtr) } /* compute y = yn + update */ - N_VLinearSum(ONE, ark_mem->yn, ONE, y, y); + N_VLinearSum(ONE, y, ONE, ark_mem->yn, y); } /* compute yerr (if step adaptivity enabled) */ diff --git a/src/arkode/arkode_ls.c b/src/arkode/arkode_ls.c index adee4bd227..fcdf8f8a1e 100644 --- a/src/arkode/arkode_ls.c +++ b/src/arkode/arkode_ls.c @@ -2357,9 +2357,9 @@ int arkLsATimes(void* arkode_mem, N_Vector v, N_Vector z) { retval = arkLsMTimes(arkode_mem, v, arkls_mem->ytemp); if (retval != 0) { return (retval); } - N_VLinearSum(ONE, arkls_mem->ytemp, -gamma, z, z); + N_VLinearSum(-gamma, z, ONE, arkls_mem->ytemp, z); } - else { N_VLinearSum(ONE, v, -gamma, z, z); } + else { N_VLinearSum(-gamma, z, ONE, v, z); } return (0); } diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index d86af26b87..92371ec146 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -1244,7 +1244,7 @@ int lsrkStep_TakeStepSSPs2(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr SUNLogExtraDebugVec(ARK_LOGGER, "embedded solution", ark_mem->tempv1, "y_embedded(:) ="); - N_VLinearSum(ONE, ark_mem->ycur, -ONE, ark_mem->tempv1, ark_mem->tempv1); + N_VLinearSum(-ONE, ark_mem->tempv1, ONE, ark_mem->ycur, ark_mem->tempv1); *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); } @@ -1526,7 +1526,7 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr { SUNLogExtraDebugVec(ARK_LOGGER, "embedded solution", ark_mem->tempv1, "y_embedded(:) ="); - N_VLinearSum(ONE, ark_mem->ycur, -ONE, ark_mem->tempv1, ark_mem->tempv1); + N_VLinearSum(-ONE, ark_mem->tempv1, ONE, ark_mem->ycur, ark_mem->tempv1); *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); } @@ -1738,7 +1738,7 @@ int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr SUNLogExtraDebugVec(ARK_LOGGER, "embedded solution", ark_mem->tempv1, "y_embedded(:) ="); - N_VLinearSum(ONE, ark_mem->ycur, -ONE, ark_mem->tempv1, ark_mem->tempv1); + N_VLinearSum(-ONE, ark_mem->tempv1, ONE, ark_mem->ycur, ark_mem->tempv1); *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); } @@ -1870,8 +1870,8 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt N_VLinearSum(SUN_RCONST(1.0) / SUN_RCONST(25.0), ark_mem->tempv2, SUN_RCONST(9.0) / SUN_RCONST(25.0), ark_mem->ycur, ark_mem->tempv2); - N_VLinearSum(SUN_RCONST(15.0), ark_mem->tempv2, SUN_RCONST(-5.0), - ark_mem->ycur, ark_mem->ycur); + N_VLinearSum(SUN_RCONST(-5.0), ark_mem->ycur, SUN_RCONST(15.0), + ark_mem->tempv2, ark_mem->ycur); /* apply user-supplied stage postprocessing function (if supplied) */ if (ark_mem->ProcessStage != NULL) @@ -1967,7 +1967,7 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt { SUNLogExtraDebugVec(ARK_LOGGER, "embedded solution", ark_mem->tempv1, "y_embedded(:) ="); - N_VLinearSum(ONE, ark_mem->ycur, -ONE, ark_mem->tempv1, ark_mem->tempv1); + N_VLinearSum(-ONE, ark_mem->tempv1, ONE, ark_mem->ycur, ark_mem->tempv1); *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 2cdc1d9f17..dbfa7d4e83 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1431,12 +1431,12 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, else if (step_mem->implicit_rhs) { /* implicit */ - N_VLinearSum(ONE, step_mem->Fsi[0], ONE, f, f); + N_VLinearSum(ONE, f, ONE, step_mem->Fsi[0], f); } else { /* explicit */ - N_VLinearSum(ONE, step_mem->Fse[0], ONE, f, f); + N_VLinearSum(ONE, f, ONE, step_mem->Fse[0], f); } break; diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index cfd3123c6e..9268884124 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -2242,7 +2242,7 @@ static sunrealtype cvUpperBoundH0(CVodeMem cv_mem, sunrealtype tdist) N_VAbs(cv_mem->cv_zn[0], temp2); cv_mem->cv_efun(cv_mem->cv_zn[0], temp1, cv_mem->cv_e_data); N_VInv(temp1, temp1); - N_VLinearSum(HUB_FACTOR, temp2, ONE, temp1, temp1); + N_VLinearSum(ONE, temp1, HUB_FACTOR, temp2, temp1); N_VAbs(cv_mem->cv_zn[1], temp2); @@ -3134,7 +3134,7 @@ static int cvCheckConstraints(CVodeMem cv_mem) N_VCompare(ONEPT5, cv_mem->cv_constraints, tmp); /* a[i]=1 when |c[i]|=2 */ N_VProd(tmp, cv_mem->cv_constraints, tmp); /* a * c */ N_VDiv(tmp, cv_mem->cv_ewt, tmp); /* a * c * wt */ - N_VLinearSum(ONE, cv_mem->cv_y, -PT1, tmp, tmp); /* y - 0.1 * a * c * wt */ + N_VLinearSum(-PT1, tmp, ONE, cv_mem->cv_y, tmp); /* y - 0.1 * a * c * wt */ N_VProd(tmp, mm, tmp); /* v = mm*(y-0.1*a*c*wt) */ } diff --git a/src/cvode/cvode_diag.c b/src/cvode/cvode_diag.c index 193ca9dc09..1922bb4ecd 100644 --- a/src/cvode/cvode_diag.c +++ b/src/cvode/cvode_diag.c @@ -375,7 +375,7 @@ static int CVDiagSetup(CVodeMem cv_mem, SUNDIALS_MAYBE_UNUSED int convfail, #endif { N_VLinearSum(ONE, M, -ONE, fpred, M); - N_VLinearSum(FRACT, ftemp, -h, M, M); + N_VLinearSum(-h, M, FRACT, ftemp, M); N_VProd(ftemp, ewt, y); /* Protect against deltay_i being at roundoff level */ N_VCompare(uround, y, bit); diff --git a/src/cvode/cvode_fused_stubs.c b/src/cvode/cvode_fused_stubs.c index 42f4820200..6239407f82 100644 --- a/src/cvode/cvode_fused_stubs.c +++ b/src/cvode/cvode_fused_stubs.c @@ -80,7 +80,7 @@ int cvCheckConstraints_fused(const N_Vector c, const N_Vector ewt, N_VCompare(ONEPT5, c, tmp); /* a[i]=1 when |c[i]|=2 */ N_VProd(tmp, c, tmp); /* a * c */ N_VDiv(tmp, ewt, tmp); /* a * c * wt */ - N_VLinearSum(ONE, y, -PT1, tmp, tmp); /* y - 0.1 * a * c * wt */ + N_VLinearSum(-PT1, tmp, ONE, y, tmp); /* y - 0.1 * a * c * wt */ N_VProd(tmp, mm, tmp); /* v = mm*(y-0.1*a*c*wt) */ return 0; } @@ -96,7 +96,7 @@ int cvNlsResid_fused(const sunrealtype rl1, const sunrealtype ngamma, const N_Vector ftemp, N_Vector res) { N_VLinearSum(rl1, zn1, ONE, ycor, res); - N_VLinearSum(ngamma, ftemp, ONE, res, res); + N_VLinearSum(ONE, res, ngamma, ftemp, res); return 0; } @@ -129,7 +129,7 @@ int cvDiagSetup_buildM(SUNDIALS_MAYBE_UNUSED const sunrealtype fract, N_Vector y, N_Vector M) { N_VLinearSum(ONE, M, -ONE, fpred, M); - N_VLinearSum(FRACT, ftemp, -h, M, M); + N_VLinearSum(-h, M, FRACT, ftemp, M); N_VProd(ftemp, ewt, y); /* Protect against deltay_i being at roundoff level */ N_VCompare(uround, y, bit); diff --git a/src/cvode/cvode_ls.c b/src/cvode/cvode_ls.c index 2a0a333e90..46da3b6250 100644 --- a/src/cvode/cvode_ls.c +++ b/src/cvode/cvode_ls.c @@ -907,7 +907,7 @@ int cvLsATimes(void* cvode_mem, N_Vector v, N_Vector z) if (retval != 0) { return (retval); } /* add contribution from identity matrix */ - N_VLinearSum(ONE, v, -cv_mem->cv_gamma, z, z); + N_VLinearSum(-cv_mem->cv_gamma, z, ONE, v, z); return (0); } diff --git a/src/cvode/cvode_nls.c b/src/cvode/cvode_nls.c index 868cbead69..e2ca4aef41 100644 --- a/src/cvode/cvode_nls.c +++ b/src/cvode/cvode_nls.c @@ -389,7 +389,7 @@ static int cvNlsResidual(N_Vector ycor, N_Vector res, void* cvode_mem) #endif { N_VLinearSum(cv_mem->cv_rl1, cv_mem->cv_zn[1], ONE, ycor, res); - N_VLinearSum(-cv_mem->cv_gamma, cv_mem->cv_ftemp, ONE, res, res); + N_VLinearSum(ONE, res, -cv_mem->cv_gamma, cv_mem->cv_ftemp, res); } return (CV_SUCCESS); diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c index 6d19dd35ed..909dbc3937 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -5576,7 +5576,7 @@ static sunrealtype cvUpperBoundH0(CVodeMem cv_mem, sunrealtype tdist) N_VAbs(cv_mem->cv_zn[0], temp2); cv_mem->cv_efun(cv_mem->cv_zn[0], temp1, cv_mem->cv_e_data); N_VInv(temp1, temp1); - N_VLinearSum(HUB_FACTOR, temp2, ONE, temp1, temp1); + N_VLinearSum(ONE, temp1, HUB_FACTOR, temp2, temp1); N_VAbs(cv_mem->cv_zn[1], temp2); @@ -5593,7 +5593,7 @@ static sunrealtype cvUpperBoundH0(CVodeMem cv_mem, sunrealtype tdist) N_VAbs(cv_mem->cv_znQ[0], tempQ2); cvQuadEwtSet(cv_mem, cv_mem->cv_znQ[0], tempQ1); N_VInv(tempQ1, tempQ1); - N_VLinearSum(HUB_FACTOR, tempQ2, ONE, tempQ1, tempQ1); + N_VLinearSum(ONE, tempQ1, HUB_FACTOR, tempQ2, tempQ1); N_VAbs(cv_mem->cv_znQ[1], tempQ2); @@ -5614,7 +5614,7 @@ static sunrealtype cvUpperBoundH0(CVodeMem cv_mem, sunrealtype tdist) { N_VAbs(cv_mem->cv_znS[0][is], temp2); N_VInv(tempS1[is], temp1); - N_VLinearSum(HUB_FACTOR, temp2, ONE, temp1, temp1); + N_VLinearSum(ONE, temp1, HUB_FACTOR, temp2, temp1); N_VAbs(cv_mem->cv_znS[1][is], temp2); @@ -5639,7 +5639,7 @@ static sunrealtype cvUpperBoundH0(CVodeMem cv_mem, sunrealtype tdist) { N_VAbs(cv_mem->cv_znQS[0][is], tempQ2); N_VInv(tempQS1[is], tempQ1); - N_VLinearSum(HUB_FACTOR, tempQ2, ONE, tempQ1, tempQ1); + N_VLinearSum(ONE, tempQ1, HUB_FACTOR, tempQ2, tempQ1); N_VAbs(cv_mem->cv_znQS[1][is], tempQ2); @@ -7069,7 +7069,7 @@ static int cvCheckConstraints(CVodeMem cv_mem) N_VCompare(ONEPT5, cv_mem->cv_constraints, tmp); /* a[i]=1 when |c[i]|=2 */ N_VProd(tmp, cv_mem->cv_constraints, tmp); /* a * c */ N_VDiv(tmp, cv_mem->cv_ewt, tmp); /* a * c * wt */ - N_VLinearSum(ONE, cv_mem->cv_y, -PT1, tmp, tmp); /* y - 0.1 * a * c * wt */ + N_VLinearSum(-PT1, tmp, ONE, cv_mem->cv_y, tmp); /* y - 0.1 * a * c * wt */ N_VProd(tmp, mm, tmp); /* v = mm*(y-0.1*a*c*wt) */ vnorm = N_VWrmsNorm(tmp, cv_mem->cv_ewt); /* ||v|| */ diff --git a/src/cvodes/cvodes_diag.c b/src/cvodes/cvodes_diag.c index d1de7ff4ea..9833c74889 100644 --- a/src/cvodes/cvodes_diag.c +++ b/src/cvodes/cvodes_diag.c @@ -364,7 +364,7 @@ static int CVDiagSetup(CVodeMem cv_mem, SUNDIALS_MAYBE_UNUSED int convfail, /* Construct M = I - gamma*J with J = diag(deltaf_i/deltay_i) */ N_VLinearSum(ONE, M, -ONE, fpred, M); - N_VLinearSum(FRACT, ftemp, -h, M, M); + N_VLinearSum(-h, M, FRACT, ftemp, M); N_VProd(ftemp, ewt, y); /* Protect against deltay_i being at roundoff level */ N_VCompare(uround, y, bit); diff --git a/src/cvodes/cvodes_ls.c b/src/cvodes/cvodes_ls.c index 041e5c8141..fc5fc93cc6 100644 --- a/src/cvodes/cvodes_ls.c +++ b/src/cvodes/cvodes_ls.c @@ -985,7 +985,7 @@ int cvLsATimes(void* cvode_mem, N_Vector v, N_Vector z) if (retval != 0) { return (retval); } /* add contribution from identity matrix */ - N_VLinearSum(ONE, v, -cv_mem->cv_gamma, z, z); + N_VLinearSum(-cv_mem->cv_gamma, z, ONE, v, z); return (0); } diff --git a/src/cvodes/cvodes_nls.c b/src/cvodes/cvodes_nls.c index 0b35c00473..b4f89b6774 100644 --- a/src/cvodes/cvodes_nls.c +++ b/src/cvodes/cvodes_nls.c @@ -374,7 +374,7 @@ static int cvNlsResidual(N_Vector ycor, N_Vector res, void* cvode_mem) /* compute the resiudal */ N_VLinearSum(cv_mem->cv_rl1, cv_mem->cv_zn[1], ONE, ycor, res); - N_VLinearSum(-cv_mem->cv_gamma, cv_mem->cv_ftemp, ONE, res, res); + N_VLinearSum(ONE, res, -cv_mem->cv_gamma, cv_mem->cv_ftemp, res); return (CV_SUCCESS); } diff --git a/src/cvodes/cvodes_nls_sim.c b/src/cvodes/cvodes_nls_sim.c index a5396e32f2..f999877840 100644 --- a/src/cvodes/cvodes_nls_sim.c +++ b/src/cvodes/cvodes_nls_sim.c @@ -483,7 +483,7 @@ static int cvNlsResidualSensSim(N_Vector ycorSim, N_Vector resSim, void* cvode_m /* compute the resiudal */ N_VLinearSum(cv_mem->cv_rl1, cv_mem->cv_zn[1], ONE, ycor, res); - N_VLinearSum(-cv_mem->cv_gamma, cv_mem->cv_ftemp, ONE, res, res); + N_VLinearSum(ONE, res, -cv_mem->cv_gamma, cv_mem->cv_ftemp, res); /* extract sensitivity and residual vectors from the vector wrapper */ ycorS = NV_VECS_SW(ycorSim) + 1; diff --git a/src/cvodes/cvodes_nls_stg1.c b/src/cvodes/cvodes_nls_stg1.c index 46c66de694..daada4606c 100644 --- a/src/cvodes/cvodes_nls_stg1.c +++ b/src/cvodes/cvodes_nls_stg1.c @@ -336,7 +336,7 @@ static int cvNlsResidualSensStg1(N_Vector ycor, N_Vector res, void* cvode_mem) /* compute the sensitivity resiudal */ N_VLinearSum(cv_mem->cv_rl1, cv_mem->cv_znS[1][is], ONE, ycor, res); - N_VLinearSum(-cv_mem->cv_gamma, cv_mem->cv_ftempS[is], ONE, res, res); + N_VLinearSum(ONE, res, -cv_mem->cv_gamma, cv_mem->cv_ftempS[is], res); return (CV_SUCCESS); } diff --git a/src/ida/ida.c b/src/ida/ida.c index b964d0d8f3..f9b6107c66 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2798,7 +2798,7 @@ static int IDANls(IDAMem IDA_mem) N_VCompare(ONEPT5, IDA_mem->ida_constraints, tmp); /* a[i] =1 when |c[i]| = 2 */ N_VProd(tmp, IDA_mem->ida_constraints, tmp); /* a * c */ N_VDiv(tmp, IDA_mem->ida_ewt, tmp); /* a * c * wt */ - N_VLinearSum(ONE, IDA_mem->ida_yy, -PT1, tmp, tmp); /* y - 0.1 * a * c * wt */ + N_VLinearSum(-PT1, tmp, ONE, IDA_mem->ida_yy, tmp); /* y - 0.1 * a * c * wt */ N_VProd(tmp, mm, tmp); /* v = mm*(y-.1*a*c*wt) */ vnorm = IDAWrmsNorm(IDA_mem, tmp, IDA_mem->ida_ewt, SUNFALSE); /* ||v|| */ @@ -2903,8 +2903,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, if (IDA_mem->ida_kk > 2) { /* Compute error at order k-2 */ - N_VLinearSum(ONE, IDA_mem->ida_phi[IDA_mem->ida_kk - 1], ONE, - IDA_mem->ida_delta, IDA_mem->ida_delta); + N_VLinearSum(ONE, IDA_mem->ida_delta, ONE, + IDA_mem->ida_phi[IDA_mem->ida_kk - 1], IDA_mem->ida_delta); enorm_km2 = IDAWrmsNorm(IDA_mem, IDA_mem->ida_delta, IDA_mem->ida_ewt, IDA_mem->ida_suppressalg); err_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * enorm_km2; diff --git a/src/ida/ida_ic.c b/src/ida/ida_ic.c index ac513aea0d..2a3e2466fb 100644 --- a/src/ida/ida_ic.c +++ b/src/ida/ida_ic.c @@ -623,7 +623,7 @@ static int IDANewyyp(IDAMem IDA_mem, sunrealtype lambda) N_VProd(IDA_mem->ida_id, IDA_mem->ida_delta, IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_yp0, -IDA_mem->ida_cj * lambda, IDA_mem->ida_dtemp, IDA_mem->ida_ypnew); - N_VLinearSum(ONE, IDA_mem->ida_delta, -ONE, IDA_mem->ida_dtemp, + N_VLinearSum(-ONE, IDA_mem->ida_dtemp, ONE, IDA_mem->ida_delta, IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_yy0, -lambda, IDA_mem->ida_dtemp, IDA_mem->ida_ynew); @@ -654,7 +654,7 @@ static int IDANewy(IDAMem IDA_mem) if (IDA_mem->ida_icopt == IDA_YA_YDP_INIT) { N_VProd(IDA_mem->ida_id, IDA_mem->ida_delta, IDA_mem->ida_dtemp); - N_VLinearSum(ONE, IDA_mem->ida_delta, -ONE, IDA_mem->ida_dtemp, + N_VLinearSum(-ONE, IDA_mem->ida_dtemp, ONE, IDA_mem->ida_delta, IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_yy0, -ONE, IDA_mem->ida_dtemp, IDA_mem->ida_ynew); diff --git a/src/idas/idas.c b/src/idas/idas.c index c4c48d0b8b..d06bc4a0e8 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -6442,7 +6442,7 @@ static int IDANls(IDAMem IDA_mem) N_VCompare(ONEPT5, IDA_mem->ida_constraints, tmp); /* a[i] =1 when |c[i]| = 2 */ N_VProd(tmp, IDA_mem->ida_constraints, tmp); /* a * c */ N_VDiv(tmp, IDA_mem->ida_ewt, tmp); /* a * c * wt */ - N_VLinearSum(ONE, IDA_mem->ida_yy, -PT1, tmp, tmp); /* y - 0.1 * a * c * wt */ + N_VLinearSum(-PT1, tmp, ONE, IDA_mem->ida_yy, tmp); /* y - 0.1 * a * c * wt */ N_VProd(tmp, mm, tmp); /* v = mm*(y-.1*a*c*wt) */ vnorm = IDAWrmsNorm(IDA_mem, tmp, IDA_mem->ida_ewt, SUNFALSE); /* ||v|| */ @@ -6740,8 +6740,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, if (IDA_mem->ida_kk > 2) { /* Compute error at order k-2 */ - N_VLinearSum(ONE, IDA_mem->ida_phi[IDA_mem->ida_kk - 1], ONE, - IDA_mem->ida_delta, IDA_mem->ida_delta); + N_VLinearSum(ONE, IDA_mem->ida_delta, ONE, + IDA_mem->ida_phi[IDA_mem->ida_kk - 1], IDA_mem->ida_delta); enorm_km2 = IDAWrmsNorm(IDA_mem, IDA_mem->ida_delta, IDA_mem->ida_ewt, IDA_mem->ida_suppressalg); *err_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * enorm_km2; @@ -6838,7 +6838,7 @@ static int IDAQuadTestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, if (IDA_mem->ida_kk > 2) { /* Update error at order k-2 */ - N_VLinearSum(ONE, IDA_mem->ida_phiQ[IDA_mem->ida_kk - 1], ONE, tempv, + N_VLinearSum(ONE, tempv, ONE, IDA_mem->ida_phiQ[IDA_mem->ida_kk - 1], tempv); errQ_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * N_VWrmsNorm(tempv, IDA_mem->ida_ewtQ); @@ -6934,9 +6934,9 @@ static int IDASensTestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, if (IDA_mem->ida_kk > 2) { /* Update error at order k-2 */ - retval = N_VLinearSumVectorArray(IDA_mem->ida_Ns, ONE, + retval = N_VLinearSumVectorArray(IDA_mem->ida_Ns, ONE, tempv, ONE, IDA_mem->ida_phiS[IDA_mem->ida_kk - 1], - ONE, tempv, tempv); + tempv); if (retval != IDA_SUCCESS) { return (IDA_VECTOROP_ERR); } errS_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * @@ -7035,9 +7035,9 @@ static int IDAQuadSensTestError(IDAMem IDA_mem, sunrealtype ck, if (IDA_mem->ida_kk > 2) { /* Update error at order k-2 */ - retval = N_VLinearSumVectorArray(IDA_mem->ida_Ns, ONE, + retval = N_VLinearSumVectorArray(IDA_mem->ida_Ns, ONE, tempv, ONE, IDA_mem->ida_phiQS[IDA_mem->ida_kk - 1], - ONE, tempv, tempv); + tempv); if (retval != IDA_SUCCESS) { return (IDA_VECTOROP_ERR); } errQS_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * diff --git a/src/idas/idas_ic.c b/src/idas/idas_ic.c index 85b36d703a..247e1fc5f4 100644 --- a/src/idas/idas_ic.c +++ b/src/idas/idas_ic.c @@ -953,7 +953,7 @@ static int IDANewyyp(IDAMem IDA_mem, sunrealtype lambda) N_VProd(IDA_mem->ida_id, IDA_mem->ida_delta, IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_yp0, -IDA_mem->ida_cj * lambda, IDA_mem->ida_dtemp, IDA_mem->ida_ypnew); - N_VLinearSum(ONE, IDA_mem->ida_delta, -ONE, IDA_mem->ida_dtemp, + N_VLinearSum(-ONE, IDA_mem->ida_dtemp, ONE, IDA_mem->ida_delta, IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_yy0, -lambda, IDA_mem->ida_dtemp, IDA_mem->ida_ynew); @@ -991,7 +991,7 @@ static int IDANewy(IDAMem IDA_mem) if (IDA_mem->ida_icopt == IDA_YA_YDP_INIT) { N_VProd(IDA_mem->ida_id, IDA_mem->ida_delta, IDA_mem->ida_dtemp); - N_VLinearSum(ONE, IDA_mem->ida_delta, -ONE, IDA_mem->ida_dtemp, + N_VLinearSum(-ONE, IDA_mem->ida_dtemp, ONE, IDA_mem->ida_delta, IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_yy0, -ONE, IDA_mem->ida_dtemp, IDA_mem->ida_ynew); @@ -1342,7 +1342,7 @@ static int IDASensNewyyp(IDAMem IDA_mem, sunrealtype lambda) N_VProd(IDA_mem->ida_id, IDA_mem->ida_deltaS[is], IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_ypS0[is], -IDA_mem->ida_cj * lambda, IDA_mem->ida_dtemp, IDA_mem->ida_ypS0new[is]); - N_VLinearSum(ONE, IDA_mem->ida_deltaS[is], -ONE, IDA_mem->ida_dtemp, + N_VLinearSum(-ONE, IDA_mem->ida_dtemp, ONE, IDA_mem->ida_deltaS[is], IDA_mem->ida_dtemp); N_VLinearSum(ONE, IDA_mem->ida_yyS0[is], -lambda, IDA_mem->ida_dtemp, IDA_mem->ida_yyS0new[is]); diff --git a/src/kinsol/kinsol.c b/src/kinsol/kinsol.c index e474682f7b..d68c3ffeca 100644 --- a/src/kinsol/kinsol.c +++ b/src/kinsol/kinsol.c @@ -2803,7 +2803,7 @@ static int KINPicardFcnEval(KINMem kin_mem, N_Vector gval, N_Vector uval, if (retval == 0) { /* Update gval = uval + gval since gval = -L^{-1}F(uu) */ - N_VLinearSum(ONE, uval, ONE, gval, gval); + N_VLinearSum(ONE, gval, ONE, uval, gval); return (KIN_SUCCESS); } else if (retval < 0) { return (KIN_LSOLVE_FAIL); } @@ -3061,7 +3061,7 @@ static int AndersonAcc(KINMem kin_mem, N_Vector gval, N_Vector fv, N_Vector x, } N_VLinearSum(c, kin_mem->kin_q_aa[i], s, kin_mem->kin_q_aa[i + 1], kin_mem->kin_vtemp2); - N_VLinearSum(-s, kin_mem->kin_q_aa[i], c, kin_mem->kin_q_aa[i + 1], + N_VLinearSum(c, kin_mem->kin_q_aa[i + 1], -s, kin_mem->kin_q_aa[i], kin_mem->kin_q_aa[i + 1]); N_VScale(ONE, kin_mem->kin_vtemp2, kin_mem->kin_q_aa[i]); } diff --git a/src/sundials/sundials_iterative.c b/src/sundials/sundials_iterative.c index 503354514a..25b0e24172 100644 --- a/src/sundials/sundials_iterative.c +++ b/src/sundials/sundials_iterative.c @@ -514,7 +514,7 @@ SUNErrCode SUNQRAdd_CGS2(N_Vector* Q, sunrealtype* R, N_Vector df, int m, /* y = df - Q_k-1 s_k */ SUNCheckCall(N_VLinearCombination(m, R + m * mMax, Q, qrdata->vtemp2)); - N_VLinearSum(ONE, qrdata->vtemp, -ONE, qrdata->vtemp2, qrdata->vtemp2); + N_VLinearSum(-ONE, qrdata->vtemp2, ONE, qrdata->vtemp, qrdata->vtemp2); SUNCheckLastErr(); /* z_k = Q_k-1^T y */ diff --git a/src/sundials/sundials_nvector.c b/src/sundials/sundials_nvector.c index f998510a4d..bfc99c729a 100644 --- a/src/sundials/sundials_nvector.c +++ b/src/sundials/sundials_nvector.c @@ -559,7 +559,7 @@ SUNErrCode N_VLinearCombination(int nvec, sunrealtype* c, N_Vector* X, N_Vector z->ops->nvscale(c[0], X[0], z); for (i = 1; i < nvec; i++) { - z->ops->nvlinearsum(c[i], X[i], SUN_RCONST(1.0), z, z); + z->ops->nvlinearsum(SUN_RCONST(1.0), z, c[i], X[i], z); } ier = SUN_SUCCESS; } @@ -584,7 +584,7 @@ SUNErrCode N_VScaleAddMulti(int nvec, sunrealtype* a, N_Vector x, N_Vector* Y, { for (i = 0; i < nvec; i++) { - x->ops->nvlinearsum(a[i], x, SUN_RCONST(1.0), Y[i], Z[i]); + x->ops->nvlinearsum(SUN_RCONST(1.0), Y[i], a[i], x, Z[i]); } ier = SUN_SUCCESS; } @@ -773,7 +773,7 @@ SUNErrCode N_VScaleAddMultiVectorArray(int nvec, int nsum, sunrealtype* a, { for (j = 0; j < nsum; j++) { - X[0]->ops->nvlinearsum(a[j], X[i], SUN_RCONST(1.0), Y[j][i], Z[j][i]); + X[0]->ops->nvlinearsum(SUN_RCONST(1.0), Y[j][i], a[j], X[i], Z[j][i]); } } ier = SUN_SUCCESS; @@ -817,7 +817,7 @@ SUNErrCode N_VLinearCombinationVectorArray(int nvec, int nsum, sunrealtype* c, Z[0]->ops->nvscale(c[0], X[0][i], Z[i]); for (j = 1; j < nsum; j++) { - Z[0]->ops->nvlinearsum(c[j], X[j][i], SUN_RCONST(1.0), Z[i], Z[i]); + Z[0]->ops->nvlinearsum(SUN_RCONST(1.0), Z[i], c[j], X[j][i], Z[i]); } } ier = SUN_SUCCESS; diff --git a/src/sundials/sundials_xbraid.c b/src/sundials/sundials_xbraid.c index abba69f790..4c8e7924df 100644 --- a/src/sundials/sundials_xbraid.c +++ b/src/sundials/sundials_xbraid.c @@ -168,7 +168,7 @@ int SUNBraidVector_Sum(SUNDIALS_MAYBE_UNUSED braid_App app, braid_Real alpha, if (x->y == NULL || y->y == NULL) { return SUNBRAID_MEMFAIL; } /* Compute linear sum */ - N_VLinearSum(alpha, x->y, beta, y->y, y->y); + N_VLinearSum(beta, y->y, alpha, x->y, y->y); return SUNBRAID_SUCCESS; } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 4f524e020e..f50ed6e0a9 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -335,7 +335,7 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, return (LASTFLAG(S)); } - N_VLinearSum(ONE, b, -ONE, r, r); + N_VLinearSum(-ONE, r, ONE, b, r); SUNCheckLastErr(); } @@ -502,7 +502,7 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, beta = rz / rz_old; /* Update p = z + beta*p */ - N_VLinearSum(ONE, z, beta, p, p); + N_VLinearSum(beta, p, ONE, z, p); SUNCheckLastErr(); SUNLogInfo(S->sunctx->logger, "end-linear-iterate", "status = continue"); diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 5c941c5e22..ab1e304b8a 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -391,7 +391,7 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, return (LASTFLAG(S)); } - N_VLinearSum(ONE, b, -ONE, r_star, r_star); + N_VLinearSum(-ONE, r_star, ONE, b, r_star); SUNCheckLastErr(); } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index bc6b4576c1..727bfe6480 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -450,7 +450,7 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, return (LASTFLAG(S)); } - N_VLinearSum(ONE, b, -ONE, vtemp, vtemp); + N_VLinearSum(-ONE, vtemp, ONE, b, vtemp); SUNCheckLastErr(); } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 55a472987c..bd57e3aff5 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -434,7 +434,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, return (LASTFLAG(S)); } - N_VLinearSum(ONE, b, -ONE, vtemp, vtemp); + N_VLinearSum(-ONE, vtemp, ONE, b, vtemp); SUNCheckLastErr(); } N_VScale(ONE, vtemp, V[0]); diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index cc13ae7068..8df392292f 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -393,7 +393,7 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, return (LASTFLAG(S)); } - N_VLinearSum(ONE, b, -ONE, r_star, r_star); + N_VLinearSum(-ONE, r_star, ONE, b, r_star); SUNCheckLastErr(); } @@ -661,13 +661,13 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, omega = N_VDotProd(r[0], r[0]); SUNCheckLastErr(); omega = SUNRsqrt(SUNRsqrt(omega) * temp_val); - N_VLinearSum(ONE, u, SUNSQR(v_bar) * eta / alpha, d, d); + N_VLinearSum(SUNSQR(v_bar) * eta / alpha, d, ONE, u, d); SUNCheckLastErr(); } else { omega = temp_val; - N_VLinearSum(ONE, q, SUNSQR(v_bar) * eta / alpha, d, d); + N_VLinearSum(SUNSQR(v_bar) * eta / alpha, d, ONE, q, d); SUNCheckLastErr(); } diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index f53b03cf23..a96df9bb0b 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -531,7 +531,7 @@ static SUNErrCode AndersonAccelerate(SUNNonlinearSolver NLS, N_Vector gval, } N_VLinearSum(c, Q[i], s, Q[i + 1], vtemp); SUNCheckLastErr(); - N_VLinearSum(-s, Q[i], c, Q[i + 1], Q[i + 1]); + N_VLinearSum(c, Q[i + 1], -s, Q[i], Q[i + 1]); SUNCheckLastErr(); N_VScale(ONE, vtemp, Q[i]); SUNCheckLastErr(); diff --git a/test/unit_tests/nvector/test_nvector.c b/test/unit_tests/nvector/test_nvector.c index 1aff131250..cbc272c50e 100644 --- a/test/unit_tests/nvector/test_nvector.c +++ b/test/unit_tests/nvector/test_nvector.c @@ -570,7 +570,7 @@ int Test_N_VLinearSum(N_Vector X, N_Vector Y, N_Vector Z, N_VConst(NEG_TWO, Y); start_time = get_time(); - N_VLinearSum(ONE, X, ONE, Y, Y); + N_VLinearSum(ONE, Y, ONE, X, Y); sync_device(X); stop_time = get_time(); @@ -600,7 +600,7 @@ int Test_N_VLinearSum(N_Vector X, N_Vector Y, N_Vector Z, N_VConst(TWO, Y); start_time = get_time(); - N_VLinearSum(NEG_ONE, X, ONE, Y, Y); + N_VLinearSum(ONE, Y, NEG_ONE, X, Y); sync_device(X); stop_time = get_time(); @@ -630,7 +630,7 @@ int Test_N_VLinearSum(N_Vector X, N_Vector Y, N_Vector Z, N_VConst(NEG_TWO, Y); start_time = get_time(); - N_VLinearSum(HALF, X, ONE, Y, Y); + N_VLinearSum(ONE, Y, HALF, X, Y); sync_device(X); stop_time = get_time(); @@ -2756,7 +2756,7 @@ int Test_N_VLinearSumVectorArray(N_Vector V, sunindextype local_length, int myid N_VConst(NEG_ONE, Y[2]); start_time = get_time(); - ierr = N_VLinearSumVectorArray(3, ONE, X, ONE, Y, Y); + ierr = N_VLinearSumVectorArray(3, ONE, Y, ONE, X, Y); sync_device(V); stop_time = get_time(); @@ -2799,7 +2799,7 @@ int Test_N_VLinearSumVectorArray(N_Vector V, sunindextype local_length, int myid N_VConst(NEG_ONE, Y[2]); start_time = get_time(); - ierr = N_VLinearSumVectorArray(3, NEG_ONE, X, ONE, Y, Y); + ierr = N_VLinearSumVectorArray(3, ONE, Y, NEG_ONE, X, Y); sync_device(V); stop_time = get_time(); @@ -2842,7 +2842,7 @@ int Test_N_VLinearSumVectorArray(N_Vector V, sunindextype local_length, int myid N_VConst(TWO, Y[2]); start_time = get_time(); - ierr = N_VLinearSumVectorArray(3, HALF, X, ONE, Y, Y); + ierr = N_VLinearSumVectorArray(3, ONE, Y, HALF, X, Y); sync_device(V); stop_time = get_time();