YANE-Framework Tutorial 1.1.0

examples/linearequation/src/Problems/linearequationproblem.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  * Copyright (C) 2011 by www.nonlinearmpc.com                              *
00004  *                                                                         *
00005  * Authors:                                                                *
00006  *  Juergen Pannek <juergen.pannek@googlemail.com>                         *
00007  *                                                                         *
00008  ***************************************************************************/
00009 
00010 #include "linearequationproblem.h"
00011 
00012 using namespace std;
00013 
00014 #include "libexport.h"
00015 
00016 LIB_EXPORT yane::EqSys::LinearEquationProblem::LinearEquationProblem ( void )
00017 {
00018 }
00019 
00020 LIB_EXPORT yane::EqSys::LinearEquationProblem::~LinearEquationProblem ( void )
00021 {
00022         if ( _b != 0 ) delete [ ] _b;
00023         if ( _A != 0 ) delete [ ] _A;
00024 }
00025 
00026 LIB_EXPORT void yane::EqSys::LinearEquationProblem::initialize ( int N )
00027 {
00028         try
00029         {
00030                 setupMatrix ( N );
00031                 setupVector ( N );
00032         }
00033         catch ( yane::Utils::MemoryException e )
00034         {
00035                 if ( _b != 0 ) delete [ ] _b;
00036                 if ( _A != 0 ) delete [ ] _A;
00037                 throw yane::Utils::Exception ( __EXCEPTIONMESS (
00038                         yane::Utils::Exception::TYPE, "Initialization error" ),
00039                         __DEBUGMESS ( "Example setup failed" ), & e );
00040         }
00041 }
00042 
00043 LIB_EXPORT void yane::EqSys::LinearEquationProblem::getA ( double ** & A )
00044 {
00045         A = _A;
00046 }
00047 
00048 LIB_EXPORT void yane::EqSys::LinearEquationProblem::getB ( double * & b )
00049 {
00050         b = _b;
00051 }
00052 
00053 LIB_EXPORT int yane::EqSys::LinearEquationProblem::dimensionRows ( void )
00054 {
00055         return _dimensionRows;
00056 }
00057 
00058 LIB_EXPORT int yane::EqSys::LinearEquationProblem::dimensionColumns ( void )
00059 {
00060         return _dimensionColumns;
00061 }
00062 
00063 LIB_EXPORT int yane::EqSys::LinearEquationProblem::dimensionB ( void )
00064 {
00065         return _dimensionB;
00066 }