1515#include <cuqdyn.h>
1616#include <stdio.h>
1717#include <sunmatrix/sunmatrix_dense.h>
18+ #include <math.h>
1819#include "nvector/nvector_serial.h"
1920
2021#include "data_reader.h"
@@ -64,7 +65,7 @@ void lotka_volterra_ess(char *conf_file)
6465
6566 read_data_file (LOTKA_VOLTERRA_DATA , & texp , & yexp );
6667
67- N_Vector initial_values = copy_matrix_row (yexp , 0 , 0 , SM_COLUMNS_D (yexp ));
68+ N_Vector initial_values = copy_matrix_column (yexp , 0 , 0 , SM_ROWS_D (yexp ));
6869
6970 N_Vector xbest = execute_ess_solver (conf_file , OUPUT_PATH , texp , yexp , initial_values , NULL );
7071
@@ -73,8 +74,7 @@ void lotka_volterra_ess(char *conf_file)
7374 sunrealtype expected = expected_values [i ];
7475 sunrealtype result = NV_Ith_S (xbest , i );
7576
76- sunrealtype a = 6 ;
77- // assert(fabs(result - expected) < 0.1);
77+ assert (fabs (result - expected ) < 1 );
7878 }
7979
8080 destroy_cuqdyn_context (context );
@@ -91,7 +91,7 @@ void alpha_pinene_ess(char *conf_file)
9191
9292 read_data_file (ALPHA_PINENE_DATA , & texp , & yexp );
9393
94- N_Vector initial_values = copy_matrix_row (yexp , 0 , 0 , SM_COLUMNS_D (yexp ));
94+ N_Vector initial_values = copy_matrix_column (yexp , 0 , 0 , SM_ROWS_D (yexp ));
9595
9696 N_Vector xbest = execute_ess_solver (conf_file , OUPUT_PATH , texp , yexp , initial_values , NULL );
9797
@@ -100,8 +100,7 @@ void alpha_pinene_ess(char *conf_file)
100100 sunrealtype expected = expected_values [i ];
101101 sunrealtype result = NV_Ith_S (xbest , i );
102102
103- sunrealtype a = 6 ;
104- // assert(fabs(result - expected) < 0.1);
103+ assert (fabs (result - expected ) < 1 );
105104 }
106105
107106 destroy_cuqdyn_context (context );
@@ -111,24 +110,23 @@ void logistic_model_ess(char *conf_file)
111110{
112111 CuqDynContext context = init_cuqdyn_context_from_file ("data/logistic_model_cuqdyn_config.xml" );
113112
114- sunrealtype expected_values [2 ] = {0.1 , 100 };
113+ sunrealtype expected_values [2 ] = {0.1 , 102 };
115114
116115 N_Vector texp = NULL ;
117116 SUNMatrix yexp = NULL ;
118117
119118 read_data_file (LOGISTIC_MODEL_DATA , & texp , & yexp );
120119
121- N_Vector initial_values = copy_matrix_row (yexp , 0 , 0 , SM_COLUMNS_D (yexp ));
120+ N_Vector initial_values = copy_matrix_column (yexp , 0 , 0 , SM_ROWS_D (yexp ));
122121
123122 N_Vector xbest = execute_ess_solver (conf_file , OUPUT_PATH , texp , yexp , initial_values , NULL );
124123
125- for (int i = 0 ; i < sizeof ( expected_values ) ; ++ i )
124+ for (int i = 0 ; i < 2 ; ++ i )
126125 {
127126 sunrealtype expected = expected_values [i ];
128127 sunrealtype result = NV_Ith_S (xbest , i );
129128
130- sunrealtype a = 6 ;
131- // assert(fabs(result - expected) < 0.1);
129+ assert (fabs (result - expected ) < 1 );
132130 }
133131
134132 destroy_cuqdyn_context (context );
0 commit comments