Skip to content

Commit 9369ae3

Browse files
committed
closer and closer
1 parent e8c6667 commit 9369ae3

File tree

1,076 files changed

+75
-171401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,076 files changed

+75
-171401
lines changed

modules/cuqdyn-c/include/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
typedef struct
77
{
8-
sunsunrealtype rtol;
8+
sunrealtype rtol;
99
N_Vector atol;
1010

1111
} Tolerances;
1212

13-
Tolerances create_tolerances(sunsunrealtype rtol, N_Vector atol);
13+
Tolerances create_tolerances(sunrealtype rtol, N_Vector atol);
1414
void destroy_tolerances(Tolerances);
1515

1616
typedef struct

modules/cuqdyn-c/include/functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
void mexpreval_init_wrapper(OdeExpr ode_expr);
99
/// Function used to solve the ODE using cvodes
10-
int ode_model_fun(sunsunrealtype t, N_Vector y, N_Vector ydot, void *data);
10+
int ode_model_fun(sunrealtype t, N_Vector y, N_Vector ydot, void *data);
1111
/// Objetive function for the lotka_volterra problem used by the sacess library
1212
void* ode_model_obj_func(double *x, void *data);
1313

modules/cuqdyn-c/include/matlab.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ SUNMatrix subtract_two_matrices(SUNMatrix a, SUNMatrix b);
5353
* For the quantiles corresponding to the probabilities outside that range,
5454
* quantile assigns the minimum or maximum values of the elements in A.
5555
*/
56-
sunsunrealtype quantile(N_Vector, sunsunrealtype);
56+
sunrealtype quantile(N_Vector, sunrealtype);
5757
#endif //MATLAB_H

modules/cuqdyn-c/include/ode_solver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
* - Columns 1-n: Solution components (y1, y2, ..., yn)
1515
*
1616
*/
17-
SUNMatrix solve_ode(N_Vector parameters, N_Vector initial_values, sunsunrealtype t0, N_Vector times);
17+
SUNMatrix solve_ode(N_Vector parameters, N_Vector initial_values, sunrealtype t0, N_Vector times);
1818

1919
#endif //EDO_SOLVER_H

modules/cuqdyn-c/src/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int parse_cuqdyn_conf(const char *filename, CuqdynConf *config)
6969
xmlNodePtr root = xmlDocGetRootElement(doc);
7070
xmlNodePtr cur = root->children;
7171

72-
sunsunrealtype rtol = 1e-6;
72+
sunrealtype rtol = 1e-6;
7373
N_Vector atol = NULL;
7474
int y_count = 0;
7575
char **odes = NULL;
@@ -213,7 +213,7 @@ CuqdynConf *get_cuqdyn_conf()
213213
return config;
214214
}
215215

