45 const std::string& _commonHeaderName
130 for( run1 =
dim; run1 > 0; run1--) {
131 for( run2 =
dim-1; run2 > (run1-1); run2--) {
134 _solveTriangular <<
"b[" <<
toString( (run1-1) ) <<
"] = b[" <<
toString( (run1-1) ) <<
"]/A[" <<
toString( (run1-1)*
dim+(run1-1) ) <<
"];\n";
143 uint run1, run2, run3;
174 for( run1 = 0; run1 < (
dim-1); run1++ ) {
176 for( run2 = run1+1; run2 <
dim; run2++ ) {
179 if( run2 == (run1+1) ) {
184 test << absF <<
"(A[" <<
toString( run2*dim+run1 ) <<
"]) > " << absF <<
"(A[" <<
toString( run1*dim+run1 ) <<
"])";
185 for( run3 = run1+1; run3 <
dim; run3++ ) {
187 test <<
" && " << absF <<
"(A[" <<
toString( run2*dim+run1 ) <<
"]) > " << absF <<
"(A[" <<
toString( run3*dim+run1 ) <<
"])";
195 for( run3 = 0; run3 <
dim; run3++ ) {
216 for( run2 = run1+1; run2 <
dim; run2++ ) {
217 _solve <<
"A[" <<
toString( run2*dim+run1 ) <<
"] = -A[" <<
toString( run2*dim+run1 ) <<
"]/A[" <<
toString( run1*dim+run1 ) <<
"];\n";
229 _solve <<
"for( i=0; i < (" <<
toString(
dim-1 ) <<
"); i++ ) {\n";
230 _solve <<
" indexMax = i;\n";
231 _solve <<
" valueMax = " << absF <<
"(A[i*" <<
toString(
dim ) <<
"+i]);\n";
232 _solve <<
" for( j=(i+1); j < " <<
toString(
dim ) <<
"; j++ ) {\n";
233 _solve <<
" temp = " << absF <<
"(A[j*" <<
toString(
dim ) <<
"+i]);\n";
234 _solve <<
" if( temp > valueMax ) {\n";
235 _solve <<
" indexMax = j;\n";
236 _solve <<
" valueMax = temp;\n";
239 _solve <<
" if( indexMax > i ) {\n";
245 _solve <<
" " << _swap.
getFullName() <<
" = b[i];\n";
246 _solve <<
" b[i] = b[indexMax];\n";
247 _solve <<
" b[indexMax] = " << _swap.
getFullName() <<
";\n";
255 _solve <<
" for( j=i+1; j < " <<
toString(
dim ) <<
"; j++ ) {\n";
257 _solve <<
" for( k=i+1; k < " <<
toString(
dim ) <<
"; k++ ) {\n";
260 _solve <<
" b[j] += A[j*" <<
toString(
dim ) <<
"+i] * b[i];\n";
275 uint run1, run2, run3;
303 for( run1 = 0; run1 < (
dim-1); run1++ ) {
305 for( run2 = run1+1; run2 <
dim; run2++ ) {
308 if( run2 == (run1+1) ) {
313 test << absF <<
"(A[" <<
toString( run2*dim+run1 ) <<
"]) > " << absF <<
"(A[" <<
toString( run1*dim+run1 ) <<
"])";
314 for( run3 = run1+1; run3 <
dim; run3++ ) {
316 test <<
" && " << absF <<
"(A[" <<
toString( run2*dim+run1 ) <<
"]) > " << absF <<
"(A[" <<
toString( run3*dim+run1 ) <<
"])";
324 for( run3 = 0; run3 <
dim; run3++ ) {
341 for( run2 = run1+1; run2 <
dim; run2++ ) {
342 _solve <<
"A[" <<
toString( run2*dim+run1 ) <<
"] = -A[" <<
toString( run2*dim+run1 ) <<
"]/A[" <<
toString( run1*dim+run1 ) <<
"];\n";
353 _solve <<
"for( i=0; i < (" <<
toString(
dim-1 ) <<
"); i++ ) {\n";
354 _solve <<
" indexMax = i;\n";
355 _solve <<
" valueMax = " << absF <<
"(A[i*" <<
toString(
dim ) <<
"+i]);\n";
356 _solve <<
" for( j=(i+1); j < " <<
toString(
dim ) <<
"; j++ ) {\n";
357 _solve <<
" temp = " << absF <<
"(A[j*" <<
toString(
dim ) <<
"+i]);\n";
358 _solve <<
" if( temp > valueMax ) {\n";
359 _solve <<
" indexMax = j;\n";
360 _solve <<
" valueMax = temp;\n";
363 _solve <<
" if( indexMax > i ) {\n";
376 _solve <<
" for( j=i+1; j < " <<
toString(
dim ) <<
"; j++ ) {\n";
378 _solve <<
" for( k=i+1; k < " <<
toString(
dim ) <<
"; k++ ) {\n";
398 for( run1 = 0; run1 <
dim; run1++ ) {
402 for( run2 = 1; run2 <
dim; run2++ ) {
403 for( run1 = 0; run1 < run2; run1++ ) {
404 _solveReuse << _bPerm.
get( run2,0 ) <<
" += A[" <<
toString( run2*dim+run1 ) <<
"]*" << _bPerm.
getFullName() <<
"[" <<
toString( run1 ) <<
"];\n";
437 loop1 << _bPerm.
get( run1,run3 ) <<
" = b[" << run2.
getName() <<
"+" <<
toString(run3) <<
"];\n";
442 loop2.
addStatement( tmp_index1 == run2*nRightHandSides );
444 loop3.
addStatement( tmp_index2 == run1*nRightHandSides );
456 loop4.
addStatement( tmp_index1 == run1*nRightHandSides );
458 loop5.
addStatement( tmp_index2 == run2*nRightHandSides );
465 loop4 << tmp.getName() <<
" = 1.0/A[" << run1.
getName() <<
"*" <<
toString(
dim+1) <<
"];\n";
493 loop2 << tmp.getName() <<
" = 1.0/A[" << run2.
getName() <<
"*" <<
toString(
dim+1) <<
"];\n";
ExportVariable getRow(const ExportIndex &idx) const
const std::string getNameSolveTransposeReuseFunction()
ExportFunction solveReuseTranspose
UserInteraction * userInteraction
virtual returnValue setup()
returnValue get(OptionsName name, int &value) const
virtual ~ExportGaussElim()
Allows to pass back messages to the calling function.
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
virtual returnValue setupSolveReuseTranspose(ExportFunction &_solveReuse, ExportVariable &_bPerm)
Allows to export code of a for-loop.
string toString(T const &value)
virtual returnValue setupSolveReuseComplete(ExportFunction &_solveReuse, ExportVariable &_bPerm)
ExportVariable getElement(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
#define CLOSE_NAMESPACE_ACADO
ExportVariable getSubMatrix(const ExportIndex &rowIdx1, const ExportIndex &rowIdx2, const ExportIndex &colIdx1, const ExportIndex &colIdx2) const
virtual returnValue getCode(ExportStatementBlock &code)
Defines a scalar-valued index variable to be used for exporting code.
ExportVariable determinant
ExportFunction solveTriangular
returnValue appendVariableNames(std::stringstream &string)
const std::string getNameSolveReuseFunction()
const std::string get(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
Encapsulates all user interaction for setting options, logging data and plotting results.
Allows to export code of an arbitrary function.
returnValue addStatement(const ExportStatement &_statement)
ExportFunction solveReuse
std::string getFullName() const
returnValue addLinebreak(uint num=1)
ExportFunction & setReturnValue(const ExportVariable &_functionReturnValue, bool _returnAsPointer=false)
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
virtual returnValue setupSolveUpperTriangular(ExportFunction &_solveTriangular)
returnValue addDeclaration(const ExportVariable &_data, ExportStruct _dataStruct=ACADO_ANY)
virtual returnValue setupSolve(ExportFunction &_solve, ExportFunction &_solveTriangular, ExportVariable &_swap, ExportVariable &_determinant, const std::string &absF)
ExportGaussElim(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
const std::string getNameSolveFunction()
#define BEGIN_NAMESPACE_ACADO
returnValue addFunction(const ExportFunction &_function)
virtual returnValue setupSolveReuse(ExportFunction &_solveReuse, ExportFunction &_solveTriangular, ExportVariable &_bPerm)
Allows to export automatically generated algorithms for solving linear systems of specific dimensions...
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
ExportType getType() const
Allows to export code for a block of statements.
virtual ExportVariable getGlobalExportVariable(const uint factor) const
ExportVariable rk_bPerm_trans
ExportVariable getCol(const ExportIndex &idx) const
ExportFunction & addIndex(const ExportIndex &_index)
#define ACADOERROR(retval)
Defines a matrix-valued variable to be used for exporting code.
returnValue addFunctionCall(const std::string &_fName, const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
std::string getName() const
virtual returnValue setupFactorization(ExportFunction &_solve, ExportVariable &_swap, ExportVariable &_determinant, const std::string &absF)