Global reindentation of MEX sources
parent
22ab507c6c
commit
b901b7af86
|
@ -466,7 +466,7 @@ BlockKalmanFilter::block_kalman_filter(int nlhs, mxArray *plhs[])
|
||||||
int j1 = j - pure_obs;
|
int j1 = j - pure_obs;
|
||||||
int j1_n_state = j1 * n_state - pure_obs;
|
int j1_n_state = j1 * n_state - pure_obs;
|
||||||
for (int k = pure_obs; k < i_nz_state_var[i]; k++)
|
for (int k = pure_obs; k < i_nz_state_var[i]; k++)
|
||||||
tmp[i + j1 * n ] += T[i + k * n] * P[k + j1_n_state];
|
tmp[i + j1 * n] += T[i + k * n] * P[k + j1_n_state];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fill_n(P, 0, n * n);
|
std::fill_n(P, 0, n * n);
|
||||||
|
|
|
@ -152,7 +152,7 @@ using namespace std;
|
||||||
const int NO_ERROR_ON_EXIT = 0;
|
const int NO_ERROR_ON_EXIT = 0;
|
||||||
const int ERROR_ON_EXIT = 1;
|
const int ERROR_ON_EXIT = 1;
|
||||||
|
|
||||||
typedef vector<pair<Tags, void * > > code_liste_type;
|
typedef vector<pair<Tags, void * >> code_liste_type;
|
||||||
typedef code_liste_type::const_iterator it_code_type;
|
typedef code_liste_type::const_iterator it_code_type;
|
||||||
|
|
||||||
class GeneralExceptionHandling
|
class GeneralExceptionHandling
|
||||||
|
@ -271,7 +271,7 @@ struct s_plan
|
||||||
{
|
{
|
||||||
string var, exo;
|
string var, exo;
|
||||||
int var_num, exo_num;
|
int var_num, exo_num;
|
||||||
vector<pair<int, double> > per_value;
|
vector<pair<int, double>> per_value;
|
||||||
vector<double> value;
|
vector<double> value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ public:
|
||||||
vector<mxArray *> jacobian_block, jacobian_other_endo_block, jacobian_exo_block, jacobian_det_exo_block;
|
vector<mxArray *> jacobian_block, jacobian_other_endo_block, jacobian_exo_block, jacobian_det_exo_block;
|
||||||
map<unsigned int, double> TEF;
|
map<unsigned int, double> TEF;
|
||||||
map<pair<unsigned int, unsigned int>, double > TEFD;
|
map<pair<unsigned int, unsigned int>, double > TEFD;
|
||||||
map<pair<unsigned int, pair<unsigned int, unsigned int> >, double > TEFDD;
|
map<pair<unsigned int, pair<unsigned int, unsigned int>>, double > TEFDD;
|
||||||
|
|
||||||
ExpressionType EQN_type;
|
ExpressionType EQN_type;
|
||||||
it_code_type it_code_expr;
|
it_code_type it_code_expr;
|
||||||
|
@ -319,7 +319,7 @@ public:
|
||||||
size_t /*unsigned int*/ endo_name_length, exo_name_length, param_name_length;
|
size_t /*unsigned int*/ endo_name_length, exo_name_length, param_name_length;
|
||||||
unsigned int EQN_equation, EQN_block, EQN_block_number;
|
unsigned int EQN_equation, EQN_block, EQN_block_number;
|
||||||
unsigned int EQN_dvar1, EQN_dvar2, EQN_dvar3;
|
unsigned int EQN_dvar1, EQN_dvar2, EQN_dvar3;
|
||||||
vector<pair<string, pair<SymbolType, unsigned int> > > Variable_list;
|
vector<pair<string, pair<SymbolType, unsigned int>>> Variable_list;
|
||||||
|
|
||||||
inline
|
inline
|
||||||
ErrorMsg()
|
ErrorMsg()
|
||||||
|
@ -2134,7 +2134,7 @@ public:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
double rr = Stackf.top();
|
double rr = Stackf.top();
|
||||||
mexPrintf("rr=%f\n", rr);
|
mexPrintf("rr=%f\n", rr);
|
||||||
map<pair<unsigned int, pair<unsigned int, unsigned int> >, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1)));
|
map<pair<unsigned int, pair<unsigned int, unsigned int>>, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1)));
|
||||||
mexPrintf("FSTP TEFDD[make_pair(indx, make_pair(row, col))]=%f done\n", it->second);
|
mexPrintf("FSTP TEFDD[make_pair(indx, make_pair(row, col))]=%f done\n", it->second);
|
||||||
mexEvalString("drawnow;");
|
mexEvalString("drawnow;");
|
||||||
#endif
|
#endif
|
||||||
|
@ -2157,13 +2157,13 @@ public:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mexPrintf("FLDTEFD\n");
|
mexPrintf("FLDTEFD\n");
|
||||||
mexPrintf("indx=%d Stack.size()=%d\n", indx, Stack.size());
|
mexPrintf("indx=%d Stack.size()=%d\n", indx, Stack.size());
|
||||||
map<pair<unsigned int, pair<unsigned int, unsigned int> >, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1)));
|
map<pair<unsigned int, pair<unsigned int, unsigned int>>, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1)));
|
||||||
mexPrintf("FLD TEFD[make_pair(indx, make_pair(row, col))]=%f done\n", it->second);
|
mexPrintf("FLD TEFD[make_pair(indx, make_pair(row, col))]=%f done\n", it->second);
|
||||||
mexEvalString("drawnow;");
|
mexEvalString("drawnow;");
|
||||||
#endif
|
#endif
|
||||||
if (compute)
|
if (compute)
|
||||||
{
|
{
|
||||||
map<pair<unsigned int, pair<unsigned int, unsigned int> >, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1)));
|
map<pair<unsigned int, pair<unsigned int, unsigned int>>, double>::const_iterator it = TEFDD.find(make_pair(indx, make_pair(row-1, col-1)));
|
||||||
Stackf.push(it->second);
|
Stackf.push(it->second);
|
||||||
}
|
}
|
||||||
tmp_out.str("");
|
tmp_out.str("");
|
||||||
|
|
|
@ -921,9 +921,9 @@ Interpreter::extended_path(string file_name, string bin_basename, bool evaluate,
|
||||||
MainLoop(bin_basename, code, evaluate, block, true, true, sconstrained_extended_path, vector_table_conditional_local);
|
MainLoop(bin_basename, code, evaluate, block, true, true, sconstrained_extended_path, vector_table_conditional_local);
|
||||||
for (int j = 0; j < y_size; j++)
|
for (int j = 0; j < y_size; j++)
|
||||||
{
|
{
|
||||||
y_save[j + (t + y_kmin) * y_size] = y[ j + (y_kmin) * y_size];
|
y_save[j + (t + y_kmin) * y_size] = y[j + y_kmin * y_size];
|
||||||
if (y_kmin > 0)
|
if (y_kmin > 0)
|
||||||
y[j ] = y[ j + (y_kmin) * y_size];
|
y[j] = y[j + y_kmin * y_size];
|
||||||
}
|
}
|
||||||
for (int j = 0; j < col_x; j++)
|
for (int j = 0; j < col_x; j++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,39 +49,39 @@ t_umfpack_dl_free_numeric umfpack_dl_free_numeric;
|
||||||
typedef void (*t_umfpack_dl_free_symbolic)(void **Symbolic);
|
typedef void (*t_umfpack_dl_free_symbolic)(void **Symbolic);
|
||||||
t_umfpack_dl_free_symbolic umfpack_dl_free_symbolic;
|
t_umfpack_dl_free_symbolic umfpack_dl_free_symbolic;
|
||||||
typedef int64_t (*t_umfpack_dl_solve)(int64_t sys,
|
typedef int64_t (*t_umfpack_dl_solve)(int64_t sys,
|
||||||
const int64_t Ap [],
|
const int64_t Ap[],
|
||||||
const int64_t Ai [],
|
const int64_t Ai[],
|
||||||
const double Ax [],
|
const double Ax[],
|
||||||
double X [],
|
double X[],
|
||||||
const double B [],
|
const double B[],
|
||||||
void *Numeric,
|
void *Numeric,
|
||||||
const double Control [UMFPACK_CONTROL],
|
const double Control[UMFPACK_CONTROL],
|
||||||
double Info [UMFPACK_INFO]);
|
double Info[UMFPACK_INFO]);
|
||||||
t_umfpack_dl_solve umfpack_dl_solve;
|
t_umfpack_dl_solve umfpack_dl_solve;
|
||||||
typedef int64_t (*t_umfpack_dl_numeric)(const int64_t Ap [],
|
typedef int64_t (*t_umfpack_dl_numeric)(const int64_t Ap[],
|
||||||
const int64_t Ai [],
|
const int64_t Ai[],
|
||||||
const double Ax [],
|
const double Ax[],
|
||||||
void *Symbolic,
|
void *Symbolic,
|
||||||
void **Numeric,
|
void **Numeric,
|
||||||
const double Control [UMFPACK_CONTROL],
|
const double Control[UMFPACK_CONTROL],
|
||||||
double Info [UMFPACK_INFO]);
|
double Info[UMFPACK_INFO]);
|
||||||
t_umfpack_dl_numeric umfpack_dl_numeric;
|
t_umfpack_dl_numeric umfpack_dl_numeric;
|
||||||
typedef int64_t (*t_umfpack_dl_symbolic)(int64_t n_row,
|
typedef int64_t (*t_umfpack_dl_symbolic)(int64_t n_row,
|
||||||
int64_t n_col,
|
int64_t n_col,
|
||||||
const int64_t Ap [],
|
const int64_t Ap[],
|
||||||
const int64_t Ai [],
|
const int64_t Ai[],
|
||||||
const double Ax [],
|
const double Ax[],
|
||||||
void **Symbolic,
|
void **Symbolic,
|
||||||
const double Control [UMFPACK_CONTROL],
|
const double Control[UMFPACK_CONTROL],
|
||||||
double Info [UMFPACK_INFO]);
|
double Info[UMFPACK_INFO]);
|
||||||
t_umfpack_dl_symbolic umfpack_dl_symbolic;
|
t_umfpack_dl_symbolic umfpack_dl_symbolic;
|
||||||
typedef void (*t_umfpack_dl_report_info)(const double Control [UMFPACK_CONTROL],
|
typedef void (*t_umfpack_dl_report_info)(const double Control[UMFPACK_CONTROL],
|
||||||
const double Info [UMFPACK_INFO]);
|
const double Info[UMFPACK_INFO]);
|
||||||
t_umfpack_dl_report_info umfpack_dl_report_info;
|
t_umfpack_dl_report_info umfpack_dl_report_info;
|
||||||
typedef void (*t_umfpack_dl_report_status)(const double Control [UMFPACK_CONTROL],
|
typedef void (*t_umfpack_dl_report_status)(const double Control[UMFPACK_CONTROL],
|
||||||
int64_t status);
|
int64_t status);
|
||||||
t_umfpack_dl_report_status umfpack_dl_report_status;
|
t_umfpack_dl_report_status umfpack_dl_report_status;
|
||||||
typedef void (*t_umfpack_dl_defaults)(double Control [UMFPACK_CONTROL]);
|
typedef void (*t_umfpack_dl_defaults)(double Control[UMFPACK_CONTROL]);
|
||||||
t_umfpack_dl_defaults umfpack_dl_defaults;
|
t_umfpack_dl_defaults umfpack_dl_defaults;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -796,7 +796,7 @@ dynSparseMatrix::Init_Matlab_Sparse_Simple(int Size, map<pair<pair<int, int>, in
|
||||||
var = it4->first.first.first;
|
var = it4->first.first.first;
|
||||||
if (var != last_var)
|
if (var != last_var)
|
||||||
{
|
{
|
||||||
Aj[1+last_var ] = NZE;
|
Aj[1+last_var] = NZE;
|
||||||
last_var = var;
|
last_var = var;
|
||||||
}
|
}
|
||||||
eq = it4->first.second;
|
eq = it4->first.second;
|
||||||
|
@ -894,7 +894,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse_Simple(int Size, map<pair<pair<int, int>, i
|
||||||
ya[eq+it_*y_size] = y[eq+it_*y_size];
|
ya[eq+it_*y_size] = y[eq+it_*y_size];
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
unsigned int max_nze = prior_nz;//mxGetNzmax(A_m);
|
unsigned int max_nze = prior_nz; //mxGetNzmax(A_m);
|
||||||
#endif
|
#endif
|
||||||
unsigned int NZE = 0;
|
unsigned int NZE = 0;
|
||||||
int last_var = 0;
|
int last_var = 0;
|
||||||
|
@ -918,7 +918,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse_Simple(int Size, map<pair<pair<int, int>, i
|
||||||
var = it4->first.first.first;
|
var = it4->first.first.first;
|
||||||
if (var != last_var)
|
if (var != last_var)
|
||||||
{
|
{
|
||||||
(*Ap)[1+last_var ] = NZE;
|
(*Ap)[1+last_var] = NZE;
|
||||||
last_var = var;
|
last_var = var;
|
||||||
}
|
}
|
||||||
eq = it4->first.second;
|
eq = it4->first.second;
|
||||||
|
@ -980,11 +980,11 @@ dynSparseMatrix::find_exo_num(vector<s_plan> sconstrained_extended_path, int val
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dynSparseMatrix::find_int_date(vector<pair<int, double> > per_value, int value)
|
dynSparseMatrix::find_int_date(vector<pair<int, double>> per_value, int value)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (vector<pair<int, double> >::iterator it = per_value.begin(); it != per_value.end(); it++, i++)
|
for (vector<pair<int, double>>::iterator it = per_value.begin(); it != per_value.end(); it++, i++)
|
||||||
if (it->first == value)
|
if (it->first == value)
|
||||||
{
|
{
|
||||||
res = i;
|
res = i;
|
||||||
|
@ -1369,7 +1369,7 @@ dynSparseMatrix::Init_CUDA_Sparse_Simple(int Size, map<pair<pair<int, int>, int>
|
||||||
var = it4->first.first.first;
|
var = it4->first.first.first;
|
||||||
if (var != last_var)
|
if (var != last_var)
|
||||||
{
|
{
|
||||||
(*Ap)[1+last_var ] = NZE;
|
(*Ap)[1+last_var] = NZE;
|
||||||
last_var = var;
|
last_var = var;
|
||||||
}
|
}
|
||||||
eq = it4->first.second;
|
eq = it4->first.second;
|
||||||
|
@ -1509,7 +1509,7 @@ dynSparseMatrix::Init_CUDA_Sparse(int periods, int y_kmin, int y_kmax, int Size,
|
||||||
# endif
|
# endif
|
||||||
Host_Ap[1+last_eq + t * Size] = NZE;
|
Host_Ap[1+last_eq + t * Size] = NZE;
|
||||||
if (preconditioner == 3 && t == 0)
|
if (preconditioner == 3 && t == 0)
|
||||||
Host_Ap_tild[1+last_eq ] = NZE_tild;
|
Host_Ap_tild[1+last_eq] = NZE_tild;
|
||||||
last_eq = eq;
|
last_eq = eq;
|
||||||
}
|
}
|
||||||
var = it4->first.second+Size*t;
|
var = it4->first.second+Size*t;
|
||||||
|
@ -3133,7 +3133,7 @@ dynSparseMatrix::Solve_Matlab_Relaxation(mxArray *A_m, mxArray *b_m, unsigned in
|
||||||
while (A3_var < Size)
|
while (A3_var < Size)
|
||||||
A3_j[++A3_var] = A3_nze;
|
A3_j[++A3_var] = A3_nze;
|
||||||
mxArray *d1 = NULL;
|
mxArray *d1 = NULL;
|
||||||
vector<pair<mxArray *, mxArray *> > triangular_form;
|
vector<pair<mxArray *, mxArray *>> triangular_form;
|
||||||
double sumc = 0, C_sumc = 1000;
|
double sumc = 0, C_sumc = 1000;
|
||||||
mxArray *B1_inv = NULL;
|
mxArray *B1_inv = NULL;
|
||||||
mxArray *B1_inv_t = NULL;
|
mxArray *B1_inv_t = NULL;
|
||||||
|
@ -3333,7 +3333,7 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
|
||||||
{
|
{
|
||||||
SuiteSparse_long status, sys = 0;
|
SuiteSparse_long status, sys = 0;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO], res [n];
|
double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO], res[n];
|
||||||
#else
|
#else
|
||||||
double *Control, *Info, *res;
|
double *Control, *Info, *res;
|
||||||
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
||||||
|
@ -3345,7 +3345,7 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
umfpack_dl_defaults(Control);
|
umfpack_dl_defaults(Control);
|
||||||
Control [UMFPACK_PRL] = 5;
|
Control[UMFPACK_PRL] = 5;
|
||||||
status = 0;
|
status = 0;
|
||||||
if (iter == 0)
|
if (iter == 0)
|
||||||
{
|
{
|
||||||
|
@ -3400,7 +3400,7 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int eq = index_vara[i+Size*(y_kmin)];
|
int eq = index_vara[i+Size*(y_kmin)];
|
||||||
double yy = -(res[i ] + y[eq]);
|
double yy = -(res[i] + y[eq]);
|
||||||
direction[eq] = yy;
|
direction[eq] = yy;
|
||||||
y[eq] += slowc_l * yy;
|
y[eq] += slowc_l * yy;
|
||||||
}
|
}
|
||||||
|
@ -3461,7 +3461,7 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
|
||||||
{
|
{
|
||||||
SuiteSparse_long status, sys = 0;
|
SuiteSparse_long status, sys = 0;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO], res [n];
|
double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO], res[n];
|
||||||
#else
|
#else
|
||||||
double *Control, *Info, *res;
|
double *Control, *Info, *res;
|
||||||
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
||||||
|
@ -3473,7 +3473,7 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
umfpack_dl_defaults(Control);
|
umfpack_dl_defaults(Control);
|
||||||
Control [UMFPACK_PRL] = 5;
|
Control[UMFPACK_PRL] = 5;
|
||||||
status = 0;
|
status = 0;
|
||||||
if (iter == 0)
|
if (iter == 0)
|
||||||
{
|
{
|
||||||
|
@ -3547,7 +3547,7 @@ dynSparseMatrix::Solve_LU_UMFPack(mxArray *A_m, mxArray *b_m, int Size, double s
|
||||||
double *B = mxGetPr(b_m);
|
double *B = mxGetPr(b_m);
|
||||||
SuiteSparse_long status, sys = 0;
|
SuiteSparse_long status, sys = 0;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO], res [n];
|
double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO], res[n];
|
||||||
#else
|
#else
|
||||||
double *Control, *Info, *res;
|
double *Control, *Info, *res;
|
||||||
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
||||||
|
@ -3627,7 +3627,7 @@ printM(int n, double *Ax, int *Ap, int *Ai, cusparseMatDescr_t descrA, cusparse
|
||||||
|
|
||||||
void
|
void
|
||||||
dynSparseMatrix::Solve_CUDA_BiCGStab_Free(double *tmp_vect_host, double *p, double *r, double *v, double *s, double *t, double *y_, double *z, double *tmp_,
|
dynSparseMatrix::Solve_CUDA_BiCGStab_Free(double *tmp_vect_host, double *p, double *r, double *v, double *s, double *t, double *y_, double *z, double *tmp_,
|
||||||
int *Ai, double *Ax, int *Ap, double *x0, double *b, double *A_tild, int *A_tild_i, int *A_tild_p/*, double* Lx, int* Li, int* Lp,
|
int *Ai, double *Ax, int *Ap, double *x0, double *b, double *A_tild, int *A_tild_i, int *A_tild_p /*, double* Lx, int* Li, int* Lp,
|
||||||
double* Ux, int* Ui, int* Up, int* device_n*/, cusparseSolveAnalysisInfo_t infoL, cusparseSolveAnalysisInfo_t infoU,
|
double* Ux, int* Ui, int* Up, int* device_n*/, cusparseSolveAnalysisInfo_t infoL, cusparseSolveAnalysisInfo_t infoU,
|
||||||
cusparseMatDescr_t descrL, cusparseMatDescr_t descrU, int preconditioner)
|
cusparseMatDescr_t descrL, cusparseMatDescr_t descrU, int preconditioner)
|
||||||
{
|
{
|
||||||
|
@ -3756,7 +3756,7 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
|
||||||
{
|
{
|
||||||
cusparseSolveAnalysisInfo_t info, infoL, infoU;
|
cusparseSolveAnalysisInfo_t info, infoL, infoU;
|
||||||
cusparseMatDescr_t descrL, descrU;
|
cusparseMatDescr_t descrL, descrU;
|
||||||
const double tol = 1.0e-6;//1.0e-6;
|
const double tol = 1.0e-6; //1.0e-6;
|
||||||
const double eps = 1.0e-16;
|
const double eps = 1.0e-16;
|
||||||
double *p, *r, *r0, *v, *s, *t, *y_, *z, *tmp_;
|
double *p, *r, *r0, *v, *s, *t, *y_, *z, *tmp_;
|
||||||
int *A_tild_i, *A_tild_p;
|
int *A_tild_i, *A_tild_p;
|
||||||
|
@ -5129,7 +5129,7 @@ dynSparseMatrix::Singular_display(int block, int Size)
|
||||||
{
|
{
|
||||||
int k = first->u_index;
|
int k = first->u_index;
|
||||||
int jj = first->r_index;
|
int jj = first->r_index;
|
||||||
pind[ii * Size + jj ] = u[k];
|
pind[ii * Size + jj] = u[k];
|
||||||
first = first->NZE_C_N;
|
first = first->NZE_C_N;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6458,7 +6458,6 @@ dynSparseMatrix::solve_linear(const int block_num, const int y_size, const int y
|
||||||
|
|
||||||
void
|
void
|
||||||
dynSparseMatrix::solve_non_linear(const int block_num, const int y_size, const int y_kmin, const int y_kmax, const int size)
|
dynSparseMatrix::solve_non_linear(const int block_num, const int y_size, const int y_kmin, const int y_kmax, const int size)
|
||||||
|
|
||||||
{
|
{
|
||||||
max_res_idx = 0;
|
max_res_idx = 0;
|
||||||
bool cvg = false;
|
bool cvg = false;
|
||||||
|
|
|
@ -122,7 +122,7 @@ public:
|
||||||
double g0, gp0, glambda2;
|
double g0, gp0, glambda2;
|
||||||
int try_at_iteration;
|
int try_at_iteration;
|
||||||
int find_exo_num(vector<s_plan> sconstrained_extended_path, int value);
|
int find_exo_num(vector<s_plan> sconstrained_extended_path, int value);
|
||||||
int find_int_date(vector<pair<int, double> > per_value, int value);
|
int find_int_date(vector<pair<int, double>> per_value, int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init_GE(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int>, int>, int> &IM);
|
void Init_GE(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int>, int>, int> &IM);
|
||||||
|
|
|
@ -704,7 +704,7 @@ main(int nrhs, const char *prhs[])
|
||||||
string tmp = "Can not allocated memory to store the date_str in the extended path descriptor";
|
string tmp = "Can not allocated memory to store the date_str in the extended path descriptor";
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT(tmp.c_str());
|
DYN_MEX_FUNC_ERR_MSG_TXT(tmp.c_str());
|
||||||
}
|
}
|
||||||
dates.push_back(string(buf));//string(Dates[i]);
|
dates.push_back(string(buf)); //string(Dates[i]);
|
||||||
mxFree(buf);
|
mxFree(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,7 +726,7 @@ main(int nrhs, const char *prhs[])
|
||||||
mxArray *tmp = mxGetField(plan_struct, i, "exo");
|
mxArray *tmp = mxGetField(plan_struct, i, "exo");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
char name [100];
|
char name[100];
|
||||||
mxGetString(tmp, name, 100);
|
mxGetString(tmp, name, 100);
|
||||||
splan[i].var = name;
|
splan[i].var = name;
|
||||||
SymbolType variable_type = SymbolType::endogenous;
|
SymbolType variable_type = SymbolType::endogenous;
|
||||||
|
@ -744,7 +744,7 @@ main(int nrhs, const char *prhs[])
|
||||||
tmp = mxGetField(plan_struct, i, "var");
|
tmp = mxGetField(plan_struct, i, "var");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
char name [100];
|
char name[100];
|
||||||
mxGetString(tmp, name, 100);
|
mxGetString(tmp, name, 100);
|
||||||
splan[i].exo = name;
|
splan[i].exo = name;
|
||||||
SymbolType variable_type;
|
SymbolType variable_type;
|
||||||
|
@ -778,7 +778,7 @@ main(int nrhs, const char *prhs[])
|
||||||
mexPrintf(" plan fliping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
mexPrintf(" plan fliping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
||||||
else
|
else
|
||||||
mexPrintf(" plan shocks on var=%s for the following periods and with the following values:\n", it->var.c_str());
|
mexPrintf(" plan shocks on var=%s for the following periods and with the following values:\n", it->var.c_str());
|
||||||
for (vector<pair<int, double> >::iterator it1 = it->per_value.begin(); it1 != it->per_value.end(); it1++)
|
for (vector<pair<int, double>>::iterator it1 = it->per_value.begin(); it1 != it->per_value.end(); it1++)
|
||||||
{
|
{
|
||||||
mexPrintf(" %3d %10.5f\n", it1->first, it1->second);
|
mexPrintf(" %3d %10.5f\n", it1->first, it1->second);
|
||||||
}
|
}
|
||||||
|
@ -804,7 +804,7 @@ main(int nrhs, const char *prhs[])
|
||||||
mxArray *tmp = mxGetField(pfplan_struct, i, "var");
|
mxArray *tmp = mxGetField(pfplan_struct, i, "var");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
char name [100];
|
char name[100];
|
||||||
mxGetString(tmp, name, 100);
|
mxGetString(tmp, name, 100);
|
||||||
spfplan[i].var = name;
|
spfplan[i].var = name;
|
||||||
SymbolType variable_type = SymbolType::endogenous;
|
SymbolType variable_type = SymbolType::endogenous;
|
||||||
|
@ -822,7 +822,7 @@ main(int nrhs, const char *prhs[])
|
||||||
tmp = mxGetField(pfplan_struct, i, "exo");
|
tmp = mxGetField(pfplan_struct, i, "exo");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
char name [100];
|
char name[100];
|
||||||
mxGetString(tmp, name, 100);
|
mxGetString(tmp, name, 100);
|
||||||
spfplan[i].exo = name;
|
spfplan[i].exo = name;
|
||||||
SymbolType variable_type;
|
SymbolType variable_type;
|
||||||
|
@ -856,7 +856,7 @@ main(int nrhs, const char *prhs[])
|
||||||
mexPrintf(" plan flipping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
mexPrintf(" plan flipping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
||||||
else
|
else
|
||||||
mexPrintf(" plan shocks on var=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num);
|
mexPrintf(" plan shocks on var=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num);
|
||||||
for (vector<pair<int, double> >::iterator it1 = it->per_value.begin(); it1 != it->per_value.end(); it1++)
|
for (vector<pair<int, double>>::iterator it1 = it->per_value.begin(); it1 != it->per_value.end(); it1++)
|
||||||
{
|
{
|
||||||
mexPrintf(" %3d %10.5f\n", it1->first, it1->second);
|
mexPrintf(" %3d %10.5f\n", it1->first, it1->second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,7 +347,7 @@ read_struct(FILE *fid)
|
||||||
fscanf(fid, "%d", &size_2);
|
fscanf(fid, "%d", &size_2);
|
||||||
vector<string> fieldnames;
|
vector<string> fieldnames;
|
||||||
vector<mxArray *> v_Array;
|
vector<mxArray *> v_Array;
|
||||||
vector<vector<mxArray * > > vv_Array;
|
vector<vector<mxArray * >> vv_Array;
|
||||||
for (unsigned int j = 0; j < size_1 * size_2; j++)
|
for (unsigned int j = 0; j < size_1 * size_2; j++)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < nfields; i++)
|
for (unsigned int i = 0; i < nfields; i++)
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
double *data;
|
double *data;
|
||||||
mxArray_type type;
|
mxArray_type type;
|
||||||
vector<string> field_name;
|
vector<string> field_name;
|
||||||
vector<vector<mxArray_tag *> > field_array;
|
vector<vector<mxArray_tag *>> field_array;
|
||||||
mxArray_tag();
|
mxArray_tag();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,9 @@ class DynamicModelAC
|
||||||
protected:
|
protected:
|
||||||
int ntt; // Size of vector of temporary terms
|
int ntt; // Size of vector of temporary terms
|
||||||
public:
|
public:
|
||||||
DynamicModelAC(int ntt_arg) : ntt{ntt_arg} {};
|
DynamicModelAC(int ntt_arg) : ntt{ntt_arg}
|
||||||
|
{
|
||||||
|
};
|
||||||
virtual ~DynamicModelAC() = default;
|
virtual ~DynamicModelAC() = default;
|
||||||
virtual void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady,
|
virtual void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady,
|
||||||
Vector &residual, std::vector<TwoDMatrix> &md) = 0;
|
Vector &residual, std::vector<TwoDMatrix> &md) = 0;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "dynamic_abstract_class.hh"
|
#include "dynamic_abstract_class.hh"
|
||||||
|
|
||||||
using dynamic_tt_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T);
|
using dynamic_tt_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T);
|
||||||
using dynamic_deriv_fct = void (*) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *deriv);
|
using dynamic_deriv_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *deriv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates pointer to Dynamic function inside <model>_dynamic.dll
|
* creates pointer to Dynamic function inside <model>_dynamic.dll
|
||||||
|
|
|
@ -236,4 +236,3 @@ DynareStateNameList::DynareStateNameList(const KordpDynare &dynare, const Dynare
|
||||||
for (int i = 0; i < dynare.nexog(); i++)
|
for (int i = 0; i < dynare.nexog(); i++)
|
||||||
names.emplace_back(denl.getName(i));
|
names.emplace_back(denl.getName(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,4 +312,3 @@ extern "C" {
|
||||||
plhs[0] = mxCreateDoubleScalar(0);
|
plhs[0] = mxCreateDoubleScalar(0);
|
||||||
} // end of mexFunction()
|
} // end of mexFunction()
|
||||||
} // end of extern C
|
} // end of extern C
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
npar = 2; //(int)mxGetN(mxFldp);
|
npar = 2; //(int)mxGetN(mxFldp);
|
||||||
TwoDMatrix *vCov = new TwoDMatrix(npar, npar, (d2Dparams));
|
TwoDMatrix *vCov = new TwoDMatrix(npar, npar, (d2Dparams));
|
||||||
double dYSparams [16] = { // 27 mxGetData(mxFldp);
|
double dYSparams[16] = { // 27 mxGetData(mxFldp);
|
||||||
// 1.0110, 2.2582, 5.8012, 0.5808,
|
// 1.0110, 2.2582, 5.8012, 0.5808,
|
||||||
1.0110, 2.2582, 0.4477, 1.0000,
|
1.0110, 2.2582, 0.4477, 1.0000,
|
||||||
4.5959, 1.0212, 5.8012, 0.8494,
|
4.5959, 1.0212, 5.8012, 0.8494,
|
||||||
|
@ -117,7 +117,7 @@ main(int argc, char *argv[])
|
||||||
for (int v = 0; v < nEndo; v++)
|
for (int v = 0; v < nEndo; v++)
|
||||||
(*var_order_vp)[v] = var_order[v];
|
(*var_order_vp)[v] = var_order[v];
|
||||||
|
|
||||||
const double ll_incidence [] //[3][18]
|
const double ll_incidence[] //[3][18]
|
||||||
= {
|
= {
|
||||||
1, 5, 21,
|
1, 5, 21,
|
||||||
2, 6, 22,
|
2, 6, 22,
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
|
||||||
#define FIRST_ORDER_LOOP 1// Comment out this line to use mkl-blas instead of loops when computing ghx*yhat and ghu*epsilon
|
#define FIRST_ORDER_LOOP 1 // Comment out this line to use mkl-blas instead of loops when computing ghx*yhat and ghu*epsilon
|
||||||
|
|
||||||
std::tuple<std::vector<int>, std::vector<int>, std::vector<int>>
|
std::tuple<std::vector<int>, std::vector<int>, std::vector<int>>
|
||||||
set_vector_of_indices(int n, int r)
|
set_vector_of_indices(int n, int r)
|
||||||
|
@ -231,10 +231,10 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
|
||||||
mexErrMsgTxt("Too many output arguments.");
|
mexErrMsgTxt("Too many output arguments.");
|
||||||
|
|
||||||
// Get dimensions.
|
// Get dimensions.
|
||||||
size_t n = mxGetM(prhs[0]);// Number of states.
|
size_t n = mxGetM(prhs[0]); // Number of states.
|
||||||
size_t s = mxGetN(prhs[0]);// Number of particles.
|
size_t s = mxGetN(prhs[0]); // Number of particles.
|
||||||
size_t q = mxGetM(prhs[1]);// Number of innovations.
|
size_t q = mxGetM(prhs[1]); // Number of innovations.
|
||||||
size_t m = mxGetM(prhs[2]);// Number of elements in the union of states and observed variables.
|
size_t m = mxGetM(prhs[2]); // Number of elements in the union of states and observed variables.
|
||||||
//mexPrintf("\n s (the number of column of yhat) is equal to %d.", s);
|
//mexPrintf("\n s (the number of column of yhat) is equal to %d.", s);
|
||||||
//mexPrintf("\n The number of column of epsilon is %d.", mxGetN(prhs[1]));
|
//mexPrintf("\n The number of column of epsilon is %d.", mxGetN(prhs[1]));
|
||||||
// Check the dimensions.
|
// Check the dimensions.
|
||||||
|
|
|
@ -37,13 +37,13 @@
|
||||||
struct ParticleWorker : public sthread::detach_thread
|
struct ParticleWorker : public sthread::detach_thread
|
||||||
{
|
{
|
||||||
const int npred_both, exo_nbr;
|
const int npred_both, exo_nbr;
|
||||||
const std::pair<size_t,size_t> particle_range;
|
const std::pair<size_t, size_t> particle_range;
|
||||||
const ConstGeneralMatrix &yhat, ε
|
const ConstGeneralMatrix &yhat, ε
|
||||||
const Vector &ys_reordered;
|
const Vector &ys_reordered;
|
||||||
const UnfoldDecisionRule &dr;
|
const UnfoldDecisionRule &dr;
|
||||||
GeneralMatrix &ynext;
|
GeneralMatrix &ynext;
|
||||||
|
|
||||||
ParticleWorker(int npred_both_arg, int exo_nbr_arg, std::pair<size_t,size_t> particle_range_arg,
|
ParticleWorker(int npred_both_arg, int exo_nbr_arg, std::pair<size_t, size_t> particle_range_arg,
|
||||||
const ConstGeneralMatrix &yhat_arg, const ConstGeneralMatrix &epsilon_arg,
|
const ConstGeneralMatrix &yhat_arg, const ConstGeneralMatrix &epsilon_arg,
|
||||||
const Vector &ys_reordered_arg, const UnfoldDecisionRule &dr_arg,
|
const Vector &ys_reordered_arg, const UnfoldDecisionRule &dr_arg,
|
||||||
GeneralMatrix &ynext_arg)
|
GeneralMatrix &ynext_arg)
|
||||||
|
@ -52,7 +52,8 @@ struct ParticleWorker : public sthread::detach_thread
|
||||||
ynext{ynext_arg}
|
ynext{ynext_arg}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void operator()(std::mutex &mut) override
|
void
|
||||||
|
operator()(std::mutex &mut) override
|
||||||
{
|
{
|
||||||
Vector dyu(npred_both+exo_nbr);
|
Vector dyu(npred_both+exo_nbr);
|
||||||
Vector dy(dyu, 0, npred_both);
|
Vector dy(dyu, 0, npred_both);
|
||||||
|
|
|
@ -48,16 +48,16 @@ mexFunction(int nlhs, mxArray *plhs[],
|
||||||
/*
|
/*
|
||||||
* Allocate memory
|
* Allocate memory
|
||||||
*/
|
*/
|
||||||
maxnargs = static_cast<int> (mxGetN(prhs[0])/2+1);
|
maxnargs = static_cast<int>(mxGetN(prhs[0])/2+1);
|
||||||
argument = static_cast<char *> (mxCalloc(mxGetN(prhs[0])+1, sizeof(char)));
|
argument = static_cast<char *>(mxCalloc(mxGetN(prhs[0])+1, sizeof(char)));
|
||||||
args = static_cast<char **> (mxCalloc(maxnargs, sizeof(char *)));
|
args = static_cast<char **>(mxCalloc(maxnargs, sizeof(char *)));
|
||||||
if (argument == NULL || args == NULL)
|
if (argument == NULL || args == NULL)
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (1)");
|
DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (1)");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create argument string from prhs and parse to create args / nargs
|
* Create argument string from prhs and parse to create args / nargs
|
||||||
*/
|
*/
|
||||||
if (!(args[nargs] = static_cast<char *> (mxCalloc(strlen(mainarg)+1, sizeof(char)))))
|
if (!(args[nargs] = static_cast<char *>(mxCalloc(strlen(mainarg)+1, sizeof(char)))))
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (2)");
|
DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (2)");
|
||||||
|
|
||||||
strncpy(args[nargs++], mainarg, strlen(mainarg));
|
strncpy(args[nargs++], mainarg, strlen(mainarg));
|
||||||
|
@ -68,7 +68,7 @@ mexFunction(int nlhs, mxArray *plhs[],
|
||||||
beginarg = &argument[0];
|
beginarg = &argument[0];
|
||||||
while ((n = strcspn(beginarg, " ")))
|
while ((n = strcspn(beginarg, " ")))
|
||||||
{
|
{
|
||||||
if (!(args[nargs] = static_cast<char *> (mxCalloc(n+1, sizeof(char)))))
|
if (!(args[nargs] = static_cast<char *>(mxCalloc(n+1, sizeof(char)))))
|
||||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (3)");
|
DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (3)");
|
||||||
|
|
||||||
strncpy(args[nargs++], beginarg, n);
|
strncpy(args[nargs++], beginarg, n);
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
|
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
|
||||||
|
|
||||||
#include <dynmex.h>
|
# include <dynmex.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
int constant_seed;
|
int constant_seed;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ extern "C"
|
||||||
throw "Error in MS-SBVAR MEX file.\n";
|
throw "Error in MS-SBVAR MEX file.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,7 +39,9 @@ public:
|
||||||
// Used to store error messages (as exceptions cannot cross the OpenMP boundary)
|
// Used to store error messages (as exceptions cannot cross the OpenMP boundary)
|
||||||
static std::string error_msg;
|
static std::string error_msg;
|
||||||
|
|
||||||
DynamicModelCaller(bool linear_arg, bool compute_jacobian_arg) : linear{linear_arg}, compute_jacobian{compute_jacobian_arg} {};
|
DynamicModelCaller(bool linear_arg, bool compute_jacobian_arg) : linear{linear_arg}, compute_jacobian{compute_jacobian_arg}
|
||||||
|
{
|
||||||
|
};
|
||||||
virtual ~DynamicModelCaller() = default;
|
virtual ~DynamicModelCaller() = default;
|
||||||
virtual double &y(size_t i) const = 0;
|
virtual double &y(size_t i) const = 0;
|
||||||
virtual double jacobian(size_t i) const = 0;
|
virtual double jacobian(size_t i) const = 0;
|
||||||
|
@ -55,7 +57,7 @@ private:
|
||||||
static void *dynamic_mex;
|
static void *dynamic_mex;
|
||||||
#endif
|
#endif
|
||||||
using dynamic_tt_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T);
|
using dynamic_tt_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T);
|
||||||
using dynamic_deriv_fct = void (*) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *deriv);
|
using dynamic_deriv_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *deriv);
|
||||||
static dynamic_tt_fct residual_tt_fct, g1_tt_fct;
|
static dynamic_tt_fct residual_tt_fct, g1_tt_fct;
|
||||||
static dynamic_deriv_fct residual_fct, g1_fct;
|
static dynamic_deriv_fct residual_fct, g1_fct;
|
||||||
size_t nb_row_x;
|
size_t nb_row_x;
|
||||||
|
@ -65,8 +67,16 @@ private:
|
||||||
public:
|
public:
|
||||||
DynamicModelDllCaller(size_t ntt, mwIndex nx, mwIndex ny, size_t ndynvars, const double *x_arg, size_t nb_row_x_arg, const double *params_arg, const double *steady_state_arg, bool linear_arg, bool compute_jacobian_arg);
|
DynamicModelDllCaller(size_t ntt, mwIndex nx, mwIndex ny, size_t ndynvars, const double *x_arg, size_t nb_row_x_arg, const double *params_arg, const double *steady_state_arg, bool linear_arg, bool compute_jacobian_arg);
|
||||||
virtual ~DynamicModelDllCaller() = default;
|
virtual ~DynamicModelDllCaller() = default;
|
||||||
double &y(size_t i) const override { return y_p[i]; };
|
double &
|
||||||
double jacobian(size_t i) const override { return jacobian_p[i]; };
|
y(size_t i) const override
|
||||||
|
{
|
||||||
|
return y_p[i];
|
||||||
|
};
|
||||||
|
double
|
||||||
|
jacobian(size_t i) const override
|
||||||
|
{
|
||||||
|
return jacobian_p[i];
|
||||||
|
};
|
||||||
void eval(int it, double *resid) override;
|
void eval(int it, double *resid) override;
|
||||||
static void load_dll(const std::string &basename);
|
static void load_dll(const std::string &basename);
|
||||||
static void unload_dll();
|
static void unload_dll();
|
||||||
|
@ -85,13 +95,23 @@ private:
|
||||||
public:
|
public:
|
||||||
DynamicModelMatlabCaller(std::string basename_arg, size_t ntt, size_t ndynvars, const mxArray *x_mx_arg, const mxArray *params_mx_arg, const mxArray *steady_state_mx_arg, bool linear_arg, bool compute_jacobian_arg);
|
DynamicModelMatlabCaller(std::string basename_arg, size_t ntt, size_t ndynvars, const mxArray *x_mx_arg, const mxArray *params_mx_arg, const mxArray *steady_state_mx_arg, bool linear_arg, bool compute_jacobian_arg);
|
||||||
~DynamicModelMatlabCaller() override;
|
~DynamicModelMatlabCaller() override;
|
||||||
double &y(size_t i) const override { return mxGetPr(y_mx)[i]; };
|
double &
|
||||||
double jacobian(size_t i) const override { return jacobian_mx ? mxGetPr(jacobian_mx)[i] : std::numeric_limits<double>::quiet_NaN(); };
|
y(size_t i) const override
|
||||||
|
{
|
||||||
|
return mxGetPr(y_mx)[i];
|
||||||
|
};
|
||||||
|
double
|
||||||
|
jacobian(size_t i) const override
|
||||||
|
{
|
||||||
|
return jacobian_mx ? mxGetPr(jacobian_mx)[i] : std::numeric_limits<double>::quiet_NaN();
|
||||||
|
};
|
||||||
void eval(int it, double *resid) override;
|
void eval(int it, double *resid) override;
|
||||||
class Exception {
|
class Exception
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
const std::string msg;
|
const std::string msg;
|
||||||
Exception(std::string msg_arg) : msg{std::move(msg_arg)} {};
|
Exception(std::string msg_arg) : msg{std::move(msg_arg)}
|
||||||
|
{
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -148,15 +148,15 @@ usphere(int d, int n, T *U)
|
||||||
{
|
{
|
||||||
icdfm(n*d, U);
|
icdfm(n*d, U);
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for (int j = 0; j < n; j++)// sequence index.
|
for (int j = 0; j < n; j++) // sequence index.
|
||||||
{
|
{
|
||||||
int k = j*d;
|
int k = j*d;
|
||||||
double norm = 0.0;
|
double norm = 0.0;
|
||||||
for (int i = 0; i < d; i++)// dimension index.
|
for (int i = 0; i < d; i++) // dimension index.
|
||||||
norm = norm + U[k+i]*U[k+i];
|
norm = norm + U[k+i]*U[k+i];
|
||||||
|
|
||||||
norm = sqrt(norm);
|
norm = sqrt(norm);
|
||||||
for (int i = 0; i < d; i++)// dimension index.
|
for (int i = 0; i < d; i++) // dimension index.
|
||||||
U[k+i] = U[k+i]/norm;
|
U[k+i] = U[k+i]/norm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,15 +167,15 @@ usphereRadius(int d, int n, double radius, T *U)
|
||||||
{
|
{
|
||||||
icdfm(n*d, U);
|
icdfm(n*d, U);
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for (int j = 0; j < n; j++)// sequence index.
|
for (int j = 0; j < n; j++) // sequence index.
|
||||||
{
|
{
|
||||||
int k = j*d;
|
int k = j*d;
|
||||||
double norm = 0.0;
|
double norm = 0.0;
|
||||||
for (int i = 0; i < d; i++)// dimension index.
|
for (int i = 0; i < d; i++) // dimension index.
|
||||||
norm = norm + U[k+i]*U[k+i];
|
norm = norm + U[k+i]*U[k+i];
|
||||||
|
|
||||||
norm = sqrt(norm);
|
norm = sqrt(norm);
|
||||||
for (int i = 0; i < d; i++)// dimension index.
|
for (int i = 0; i < d; i++) // dimension index.
|
||||||
U[k+i] = radius*U[k+i]/norm;
|
U[k+i] = radius*U[k+i]/norm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue