示例#1
0
returnValue ThreeSweepsERKExport::getCode(	ExportStatementBlock& code
											)
{
	int useOMP;
	get(CG_USE_OPENMP, useOMP);
	if ( useOMP )
	{
		getDataDeclarations( code, ACADO_LOCAL );

		code << "#pragma omp threadprivate( "
				<< getAuxVariable().getFullName()  << ", "
				<< rk_xxx.getFullName() << ", "
				<< rk_ttt.getFullName() << ", "
				<< rk_kkk.getFullName() << ", "
				<< rk_forward_sweep.getFullName() << ", "
				<< rk_backward_sweep.getFullName()
				<< " )\n\n";
	}

	int sensGen;
	get( DYNAMIC_SENSITIVITY,sensGen );
	if( exportRhs ) {
		code.addFunction( rhs );
		code.addFunction( diffs_rhs );
		code.addFunction( diffs_sweep3 );
	}

	double h = (grid.getLastTime() - grid.getFirstTime())/grid.getNumIntervals();
	code.addComment(std::string("Fixed step size:") + toString(h));
	code.addFunction( integrate );

	return SUCCESSFUL_RETURN;
}
returnValue ExportCholeskySolver::getCode( ExportStatementBlock& code )
{
	code.addFunction( chol );
	code.addFunction( solve );

	return SUCCESSFUL_RETURN;
}
returnValue ExportCholeskySolver::getFunctionDeclarations(	ExportStatementBlock& declarations
															) const
{
	declarations.addDeclaration( chol );
	declarations.addDeclaration( solve );

	return SUCCESSFUL_RETURN;
}
示例#4
0
returnValue ExplicitRungeKuttaExport::getFunctionDeclarations(	ExportStatementBlock& declarations
                                                             ) const
{
    declarations.addDeclaration( integrate );

    declarations.addDeclaration( rhs );
    declarations.addDeclaration( diffs_rhs );

    return SUCCESSFUL_RETURN;
}
示例#5
0
returnValue DiscreteTimeExport::getFunctionDeclarations(	ExportStatementBlock& declarations
														) const
{
	declarations.addDeclaration( integrate );

	if( NX2 != NX ) 	declarations.addDeclaration( fullRhs );
	else				declarations.addDeclaration( rhs );

	return SUCCESSFUL_RETURN;
}
returnValue ExportGaussElim::getFunctionDeclarations(	ExportStatementBlock& declarations
															) const
{
	declarations.addDeclaration( solve );
	declarations.addDeclaration( solveTriangular );
	if( REUSE ) {
		declarations.addDeclaration( solveReuse );
	}

	return SUCCESSFUL_RETURN;
}
returnValue ExportGaussNewtonBlockForces::getCode(	ExportStatementBlock& code
											)
{
	setupQPInterface();
	code.addStatement( *qpInterface );

	code.addFunction( cleanup );
	code.addFunction( shiftQpData );

	code.addFunction( evaluateConstraints );
	code.addFunction( evaluateAffineConstraints );

	return ExportGaussNewtonCN2::getCode( code );
}
returnValue ExportGaussElim::getDataDeclarations(	ExportStatementBlock& declarations,
														ExportStruct dataStruct
														) const
{
	declarations.addDeclaration( rk_swap,dataStruct );			// needed for the row swaps
	if( REUSE ) {
		declarations.addDeclaration( rk_bPerm,dataStruct );		// reordered right-hand side
		if( TRANSPOSE ) {
			declarations.addDeclaration( rk_bPerm_trans,dataStruct );
		}
	}

	return SUCCESSFUL_RETURN;
}
示例#9
0
returnValue ExplicitRungeKuttaExport::getDataDeclarations(	ExportStatementBlock& declarations,
        ExportStruct dataStruct
                                                         ) const
{
    if( exportRhs ) {
        declarations.addDeclaration( getAuxVariable(),dataStruct );
    }
    declarations.addDeclaration( rk_ttt,dataStruct );
    declarations.addDeclaration( rk_xxx,dataStruct );
    declarations.addDeclaration( rk_kkk,dataStruct );

//	declarations.addDeclaration( reset_int,dataStruct );

    return SUCCESSFUL_RETURN;
}
returnValue ExportGaussNewtonForces::getDataDeclarations(	ExportStatementBlock& declarations,
															ExportStruct dataStruct
															) const
{
	returnValue status;
	status = ExportNLPSolver::getDataDeclarations(declarations, dataStruct);
	if (status != SUCCESSFUL_RETURN)
		return status;

	declarations.addDeclaration(x0, dataStruct);

	declarations.addDeclaration(lbValues, dataStruct);
	declarations.addDeclaration(ubValues, dataStruct);

	return SUCCESSFUL_RETURN;
}
returnValue ExportIRK4StageSimplifiedNewton::getFunctionDeclarations(	ExportStatementBlock& declarations
                                                                    ) const
{
    ExportGaussElim::getFunctionDeclarations( declarations );

    declarations.addDeclaration( solve_complex );
    if( REUSE ) {
        declarations.addDeclaration( solveReuse_complex );
    }

    declarations.addDeclaration( solve_full );
    if( REUSE ) {
        declarations.addDeclaration( solveReuse_full );
    }

    return SUCCESSFUL_RETURN;
}
returnValue ExportCholeskyDecomposition::getCode(	ExportStatementBlock& code
													)
{
	if (A.getDim() != 0)
		return code.addFunction( fcn );

	return SUCCESSFUL_RETURN;
}
returnValue ExportCholeskyDecomposition::getFunctionDeclarations(	ExportStatementBlock& declarations
																	) const
{
	if (A.getDim() != 0)
		return declarations.addFunction( fcn );

	return SUCCESSFUL_RETURN;
}
示例#14
0
returnValue DiscreteTimeExport::getDataDeclarations(	ExportStatementBlock& declarations,
														ExportStruct dataStruct
													) const
{
	ExportVariable max = getAuxVariable();
	declarations.addDeclaration( max,dataStruct );
	declarations.addDeclaration( rk_xxx,dataStruct );
	declarations.addDeclaration( reset_int,dataStruct );

	declarations.addDeclaration( rk_diffsPrev1,dataStruct );
	declarations.addDeclaration( rk_diffsPrev2,dataStruct );

	declarations.addDeclaration( rk_diffsNew1,dataStruct );
	declarations.addDeclaration( rk_diffsNew2,dataStruct );

	return SUCCESSFUL_RETURN;
}
示例#15
0
returnValue DiscreteTimeExport::getFunctionDeclarations(	ExportStatementBlock& declarations
														) const
{
	declarations.addDeclaration( integrate );
	if( NX2 != NX ) declarations.addDeclaration( fullRhs );

	if( exportRhs ) {
		if( NX1 > 0 ) {
			declarations.addDeclaration( lin_input );
		}
		if( NX2 > 0 ) {
			declarations.addDeclaration( rhs );
			declarations.addDeclaration( diffs_rhs );
		}
	}
	else {
		Function tmpFun;
		tmpFun << zeros(1,1);
		ExportODEfunction tmpExport(tmpFun, getNameRHS());
		declarations.addDeclaration( tmpExport );
		tmpExport = ExportODEfunction(tmpFun, getNameDiffsRHS());
		declarations.addDeclaration( tmpExport );
	}

	return SUCCESSFUL_RETURN;
}
示例#16
0
returnValue LiftedERKExport::getCode(	ExportStatementBlock& code
										)
{
	// 	int printLevel;
	// 	get( PRINTLEVEL,printLevel );
	//
	// 	if ( (PrintLevel)printLevel >= HIGH )
	// 		acadoPrintf( "--> Exporting %s... ",fileName.getName() );

	int useOMP;
	get(CG_USE_OPENMP, useOMP);
	if ( useOMP )
	{
		getDataDeclarations( code, ACADO_LOCAL );

		code << "#pragma omp threadprivate( "
				<< getAuxVariable().getFullName()  << ", "
				<< rk_xxx.getFullName() << ", "
				<< rk_ttt.getFullName() << ", "
				<< rk_kkk.getFullName()
				<< " )\n\n";
	}

	int sensGen;
	get( DYNAMIC_SENSITIVITY,sensGen );
	if( exportRhs ) {
		code.addFunction( rhs );
		code.addFunction( diffs_rhs );
		code.addFunction( alg_rhs );
		solver->getCode( code ); // solver for the algebraic equations
	}
	else {
		return ACADOERRORTEXT( RET_NOT_YET_IMPLEMENTED, "Externally defined dynamics not yet supported for the lifted ERK integrator!");
	}

	double h = (grid.getLastTime() - grid.getFirstTime())/grid.getNumIntervals();
	code.addComment(std::string("Fixed step size:") + toString(h));
	code.addFunction( integrate );


	// 	if ( (PrintLevel)printLevel >= HIGH )
	// 		acadoPrintf( "done.\n" );

	return SUCCESSFUL_RETURN;
}
示例#17
0
returnValue ExportGaussNewtonCN2::getFunctionDeclarations(	ExportStatementBlock& declarations
															) const
{
	declarations.addDeclaration( preparation );
	declarations.addDeclaration( feedback );

	declarations.addDeclaration( initialize );
	declarations.addDeclaration( initializeNodes );
	declarations.addDeclaration( shiftStates );
	declarations.addDeclaration( shiftControls );
	declarations.addDeclaration( getKKT );
	declarations.addDeclaration( getObjective );

	declarations.addDeclaration( evaluateLSQ );
	declarations.addDeclaration( evaluateLSQEndTerm );

	return SUCCESSFUL_RETURN;
}
returnValue ExportIRK4StageSimplifiedNewton::getDataDeclarations(	ExportStatementBlock& declarations,
        ExportStruct dataStruct
                                                                ) const
{
    ExportGaussElim::getDataDeclarations( declarations, dataStruct );

    declarations.addDeclaration( rk_swap_complex,dataStruct );			// needed for the row swaps
    if( REUSE ) {
        declarations.addDeclaration( rk_bPerm_complex,dataStruct );		// reordered right-hand side
    }
    declarations.addDeclaration( A_mem_complex1,dataStruct );
    declarations.addDeclaration( b_mem_complex1,dataStruct );

    declarations.addDeclaration( A_mem_complex2,dataStruct );
    declarations.addDeclaration( b_mem_complex2,dataStruct );

    return SUCCESSFUL_RETURN;
}
示例#19
0
returnValue ExportExactHessianCN2::getFunctionDeclarations(	ExportStatementBlock& declarations
															) const
{
	ExportGaussNewtonCN2::getFunctionDeclarations( declarations );

	declarations.addDeclaration( regularization );

	return SUCCESSFUL_RETURN;
}
示例#20
0
returnValue ThreeSweepsERKExport::getDataDeclarations(	ExportStatementBlock& declarations,
														ExportStruct dataStruct
														) const
{
	AdjointERKExport::getDataDeclarations( declarations, dataStruct );

	declarations.addDeclaration( rk_backward_sweep,dataStruct );

    return SUCCESSFUL_RETURN;
}
示例#21
0
returnValue ExplicitRungeKuttaExport::getCode(	ExportStatementBlock& code
                                             )
{
// 	int printLevel;
// 	get( PRINTLEVEL,printLevel );
//
// 	if ( (PrintLevel)printLevel >= HIGH )
// 		acadoPrintf( "--> Exporting %s... ",fileName.getName() );

    int useOMP;
    get(CG_USE_OPENMP, useOMP);
    if ( useOMP )
    {
        getDataDeclarations( code, ACADO_LOCAL );

        code << "#pragma omp threadprivate( "
             << getAuxVariable().getFullName()  << ", "
             << rk_xxx.getFullName() << ", "
             << rk_ttt.getFullName() << ", "
             << rk_kkk.getFullName()
             << " )\n\n";
    }

    int sensGen;
    get( DYNAMIC_SENSITIVITY,sensGen );
    if( exportRhs ) {
        code.addFunction( rhs );
        code.addFunction( diffs_rhs );
    }

    double h = (grid.getLastTime() - grid.getFirstTime())/grid.getNumIntervals();
    code.addComment(std::string("Fixed step size:") + toString(h));
    code.addFunction( integrate );


// 	if ( (PrintLevel)printLevel >= HIGH )
// 		acadoPrintf( "done.\n" );

    return SUCCESSFUL_RETURN;
}
returnValue ExportIRK4StageSimplifiedNewton::transformRightHandSide(	ExportStatementBlock& code, const ExportIndex& index )
{
    uint i, j;

    ExportVariable transf1_var( transf1 );
    ExportVariable stepSizeV( 1.0/stepsize );

    ExportForLoop loop1( index, 0, dim );
    for( j = 0; j < nRightHandSides; j++ ) {
        loop1.addStatement( b_mem_complex1.getElement(index,j) == 0.0 );
        for( i = 0; i < 4; i++ ) {
            loop1.addStatement( b_mem_complex1.getElement(index,j) += transf1_var.getElement(0,i)*b_full.getElement(index+i*dim,j) );
        }
        stringstream ss1;
        ss1 << b_mem_complex1.get(index,j) << " += (";
        for( i = 0; i < 4; i++ ) {
            if( i > 0 ) ss1 << " + ";
            ss1 << transf1_var.get(1,i) << "*" << b_full.get(index+i*dim,j);
        }
        ss1 << ")*I;\n";
        ss1 << b_mem_complex1.get(index,j) << " *= " << stepSizeV.get(0,0) << ";\n";
        loop1 << ss1.str();


        loop1.addStatement( b_mem_complex2.getElement(index,j) == 0.0 );
        for( i = 0; i < 4; i++ ) {
            loop1.addStatement( b_mem_complex2.getElement(index,j) += transf1_var.getElement(2,i)*b_full.getElement(index+i*dim,j) );
        }
        stringstream ss2;
        ss2 << b_mem_complex2.get(index,j) << " += (";
        for( i = 0; i < 4; i++ ) {
            if( i > 0 ) ss2 << " + ";
            ss2 << transf1_var.get(3,i) << "*" << b_full.get(index+i*dim,j);
        }
        ss2 << ")*I;\n";
        ss2 << b_mem_complex2.get(index,j) << " *= " << stepSizeV.get(0,0) << ";\n";
        loop1 << ss2.str();
    }
    code.addStatement( loop1 );

    return SUCCESSFUL_RETURN;
}
returnValue AuxiliaryFunctionsExport::getFunctionDeclarations(	ExportStatementBlock& declarations
																) const
{
	declarations.addDeclaration( getAcadoVariablesX );
	declarations.addDeclaration( getAcadoVariablesU );
	declarations.addDeclaration( getAcadoVariablesXRef );
	declarations.addDeclaration( getAcadoVariablesURef );

	declarations.addDeclaration( printStates );
	declarations.addDeclaration( printControls );
	declarations.addDeclaration( getTime );
	declarations.addDeclaration( printHeader );

    return SUCCESSFUL_RETURN;
}
returnValue ExportIRK4StageSimplifiedNewton::transformSolution(	ExportStatementBlock& code, const ExportIndex& index )
{
    uint j;
    ExportVariable transf2_var( transf2 );

    ExportForLoop loop1( index, 0, dim );
    for( j = 0; j < nRightHandSides; j++ ) {
        stringstream ss;
        ss << b_full.get(index,j) << " = ";
        ss << transf2_var.get(0,0) << "*creal(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(0,1) << "*cimag(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(0,2) << "*creal(" << b_mem_complex2.get(index,j) << ") + ";
        ss << transf2_var.get(0,3) << "*cimag(" << b_mem_complex2.get(index,j) << ");\n";

        ss << b_full.get(index+dim,j) << " = ";
        ss << transf2_var.get(1,0) << "*creal(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(1,1) << "*cimag(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(1,2) << "*creal(" << b_mem_complex2.get(index,j) << ") + ";
        ss << transf2_var.get(1,3) << "*cimag(" << b_mem_complex2.get(index,j) << ");\n";

        ss << b_full.get(index+2*dim,j) << " = ";
        ss << transf2_var.get(2,0) << "*creal(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(2,1) << "*cimag(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(2,2) << "*creal(" << b_mem_complex2.get(index,j) << ") + ";
        ss << transf2_var.get(2,3) << "*cimag(" << b_mem_complex2.get(index,j) << ");\n";

        ss << b_full.get(index+3*dim,j) << " = ";
        ss << transf2_var.get(3,0) << "*creal(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(3,1) << "*cimag(" << b_mem_complex1.get(index,j) << ") + ";
        ss << transf2_var.get(3,2) << "*creal(" << b_mem_complex2.get(index,j) << ") + ";
        ss << transf2_var.get(3,3) << "*cimag(" << b_mem_complex2.get(index,j) << ");\n";
        loop1 << ss.str();
    }
    code.addStatement( loop1 );

    return SUCCESSFUL_RETURN;
}
returnValue ExportGaussElim::getCode(	ExportStatementBlock& code
											)
{

	if (nRightHandSides > 0) {
		if( !REUSE ) return ACADOERROR(RET_INVALID_OPTION);

		setupFactorization( solve, rk_swap, determinant, string("fabs") );
		code.addFunction( solve );

		setupSolveReuseComplete( solveReuse, rk_bPerm );
		code.addFunction( solveReuse );

		if( TRANSPOSE ) {
			setupSolveReuseTranspose( solveReuseTranspose, rk_bPerm_trans );
			code.addFunction( solveReuseTranspose );
		}
	}
	else {
		setupSolveUpperTriangular( solveTriangular );
		code.addFunction( solveTriangular );

		setupSolve( solve, solveTriangular, rk_swap, determinant, string("fabs") );
		code.addFunction( solve );

		if( REUSE ) { // Also export the extra function which reuses the factorization of the matrix A

			setupSolveReuse( solveReuse, solveTriangular, rk_bPerm );
			code.addFunction( solveReuse );
		}
//		if( TRANSPOSE ) return ACADOERROR( RET_NOT_YET_IMPLEMENTED );
		if( TRANSPOSE ) {
			setupSolveReuseTranspose( solveReuseTranspose, rk_bPerm_trans );
			code.addFunction( solveReuseTranspose );
		}
	}

	return SUCCESSFUL_RETURN;
}
示例#26
0
returnValue LiftedERKExport::getDataDeclarations(	ExportStatementBlock& declarations,
													ExportStruct dataStruct
													) const
{
	ExplicitRungeKuttaExport::getDataDeclarations( declarations, dataStruct );

	solver->getDataDeclarations( declarations,dataStruct );

	declarations.addDeclaration( rk_A,dataStruct );
	declarations.addDeclaration( rk_b,dataStruct );
	declarations.addDeclaration( rk_auxSolver,dataStruct );

	declarations.addDeclaration( rk_zzz,dataStruct );
	declarations.addDeclaration( rk_zTemp,dataStruct );

	declarations.addDeclaration( rk_diffZ,dataStruct );
	declarations.addDeclaration( rk_delta,dataStruct );
	declarations.addDeclaration( rk_prev,dataStruct );

    return SUCCESSFUL_RETURN;
}
returnValue AuxiliaryFunctionsExport::getCode(	ExportStatementBlock& code
												)
{
// 	int printLevel;
// 	get( PRINTLEVEL,printLevel );
// 
// 	if ( (PrintLevel)printLevel >= HIGH ) 
// 		acadoPrintf( "--> Exporting %s... ",fileName.getName() );

	code.addFunction( getAcadoVariablesX );
	code.addFunction( getAcadoVariablesU );
	code.addFunction( getAcadoVariablesXRef );
	code.addFunction( getAcadoVariablesURef );
	
	code.addFunction( printStates );
	code.addFunction( printControls );
	code.addFunction( getTime );
	code.addFunction( printHeader );

// 	if ( (PrintLevel)printLevel >= HIGH ) 
// 		acadoPrintf( "done.\n" );

	return SUCCESSFUL_RETURN;
}
示例#28
0
returnValue ExportGaussNewtonCN2::getCode(	ExportStatementBlock& code
											)
{
	setupQPInterface();

	code.addLinebreak( 2 );
	code.addStatement( "/******************************************************************************/\n" );
	code.addStatement( "/*                                                                            */\n" );
	code.addStatement( "/* ACADO code generation                                                      */\n" );
	code.addStatement( "/*                                                                            */\n" );
	code.addStatement( "/******************************************************************************/\n" );
	code.addLinebreak( 2 );

	int useOMP;
	get(CG_USE_OPENMP, useOMP);
	if ( useOMP )
	{
		code.addDeclaration( state );
	}

	code.addFunction( modelSimulation );

	code.addFunction( evaluateLSQ );
	code.addFunction( evaluateLSQEndTerm );

	code.addFunction( setObjQ1Q2 );
	code.addFunction( setObjR1R2 );
	code.addFunction( setObjS1 );
	code.addFunction( setObjQN1QN2 );
	code.addFunction( evaluateObjective );

	code.addFunction( multGxGu );
	code.addFunction( moveGuE );

	code.addFunction( multBTW1 );
	code.addFunction( mac_S1T_E );
	code.addFunction( macBTW1_R1 );
	code.addFunction( multGxTGu );
	code.addFunction( macQEW2 );

	code.addFunction( macATw1QDy );
	code.addFunction( macBTw1 );
	code.addFunction( macS1TSbar );
	code.addFunction( macQSbarW2 );
	code.addFunction( macASbar );
	code.addFunction( expansionStep );

	code.addFunction( copyHTH );

	code.addFunction( multRDy );
	code.addFunction( multQDy );

	code.addFunction( multQN1Gu );

	code.addFunction( evaluatePathConstraints );

	for (unsigned i = 0; i < evaluatePointConstraints.size(); ++i)
	{
		if (evaluatePointConstraints[ i ] == 0)
			continue;
		code.addFunction( *evaluatePointConstraints[ i ] );
	}

	code.addFunction( condensePrep );
	code.addFunction( condenseFdb );
	code.addFunction( expand );

	code.addFunction( preparation );
	code.addFunction( feedback );

	code.addFunction( initialize );
	code.addFunction( initializeNodes );
	code.addFunction( shiftStates );
	code.addFunction( shiftControls );
	code.addFunction( getKKT );
	code.addFunction( getObjective );

	return SUCCESSFUL_RETURN;
}
returnValue ExportIRK4StageSimplifiedNewton::getCode(	ExportStatementBlock& code
                                                    )
{
    if( eig.isEmpty() || transf1.isEmpty() || transf2.isEmpty() || fabs(stepsize) <= ZERO_EPS ) return ACADOERROR(RET_INVALID_OPTION);

    if( TRANSPOSE ) return ACADOERROR( RET_NOT_YET_IMPLEMENTED );

    setupFactorization( solve_complex, rk_swap_complex, determinant_complex, string("cabs") );
    code.addFunction( solve_complex );

    if( REUSE ) { // Also export the extra function which reuses the factorization of the matrix A
        setupSolveReuseComplete( solveReuse_complex, rk_bPerm_complex );
        code.addFunction( solveReuse_complex );
    }

    ExportVariable eig_var( 1.0/stepsize*eig );

    // SETUP solve_full
    ExportVariable det_complex1( "det_complex1", 1, 1, REAL, ACADO_LOCAL, true );
    ExportVariable det_complex2( "det_complex2", 1, 1, REAL, ACADO_LOCAL, true );
    solve_full.addDeclaration( det_complex1 );
    solve_full.addDeclaration( det_complex2 );
    ExportIndex i( "i" );
    solve_full.addIndex(i);

    // form the real and complex linear system matrices
    solve_full.addStatement( A_mem_complex1 == A_full );
    if( implicit ) {
        ExportForLoop loop1( i, 0, dim*dim );
        loop1 << A_mem_complex1.getFullName() << "[i] += (" << eig_var.get(0,0) << "+" << eig_var.get(0,1) << "*I)*" << I_full.getFullName() << "[i];\n";
        solve_full.addStatement( loop1 );
    }
    else {
        ExportForLoop loop1( i, 0, dim );
        loop1 << A_mem_complex1.getFullName() << "[i*" << toString(dim) << "+i] -= (" << eig_var.get(0,0) << "+" << eig_var.get(0,1) << "*I);\n";
        solve_full.addStatement( loop1 );
    }

    solve_full.addStatement( A_mem_complex2 == A_full );
    if( implicit ) {
        ExportForLoop loop1( i, 0, dim*dim );
        loop1 << A_mem_complex2.getFullName() << "[i] += (" << eig_var.get(1,0) << "+" << eig_var.get(1,1) << "*I)*" << I_full.getFullName() << "[i];\n";
        solve_full.addStatement( loop1 );
    }
    else {
        ExportForLoop loop1( i, 0, dim );
        loop1 << A_mem_complex2.getFullName() << "[i*" << toString(dim) << "+i] -= (" << eig_var.get(1,0) << "+" << eig_var.get(1,1) << "*I);\n";
        solve_full.addStatement( loop1 );
    }

    // factorize the real and complex linear systems
    solve_full.addFunctionCall(getNameSolveComplexFunction(),A_mem_complex1,rk_perm_full.getAddress(0,0));
    solve_full.addFunctionCall(getNameSolveComplexFunction(),A_mem_complex2,rk_perm_full.getAddress(1,0));

    code.addFunction( solve_full );

    // SETUP solveReuse_full
    if( REUSE ) {
        solveReuse_full.addIndex(i);

        // transform the right-hand side
        transformRightHandSide( solveReuse_full, i );

        // solveReuse the real and complex linear systems
        solveReuse_full.addFunctionCall(getNameSolveComplexReuseFunction(),A_mem_complex1,b_mem_complex1,rk_perm_full.getAddress(0,0));
        solveReuse_full.addFunctionCall(getNameSolveComplexReuseFunction(),A_mem_complex2,b_mem_complex2,rk_perm_full.getAddress(1,0));

        // transform back to the solution
        transformSolution( solveReuse_full, i );

        code.addFunction( solveReuse_full );
    }

    return SUCCESSFUL_RETURN;
}
示例#30
0
returnValue ExportGaussNewtonCN2::getDataDeclarations(	ExportStatementBlock& declarations,
															ExportStruct dataStruct
															) const
{
	ExportNLPSolver::getDataDeclarations(declarations, dataStruct);

	declarations.addDeclaration(sbar, dataStruct);
	declarations.addDeclaration(x0, dataStruct);
	declarations.addDeclaration(Dx0, dataStruct);

	declarations.addDeclaration(T1, dataStruct);
	declarations.addDeclaration(T2, dataStruct);
	declarations.addDeclaration(C, dataStruct);

	declarations.addDeclaration(W1, dataStruct);
	declarations.addDeclaration(W2, dataStruct);
	declarations.addDeclaration(E, dataStruct);

	declarations.addDeclaration(QDy, dataStruct);
	declarations.addDeclaration(w1, dataStruct);
	declarations.addDeclaration(w2, dataStruct);

	declarations.addDeclaration(lbValues, dataStruct);
	declarations.addDeclaration(ubValues, dataStruct);
	declarations.addDeclaration(lbAValues, dataStruct);
	declarations.addDeclaration(ubAValues, dataStruct);

	declarations.addDeclaration(H, dataStruct);
	declarations.addDeclaration(A, dataStruct);
	declarations.addDeclaration(g, dataStruct);
	declarations.addDeclaration(lb, dataStruct);
	declarations.addDeclaration(ub, dataStruct);
	declarations.addDeclaration(lbA, dataStruct);
	declarations.addDeclaration(ubA, dataStruct);
	declarations.addDeclaration(xVars, dataStruct);
	declarations.addDeclaration(yVars, dataStruct);

	return SUCCESSFUL_RETURN;
}