diff --git a/DynamicModel.cc b/DynamicModel.cc index 5ea7aa8a..144f97e3 100644 --- a/DynamicModel.cc +++ b/DynamicModel.cc @@ -2373,7 +2373,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia << hessian_output.str() << " g2 = sparse(v2(:,1),v2(:,2),v2(:,3)," << nrows << "," << hessianColsNbr << ");" << endl; else // Either hessian is all zero, or we didn't compute it - DynamicOutput << " g2 = sparse([],[],[]," << nrows << "," << hessianColsNbr << ");" << endl; + DynamicOutput << " g2 = spzeros(" << nrows << "," << hessianColsNbr << ")" << endl; // Initialize g3 matrix DynamicOutput << "end" << endl << endl @@ -2393,7 +2393,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia << third_derivatives_output.str() << " g3 = sparse(v3(:,1),v3(:,2),v3(:,3)," << nrows << "," << ncols << ");" << endl; else // Either 3rd derivatives is all zero, or we didn't compute it - DynamicOutput << " g3 = sparse([],[],[]," << nrows << "," << ncols << ");" << endl; + DynamicOutput << " g3 = spzeros(" << nrows << "," << ncols << ")" << endl; DynamicOutput << "end" << endl; } } diff --git a/StaticModel.cc b/StaticModel.cc index a369d7e3..dcfa9c3b 100644 --- a/StaticModel.cc +++ b/StaticModel.cc @@ -1449,7 +1449,7 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c << " g2 = sparse(v2(:,1),v2(:,2),v2(:,3)," << equations.size() << "," << g2ncols << ");" << endl; else - StaticOutput << " g2 = sparse([],[],[]," << equations.size() << "," << g2ncols << ");" << endl; + StaticOutput << " g2 = spzeros(" << equations.size() << "," << g2ncols << ")" << endl; // Initialize g3 matrix StaticOutput << "end" << endl << endl @@ -1471,7 +1471,7 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c << " g3 = sparse(v3(:,1),v3(:,2),v3(:,3)," << nrows << "," << ncols << ");" << endl; else // Either 3rd derivatives is all zero, or we didn't compute it - StaticOutput << " g3 = sparse([],[],[]," << nrows << "," << ncols << ");" << endl; + StaticOutput << " g3 = spzeros(" << nrows << "," << ncols << ")" << endl; StaticOutput << "end" << endl; } }