216-
Tolerances create_tolerances(sunsunrealtype scalar_rtol, N_Vector atol)
216+
Tolerances create_tolerances(sunrealtype scalar_rtol, N_Vector atol)
217217
{
218218
Tolerances tolerances;
219219
tolerances.rtol = scalar_rtol;

modules/cuqdyn-c/src/cuqdyn.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ CuqdynResult *cuqdyn_algo(const char *data_file, const char *sacess_conf_file,
6363
exit(1);
6464
}
6565

66-
const sunsunrealtype t0 = NV_Ith_S(times, 0);
66+
const sunrealtype t0 = NV_Ith_S(times, 0);
6767
N_Vector initial_values = copy_matrix_row(observed_data, 0, 0, SM_COLUMNS_D(observed_data));
6868

6969
const long m = SM_ROWS_D(observed_data);
@@ -126,7 +126,7 @@ CuqdynResult *cuqdyn_algo(const char *data_file, const char *sacess_conf_file,
126126

127127
N_Vector init_vals = New_Serial(NV_LENGTH_S(initial_values));
128128
memcpy(NV_DATA_S(init_vals), NV_DATA_S(initial_values),
129-
NV_LENGTH_S(initial_values) * sizeof(sunsunrealtype));
129+
NV_LENGTH_S(initial_values) * sizeof(sunrealtype));
130130

131131
N_Vector predicted_params =
132132
execute_ess_solver(sacess_conf_file, output_file, texp, yexp, init_vals, rank, nproc);
@@ -138,8 +138,8 @@ CuqdynResult *cuqdyn_algo(const char *data_file, const char *sacess_conf_file,
138138

139139
for (int j = 0; j < n; ++j)
140140
{
141-
sunsunrealtype observed = SM_ELEMENT_D(observed_data, i, j);
142-
sunsunrealtype predicted = SM_ELEMENT_D(predicted_data, i, j);
141+
sunrealtype observed = SM_ELEMENT_D(observed_data, i, j);
142+
sunrealtype predicted = SM_ELEMENT_D(predicted_data, i, j);
143143

144144
NV_Ith_S(residuals, j) = fabs(observed - predicted);
145145
}
@@ -343,13 +343,13 @@ void matrix_array_set_index(MatrixArray array, long i, SUNMatrix matrix)
343343

344344
array.data[i] = NewDenseMatrix(rows, cols);
345345

346-
memcpy(SM_DATA_D(array.data[i]), SM_DATA_D(matrix), rows * cols * sizeof(sunsunrealtype));
346+
memcpy(SM_DATA_D(array.data[i]), SM_DATA_D(matrix), rows * cols * sizeof(sunrealtype));
347347
}
348348

349-
int compare_sunsunrealtype(const void *a, const void *b)
349+
int compare_sunrealtype(const void *a, const void *b)
350350
{
351-
double x = *(sunsunrealtype *) a;
352-
double y = *(sunsunrealtype *) b;
351+
double x = *(sunrealtype *) a;
352+
double y = *(sunrealtype *) b;
353353

354354
if (x < y)
355355
return -1;
@@ -367,9 +367,9 @@ SUNMatrix matrix_array_get_median(MatrixArray matrix_array)
367367
long max_z = matrix_array.len;
368368

369369
SUNMatrix medians_matrix = NewDenseMatrix(rows, cols);
370-
sunsunrealtype *medians = SM_DATA_D(medians_matrix);
370+
sunrealtype *medians = SM_DATA_D(medians_matrix);
371371

372-
sunsunrealtype values[max_z];
372+
sunrealtype values[max_z];
373373

374374
for (int i = 0; i < rows; ++i)
375375
{
@@ -382,7 +382,7 @@ SUNMatrix matrix_array_get_median(MatrixArray matrix_array)
382382
}
383383

384384
// Sorting the vector to obtain the median easily
385-
qsort(values, max_z, sizeof(values[0]), compare_sunsunrealtype);
385+
qsort(values, max_z, sizeof(values[0]), compare_sunrealtype);
386386

387387
SM_ELEMENT_D(medians_matrix, i, j) =
388388
max_z & 0b1 ? values[(max_z - 1) / 2] : (values[max_z / 2 - 1] + values[max_z / 2]) / 2;
@@ -410,9 +410,9 @@ N_Vector get_matrix_cols_median(SUNMatrix matrix)
410410
long cols = SM_COLUMNS_D(matrix);
411411

412412
N_Vector medians_vector = New_Serial(cols);
413-
sunsunrealtype *medians = NV_DATA_S(medians_vector);
413+
sunrealtype *medians = NV_DATA_S(medians_vector);
414414

415-
sunsunrealtype copied_col[rows];
415+
sunrealtype copied_col[rows];
416416

417417
for (int j = 0; j < cols; ++j)
418418
{
@@ -422,7 +422,7 @@ N_Vector get_matrix_cols_median(SUNMatrix matrix)
422422
}
423423

424424
// Sorting the vector to obtain the median easily
425-
qsort(copied_col, rows, sizeof(copied_col[0]), compare_sunsunrealtype);
425+
qsort(copied_col, rows, sizeof(copied_col[0]), compare_sunrealtype);
426426

427427
medians[j] = rows & 0b1 ? copied_col[(rows - 1) / 2] : (copied_col[rows / 2 - 1] + copied_col[rows / 2]) / 2;
428428
}

modules/cuqdyn-c/src/data_reader.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ int read_txt_data_file(const char *data_file, N_Vector *t, SUNMatrix *y)
4545
fscanf(f, "%ld", &cols);
4646

4747
*t = New_Serial(rows);
48-
sunsunrealtype *data_t = N_VGetArrayPointer(*t);
48+
sunrealtype *data_t = N_VGetArrayPointer(*t);
4949

5050
*y = NewDenseMatrix(rows, cols - 1);
51-
sunsunrealtype *data_y = ((SUNMatrixContent_Dense)(*y)->content)->data;
51+
sunrealtype *data_y = ((SUNMatrixContent_Dense)(*y)->content)->data;
5252

5353
double tmp;
5454

@@ -107,10 +107,10 @@ int read_mat_data_file(const char *data_file, N_Vector *t, SUNMatrix *y)
107107
// The first row of the matrix are the initial values [t0 y10 y20 ...]
108108

109109
*t = New_Serial((long) rows);
110-
sunsunrealtype *data_t = N_VGetArrayPointer(*t);
110+
sunrealtype *data_t = N_VGetArrayPointer(*t);
111111

112112
*y = NewDenseMatrix((long) rows, (long) cols - 1);
113-
sunsunrealtype *data_y = ((SUNMatrixContent_Dense)(*y)->content)->data;
113+
sunrealtype *data_y = ((SUNMatrixContent_Dense)(*y)->content)->data;
114114

115115
const double *file_data = matvar->data;
116116

modules/cuqdyn-c/src/ess_solver.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "ess_solver.h"
99

1010
#include <../include/functions.h>
11+
12+
#include "cuqdyn.h"
1113
#if defined(MPI2) && !defined(MPI)
1214
#include <mpi.h>
1315
#endif
@@ -78,7 +80,7 @@ N_Vector execute_ess_solver(const char *file, const char *path, N_Vector texp, S
7880

7981
destroyexp(exptotal);
8082

81-
N_Vector predicted_params = N_VNew_Serial(exptotal->test.bench.dim);
83+
N_Vector predicted_params = New_Serial(exptotal->test.bench.dim);
8284
N_VSetArrayPointer(result.bestx_value, predicted_params);
8385
return predicted_params;
8486
}

modules/cuqdyn-c/src/functions.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
#include <method_module/structure_paralleltestbed.h>
33
#include <nvector/nvector_serial.h>
44
#include <string.h>
5-
#include <sundials_old/sundials_direct.h>
6-
#include <sundials_old/sundials_nvector.h>
75
#include <sunmatrix/sunmatrix_dense.h>
86

97
#include "config.h"
108
#include "cuqdyn.h"
11-
#include "sundials_old/sundials_types.h"
129

1310
extern void mexpreval_init(OdeExpr ode_expr);
1411

@@ -17,14 +14,14 @@ void mexpreval_init_wrapper(OdeExpr ode_expr)
1714
mexpreval_init(ode_expr);
1815
}
1916

