YANE-Framework Tutorial 1.1.0

# examples/linearequation/src/Problems/demoproblem.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 "demoproblem.h"
00011
00012 using namespace std;
00013
00014 #include "libexport.h"
00015
00016 LIB_EXPORT yane::EqSys::Demoproblem::Demoproblem ( void ) :
00017         LinearEquationProblem ( )
00018 {
00019 }
00020
00021 LIB_EXPORT yane::EqSys::Demoproblem::~Demoproblem ( void )
00022 {
00023 }
00024
00025 LIB_EXPORT void yane::EqSys::Demoproblem::setupMatrix ( int N )
00026 {
00027         _dimensionRows = 2;
00028         _dimensionColumns = 2;
00029
00030         try
00031         {
00032                 _A = new double * [ _dimensionRows ];
00033                 for ( int i = 0; i < _dimensionRows; i++ )
00034                 {
00035                         _A [ i ] = new double [ _dimensionColumns ];
00036                 }
00037         }
00039         {
00040                 throw yane::Utils::MemoryException ( __DEBUGMESS (
00041                         "Allocation of matrix failed" ) );
00042         }
00043
00044         _A [ 0 ] [ 0 ] = 1.0;
00045         _A [ 0 ] [ 1 ] = 2.0;
00046         _A [ 1 ] [ 0 ] = 1.0;
00047         _A [ 1 ] [ 1 ] = 1.0;
00048 }
00049
00050 LIB_EXPORT void yane::EqSys::Demoproblem::setupVector ( int N )
00051 {
00052         _dimensionB = 2;
00053
00054         try
00055         {
00056                 _b = new double [ _dimensionB ];
00057         }