Skip to content

Commit

Permalink
Fix promotion of double to sunrealtype identified with -Wdouble-promo…
Browse files Browse the repository at this point in the history
…tion (#483)
  • Loading branch information
Steven-Roberts authored May 16, 2024
1 parent c031884 commit f0acc14
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/arkode/arkode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2816,8 +2816,8 @@ int arkPredict_MaximumOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess)
int arkPredict_VariableOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess)
{
int ord;
sunrealtype tau_tol = 0.5;
sunrealtype tau_tol2 = 0.75;
sunrealtype tau_tol = HALF;
sunrealtype tau_tol2 = SUN_RCONST(0.75);

/* verify that ark_mem and interpolation structure are provided */
if (ark_mem == NULL)
Expand Down Expand Up @@ -2854,7 +2854,7 @@ int arkPredict_VariableOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess
int arkPredict_CutoffOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess)
{
int ord;
sunrealtype tau_tol = 0.5;
sunrealtype tau_tol = HALF;

/* verify that ark_mem and interpolation structure are provided */
if (ark_mem == NULL)
Expand Down
2 changes: 1 addition & 1 deletion src/arkode/arkode_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ int ARKodeSetErrorBias(void* arkode_mem, sunrealtype bias)
/* set allowed value, otherwise set default */
if (bias < ONE)
{
retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, -1.0);
retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, -ONE);
}
else
{
Expand Down
13 changes: 7 additions & 6 deletions src/arkode/arkode_sprk.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ ARKodeSPRKTable ARKodeSymplecticMcLachlan2(void)
if (!sprk_table) { return NULL; }
sprk_table->q = 2;
sprk_table->stages = 2;
sprk_table->a[1] = SUN_RCONST(1.0) -
(SUN_RCONST(1.0) / SUN_RCONST(2.0)) * SUNRsqrt(2.0);
sprk_table->a[1] = SUN_RCONST(1.0) - (SUN_RCONST(1.0) / SUN_RCONST(2.0)) *
SUNRsqrt(SUN_RCONST(2.0));
sprk_table->a[0] = SUN_RCONST(1.0) - sprk_table->a[1];
sprk_table->ahat[1] = SUN_RCONST(1.0) /
(SUN_RCONST(2.0) * (SUN_RCONST(1.0) - sprk_table->a[1]));
Expand All @@ -147,17 +147,18 @@ ARKodeSPRKTable ARKodeSymplecticMcLachlan2(void)

ARKodeSPRKTable ARKodeSymplecticMcLachlan3(void)
{
sunrealtype w = 0.0;
sunrealtype y = 0.0;
sunrealtype z = 0.0;
sunrealtype w = SUN_RCONST(0.0);
sunrealtype y = SUN_RCONST(0.0);
sunrealtype z = SUN_RCONST(0.0);
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(3);
if (!sprk_table) { return NULL; }

sprk_table->q = 3;
sprk_table->stages = 3;

z = -SUNRpowerR((SUN_RCONST(2.0) / SUN_RCONST(27.0)) -
SUN_RCONST(1.0) / (SUN_RCONST(9.0) * SUNRsqrt(3.0)),
SUN_RCONST(1.0) /
(SUN_RCONST(9.0) * SUNRsqrt(SUN_RCONST(3.0))),
SUN_RCONST(1.0) / SUN_RCONST(3.0));
w = -SUN_RCONST(2.0) / SUN_RCONST(3.0) +
SUN_RCONST(1.0) / (SUN_RCONST(9.0) * z) + z;
Expand Down
2 changes: 1 addition & 1 deletion src/cvodes/cvodea.c
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ static CVckpntMem CVAckpntInit(CVodeMem cv_mem)
ck_mem->ck_t0 = cv_mem->cv_tn;
ck_mem->ck_nst = 0;
ck_mem->ck_q = 1;
ck_mem->ck_h = 0.0;
ck_mem->ck_h = ZERO;

/* Do we need to carry quadratures */
ck_mem->ck_quadr = cv_mem->cv_quadr && cv_mem->cv_errconQ;
Expand Down
2 changes: 1 addition & 1 deletion src/sundials/sundials_band.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void SUNDlsMat_bandMatvec(sunrealtype** a, sunrealtype* x, sunrealtype* y,
sunindextype i, j, is, ie;
sunrealtype* col_j;

for (i = 0; i < n; i++) { y[i] = 0.0; }
for (i = 0; i < n; i++) { y[i] = ZERO; }

for (j = 0; j < n; j++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/sundials/sundials_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void SUNDlsMat_denseMatvec(sunrealtype** a, sunrealtype* x, sunrealtype* y,
sunindextype i, j;
sunrealtype* col_j;

for (i = 0; i < m; i++) { y[i] = 0.0; }
for (i = 0; i < m; i++) { y[i] = ZERO; }

for (j = 0; j < n; j++)
{
Expand Down
6 changes: 3 additions & 3 deletions src/sunmatrix/sparse/sunmatrix_sparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ SUNErrCode Matvec_SparseCSC(SUNMatrix A, N_Vector x, N_Vector y)
SUNCheckLastErr();

/* initialize result */
for (i = 0; i < SM_ROWS_S(A); i++) { yd[i] = 0.0; }
for (i = 0; i < SM_ROWS_S(A); i++) { yd[i] = ZERO; }

/* iterate through matrix columns */
for (j = 0; j < SM_COLUMNS_S(A); j++)
Expand Down Expand Up @@ -1230,7 +1230,7 @@ SUNErrCode Matvec_SparseCSR(SUNMatrix A, N_Vector x, N_Vector y)
SUNAssert(yd, SUN_ERR_ARG_CORRUPT);
SUNAssert(xd != yd, SUN_ERR_ARG_CORRUPT);
/* initialize result */
for (i = 0; i < SM_ROWS_S(A); i++) { yd[i] = 0.0; }
for (i = 0; i < SM_ROWS_S(A); i++) { yd[i] = ZERO; }

/* iterate through matrix rows */
for (i = 0; i < SM_ROWS_S(A); i++)
Expand Down Expand Up @@ -1298,7 +1298,7 @@ SUNErrCode format_convert(const SUNMatrix A, SUNMatrix B)
sunindextype jj;
for (jj = Ap[row]; jj < Ap[row + 1]; jj++)
{
sunindextype col = Aj[jj];
col = Aj[jj];
sunindextype dest = Bp[col];

Bi[dest] = row;
Expand Down

0 comments on commit f0acc14

Please sign in to comment.