20-
extern void eval_f_exprs(sunsunrealtype t, sunsunrealtype *y, sunsunrealtype *ydot, sunsunrealtype *params);
17+
extern void eval_f_exprs(sunrealtype t, sunrealtype *y, sunrealtype *ydot, sunrealtype *params);
2118

22-
int ode_model_fun(sunsunrealtype t, N_Vector y, N_Vector ydot, void *user_data)
19+
int ode_model_fun(sunrealtype t, N_Vector y, N_Vector ydot, void *user_data)
2320
{
2421
N_Vector params_vec = user_data;
25-
sunsunrealtype *params = NV_DATA_S(params_vec);
26-
sunsunrealtype *ydot_pointer = NV_DATA_S(ydot);
27-
sunsunrealtype *y_pointer = NV_DATA_S(y);
22+
sunrealtype *params = NV_DATA_S(params_vec);
23+
sunrealtype *ydot_pointer = NV_DATA_S(ydot);
24+
sunrealtype *y_pointer = NV_DATA_S(y);
2825

2926
eval_f_exprs(t, y_pointer, ydot_pointer, params);
3027

@@ -48,21 +45,21 @@ void *ode_model_obj_func(double *x, void *data)
4845
output_function *res = calloc(1, sizeof(output_function));
4946

5047
N_Vector parameters = New_Serial(conf->ode_expr.p_count);
51-
memcpy(NV_DATA_S(parameters), x, NV_LENGTH_S(parameters) * sizeof(sunsunrealtype));
48+
memcpy(NV_DATA_S(parameters), x, NV_LENGTH_S(parameters) * sizeof(sunrealtype));
5249

5350
N_Vector texp = New_Serial(NV_LENGTH_S(exptotal->texp));
54-
memcpy(NV_DATA_S(texp), NV_DATA_S(exptotal->texp), NV_LENGTH_S(exptotal->texp) * sizeof(sunsunrealtype));
51+
memcpy(NV_DATA_S(texp), NV_DATA_S(exptotal->texp), NV_LENGTH_S(exptotal->texp) * sizeof(sunrealtype));
5552

56-
const sunsunrealtype t0 = NV_Ith_S(texp, 0);
53+
const sunrealtype t0 = NV_Ith_S(texp, 0);
5754

5855
SUNMatrix result = solve_ode(parameters, exptotal->initial_values, t0, texp);
5956

6057
// Objective function code:
6158
const int rows = SM_ROWS_D(result);
6259
const int cols = SM_COLUMNS_D(result);
6360

64-
// sunsunrealtype R[(cols - 1) * rows];
65-
sunsunrealtype J = 0.0;
61+
// sunrealtype R[(cols - 1) * rows];
62+
sunrealtype J = 0.0;
6663

6764
long index = 0;
6865

@@ -71,7 +68,7 @@ void *ode_model_obj_func(double *x, void *data)
7168
// Note that the first col of the result matrix is t
7269
for (long j = 1; j < cols; ++j)
7370
{
74-
const sunsunrealtype diff = SM_ELEMENT_D(result, i, j) - SM_ELEMENT_D(exptotal->yexp, i, j - 1);
71+
const sunrealtype diff = SM_ELEMENT_D(result, i, j) - SM_ELEMENT_D(exptotal->yexp, i, j - 1);
7572
J += diff * diff;
7673
// R[index++] = SM_ELEMENT_D(result, i, j) - SM_ELEMENT_D(exptotal->yexp, i, j - 1);
7774
}

modules/cuqdyn-c/src/matlab.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
N_Vector copy_vector_remove_indices(N_Vector original, LongArray indices)
1010
{
11-
sunsunrealtype *original_data = N_VGetArrayPointer(original);
11+
sunrealtype *original_data = N_VGetArrayPointer(original);
1212
long N = NV_LENGTH_S(original);
1313

1414
N_Vector new_vector = New_Serial(N - indices.len);
1515

16-
sunsunrealtype *new_data = N_VGetArrayPointer(new_vector);
16+
sunrealtype *new_data = N_VGetArrayPointer(new_vector);
1717

1818
long new_index = 0; // Index to track the current index in the new vector
1919
long skip_index = 0; // Index to track the current index in the indices array
@@ -40,8 +40,8 @@ SUNMatrix copy_matrix_remove_rows_and_columns(SUNMatrix matrix, LongArray row_in
4040

4141
SUNMatrix copy = NewDenseMatrix(rows - row_indices.len, cols - col_indices.len);
4242

43-
sunsunrealtype *original_data = SM_DATA_D(matrix);
44-
sunsunrealtype *copy_data = SM_DATA_D(copy);
43+
sunrealtype *original_data = SM_DATA_D(matrix);
44+
sunrealtype *copy_data = SM_DATA_D(copy);
4545

4646
// copy_index: Index to track the current index in the copy matrix
4747
// row_skip_index: Index to track the current index in the row_indices array
@@ -179,10 +179,10 @@ SUNMatrix subtract_two_matrices(SUNMatrix a, SUNMatrix b)
179179
return result;
180180
}
181181

182-
int cmp_sunsunrealtype(const void *a, const void *b)
182+
int cmp_sunrealtype(const void *a, const void *b)
183183
{
184-
double x = *(sunsunrealtype *) a;
185-
double y = *(sunsunrealtype *) b;
184+
double x = *(sunrealtype *) a;
185+
double y = *(sunrealtype *) b;
186186

187187
if (x < y)
188188
return -1;
@@ -191,17 +191,17 @@ int cmp_sunsunrealtype(const void *a, const void *b)
191191
return 0;
192192
}
193193

194-
sunsunrealtype quantile(N_Vector vec, sunsunrealtype q)
194+
sunrealtype quantile(N_Vector vec, sunrealtype q)
195195
{
196196
const long n = NV_LENGTH_S(vec);
197-
sunsunrealtype *data = malloc(n * sizeof(sunsunrealtype));
197+
sunrealtype *data = malloc(n * sizeof(sunrealtype));
198198

199-
memcpy(data, NV_DATA_S(vec), n * sizeof(sunsunrealtype));
199+
memcpy(data, NV_DATA_S(vec), n * sizeof(sunrealtype));
200200

201-
qsort(data, n, sizeof(sunsunrealtype), cmp_sunsunrealtype);
201+
qsort(data, n, sizeof(sunrealtype), cmp_sunrealtype);
202202

203-
const double min_q = 0.5 / (sunsunrealtype) n;
204-
const double max_q = ((sunsunrealtype) n - 0.5) / (sunsunrealtype) n;
203+
const double min_q = 0.5 / (sunrealtype) n;
204+
const double max_q = ((sunrealtype) n - 0.5) / (sunrealtype) n;
205205

206206
if (q <= min_q) {
207207
const double val = data[0];
@@ -215,7 +215,7 @@ sunsunrealtype quantile(N_Vector vec, sunsunrealtype q)
215215
return val;
216216
}
217217

218-
const double pos = q * (sunsunrealtype) n - 0.5;
218+
const double pos = q * (sunrealtype) n - 0.5;
219219
const int i = (int) pos;
220220
const double delta = pos - i;
221221

0 commit comments

Comments
 (0)