replace empty sparse calls with spzeros

issue#70
Houtan Bastani 2015-08-19 17:12:06 +02:00
parent 22f409af4f
commit a10efd7c4b
2 changed files with 4 additions and 4 deletions

View File

@ -2373,7 +2373,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
<< hessian_output.str() << hessian_output.str()
<< " g2 = sparse(v2(:,1),v2(:,2),v2(:,3)," << nrows << "," << hessianColsNbr << ");" << endl; << " g2 = sparse(v2(:,1),v2(:,2),v2(:,3)," << nrows << "," << hessianColsNbr << ");" << endl;
else // Either hessian is all zero, or we didn't compute it 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 // Initialize g3 matrix
DynamicOutput << "end" << endl << endl DynamicOutput << "end" << endl << endl
@ -2393,7 +2393,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
<< third_derivatives_output.str() << third_derivatives_output.str()
<< " g3 = sparse(v3(:,1),v3(:,2),v3(:,3)," << nrows << "," << ncols << ");" << endl; << " g3 = sparse(v3(:,1),v3(:,2),v3(:,3)," << nrows << "," << ncols << ");" << endl;
else // Either 3rd derivatives is all zero, or we didn't compute it 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; DynamicOutput << "end" << endl;
} }
} }

View File

@ -1449,7 +1449,7 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c
<< " g2 = sparse(v2(:,1),v2(:,2),v2(:,3)," << equations.size() << "," << " g2 = sparse(v2(:,1),v2(:,2),v2(:,3)," << equations.size() << ","
<< g2ncols << ");" << endl; << g2ncols << ");" << endl;
else else
StaticOutput << " g2 = sparse([],[],[]," << equations.size() << "," << g2ncols << ");" << endl; StaticOutput << " g2 = spzeros(" << equations.size() << "," << g2ncols << ")" << endl;
// Initialize g3 matrix // Initialize g3 matrix
StaticOutput << "end" << endl << endl 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 << ");" << " g3 = sparse(v3(:,1),v3(:,2),v3(:,3)," << nrows << "," << ncols << ");"
<< endl; << endl;
else // Either 3rd derivatives is all zero, or we didn't compute it 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; StaticOutput << "end" << endl;
} }
} }