Skip to content

Commit 820ca9f

Browse files
committed
correctly prining the predicted data median patrix in the output file
1 parent 4ff2ea4 commit 820ca9f

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

modules/cli/src/handlers/solve.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <unistd.h>
1010

1111
#include "cuqdyn.h"
12-
#include "functions.h"
1312
#include "handlers/handlers.h"
1413

1514
#if defined(MPI) || defined(MPI2)
@@ -18,6 +17,7 @@
1817

1918
int handle_solve(int argc, char *argv[]);
2019
void print_matrix(SUNMatrix mat, FILE *output_file, char *name);
20+
void print_transposed_matrix(TransposedStates mat, FILE *output_file, char *name);
2121
void print_vector(N_Vector vec, FILE *output_file, char *name);
2222

2323
Handler create_solve_handler()
@@ -116,7 +116,7 @@ int handle_solve(int argc, char *argv[])
116116
{
117117

118118
N_Vector params_median = cuqdyn_result->predicted_params_median;
119-
SUNMatrix data_median = cuqdyn_result->predicted_data_median;
119+
TransposedStates data_median = cuqdyn_result->predicted_data_median;
120120

121121
SUNMatrix q_low = cuqdyn_result->q_low;
122122
SUNMatrix q_up = cuqdyn_result->q_up;
@@ -129,7 +129,7 @@ int handle_solve(int argc, char *argv[])
129129
FILE *output_file = fopen(output_file_path, "w");
130130

131131
print_vector(params_median, output_file, "Params");
132-
print_matrix(data_median, output_file, "Data");
132+
print_transposed_matrix(data_median, output_file, "Data");
133133
print_matrix(q_low, output_file, "Q_low");
134134
print_matrix(q_up, output_file, "Q_up");
135135
print_vector(times, output_file, "Times");
@@ -160,6 +160,21 @@ void print_matrix(SUNMatrix mat, FILE *output_file, char *name)
160160
}
161161
}
162162

163+
void print_transposed_matrix(TransposedStates mat, FILE *output_file, char *name)
164+
{
165+
fprintf(output_file, "[%s]\n", name);
166+
fprintf(output_file, "%ld %ld\n", SM_COLUMNS_D(mat), SM_ROWS_D(mat));
167+
168+
for (int i = 0; i < SM_COLUMNS_D(mat); i++)
169+
{
170+
for (int j = 0; j < SM_ROWS_D(mat); j++)
171+
{
172+
fprintf(output_file, "%.8lf ", SM_ELEMENT_D(mat, j, i));
173+
}
174+
fprintf(output_file, "\n");
175+
}
176+
}
177+
163178
void print_vector(N_Vector vec, FILE *output_file, char *name)
164179
{
165180
fprintf(output_file, "[%s]\n", name);

modules/cuqdyn-c/include/cuqdyn.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ SUNContext get_sundials_ctx();
2424
/// Result of the cuqdyn algorithm
2525
typedef struct
2626
{
27-
SUNMatrix predicted_data_median;
27+
TransposedStates predicted_data_median;
2828
N_Vector predicted_params_median;
2929
SUNMatrix q_low;
3030
SUNMatrix q_up;
3131
N_Vector times;
3232
} CuqdynResult;
3333

34-
CuqdynResult *create_cuqdyn_result(SUNMatrix predicted_data_median, N_Vector predicted_params_median, SUNMatrix q_low,
35-
SUNMatrix q_up, N_Vector times);
34+
CuqdynResult *create_cuqdyn_result(TransposedStates predicted_data_median, N_Vector predicted_params_median,
35+
SUNMatrix q_low, SUNMatrix q_up, N_Vector times);
3636
void destroy_cuqdyn_result(CuqdynResult *result);
3737
CuqdynResult *cuqdyn_algo(const char *data_file, const char *sacess_conf_file, const char *output_file);
3838

0 commit comments

Comments
 (0)