aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-01-11 17:13:40 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-11 17:13:40 +0100
commit121a0add4a95c52c41b03723fb321e2f84902276 (patch)
treefc16aba9905da7ae1311116b52d2338d32211fb8
parent45ee13e5e3a14107cfa72928c7b93f37874a57df (diff)
{nl,ps}solve: eliminate const warnings
-rw-r--r--nlsolve.c4
-rw-r--r--pssolve.c8
-rw-r--r--pssolve.h12
3 files changed, 14 insertions, 10 deletions
diff --git a/nlsolve.c b/nlsolve.c
index ee08ec7..84c6b8a 100644
--- a/nlsolve.c
+++ b/nlsolve.c
@@ -79,7 +79,7 @@ struct NLSolvePriv {
NLEquationContext *eqs;
NLVarContext *vars;
- const double *(**eq_coeffs)[PSSOLVE_DIFF_ORDER_NB];
+ PSEqCoeffs *eq_coeffs;
double *delta;
double *rhs;
@@ -498,7 +498,7 @@ int tdi_nlsolve_context_init(NLSolveContext *ctx)
if (ret < 0)
return ret;
- s->eq_coeffs[i] = s->eqs[i].eq_coeffs;
+ s->eq_coeffs[i].func_coeffs = (const double * const (*)[PSSOLVE_DIFF_ORDER_NB])s->eqs[i].eq_coeffs;
}
/* init the per-variable state */
diff --git a/pssolve.c b/pssolve.c
index dd62391..882eed3 100644
--- a/pssolve.c
+++ b/pssolve.c
@@ -67,7 +67,7 @@ struct PSSolvePriv {
typedef struct ConstructMatrixThread {
const PSEquationContext *eq_ctx;
- const double **eq_coeffs;
+ const double * const *eq_coeffs;
double *mat;
ptrdiff_t mat_stride;
unsigned int var_idx;
@@ -77,7 +77,7 @@ static void construct_matrix(void *arg, unsigned int job_idx, unsigned int threa
{
ConstructMatrixThread *cmt = arg;
const PSEquationContext *eq_ctx = cmt->eq_ctx;
- const double **eq_coeffs = cmt->eq_coeffs;
+ const double * const *eq_coeffs = cmt->eq_coeffs;
double *mat = cmt->mat;
ptrdiff_t mat_stride = cmt->mat_stride;
unsigned int var_idx = cmt->var_idx;
@@ -169,7 +169,7 @@ static int lu_invert(TDLogger *logger, const int N, double *mat, double *rhs, in
}
int tdi_pssolve_solve(PSSolveContext *ctx,
- const double *(**eq_coeffs)[PSSOLVE_DIFF_ORDER_NB],
+ const PSEqCoeffs *eq_coeffs,
const double *rhs, double *coeffs)
{
PSSolvePriv *s = ctx->priv;
@@ -188,7 +188,7 @@ int tdi_pssolve_solve(PSSolveContext *ctx,
for (int j = 0; j < ctx->nb_equations; j++) {
ConstructMatrixThread thread = {
.eq_ctx = eq_ctx,
- .eq_coeffs = eq_coeffs[i][j],
+ .eq_coeffs = eq_coeffs[i].func_coeffs[j],
.mat = mat,
.mat_stride = s->nb_coeffs,
.var_idx = j,
diff --git a/pssolve.h b/pssolve.h
index 15ee313..b9ba17c 100644
--- a/pssolve.h
+++ b/pssolve.h
@@ -136,6 +136,10 @@ typedef struct PSSolveContext {
uint64_t construct_matrix_time;
} PSSolveContext;
+typedef struct PSEqCoeffs {
+ const double * const (*func_coeffs)[PSSOLVE_DIFF_ORDER_NB];
+} PSEqCoeffs;
+
/**
* Allocate a new solver.
*
@@ -168,9 +172,9 @@ void tdi_pssolve_context_free(PSSolveContext **ctx);
*
* @param ctx the solver context
* @param eq_coeffs the equation coefficients at the collocation points.
- * eq_coeffs[i][j][k] is the array of coefficients for the k-th
- * derivative (as per enum PSSolveDiffOrder) of the j-th
- * unknown function in the i-th equation.
+ * eq_coeffs[i].func_coeffs[j][k] is the array of coefficients
+ * for the k-th derivative (as per enum PSSolveDiffOrder) of
+ * the j-th unknown function in the i-th equation.
* @param rhs the right-hand side of the equation at the collocation points.
* @param coeffs the spectral coefficients of the solution will be written here.
*
@@ -178,7 +182,7 @@ void tdi_pssolve_context_free(PSSolveContext **ctx);
* coeffs are undefined on failure.
*/
int tdi_pssolve_solve(PSSolveContext *ctx,
- const double *(**eq_coeffs)[PSSOLVE_DIFF_ORDER_NB],
+ const PSEqCoeffs *eq_coeffs,
const double *rhs, double *coeffs);
int tdi_pssolve_diff_order(enum PSSolveDiffOrder order, unsigned int dir);