Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

linearsys.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001 The AUTHORS 
00003  *   Romeu Andre' Pieritz, Ph.D.        - romeu_pieritz@hotmail.com
00004  *   Rafael Mendes, Eng.                – mendes_rafael@yahoo.com
00005  *   Rodrigo Ferraz de Andrade, Eng.    – rferraz@iname.com 
00006  * All rights reserved.
00007  *
00008  * Permission to use, copy and distribute this software and its
00009  * documentation for educational and personal use, without fee is hereby granted, 
00010  * provided that the above copyright notice and the following
00011  * two paragraphs appear in all copies of this software.
00012  *
00013  * IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR
00014  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
00015  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS
00016  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00017  *
00018  * THE AUTHORS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
00019  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
00020  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HERE UNDER IS
00021  * ON AN "AS IS" BASIS, AND THE AUTHORS HAVE NO OBLIGATION TO
00022  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00023  *
00024  * SINMEC Lab. - CFD Sinflow Project - http://www.sinmec.ufsc.br/cfd
00025  */
00026 
00027 // File Define
00028 #ifndef __CSFL_SYS_MATH_LINEARSYSTEM_H__
00029 #define __CSFL_SYS_MATH_LINEARSYSTEM_H__
00030 
00031 
00032 // Include
00033 #include <csfl/sys/math/vector.h>
00034 #include <csfl/sys/math/matrix.h>
00035 
00036 
00037 // Namespace
00038 namespace csfl {
00039 
00040 
00041 class ILinearSystem : 
00042         virtual public ISFLObject 
00043 
00047 
00048 {
00049 
00050 public:
00051         
00056         ILinearSystem( int _variables );
00061         ILinearSystem( int _row, int _col );
00063         ILinearSystem( const ISize &_size );
00064         ILinearSystem( ILinearSystem *_lsys );    
00065         ~ILinearSystem();
00066 
00071         Vector * VectorB() { return vecB; }
00072 
00077         Vector * VectorX() { return vecX; }   
00078     
00082         inline void SetVectorB( Vector *_vecB );
00083 
00087         inline void SetVectorX( Vector *_vecX );
00088 
00093     inline virtual double MatrixA( int _i, int _j );
00094 
00096     inline double VectorX( int _i );
00097 
00099     inline double VectorB( int _i );
00100      
00105     inline virtual void MatrixA( int _i, int _j, double _val );
00106 
00108     inline void VectorX( int _i, double _val );
00109 
00111     inline void VectorB( int _i, double _val );
00112 
00118         ISize GridSize() { return gsize; }
00119 
00123         ISize Size() { return lsize; }
00124         
00128         int Variables() { return lsize.width; }
00129   
00130 protected:
00131         ISize gsize, lsize;
00132         Matrix *matA;
00133     Vector *vecB, *vecX;
00134 };
00135 
00136 // =============================================================================
00137 // Inline functions
00138 // =============================================================================
00139 
00140 inline void ILinearSystem::SetVectorB( Vector *_vecB )
00141 { 
00142     if (vecB)
00143         delete vecB;
00144     vecB = new Vector( _vecB );
00145 }
00146  
00147 inline void ILinearSystem::SetVectorX( Vector *_vecX )
00148 {
00149     if (vecX)
00150         delete vecX;
00151     vecX = new Vector( _vecX );
00152 }
00153 
00154 inline double ILinearSystem::MatrixA( int _i, int _j )
00155 {
00156     int lni = lsize.width;
00157     int lnj = lsize.height;
00158         
00159     if ( _i>=0 && _i<lni && _j>=0 && _j<lnj ) return (*matA)( _i, _j );
00160         
00161         else return 0.0;
00162 }
00163 
00164 inline double ILinearSystem::VectorX( int _i )
00165 {
00166     int ni = vecX->Size();
00167    
00168     if ( _i>=0 && _i<ni )
00169             return (*vecX)( _i );
00170     else
00171         return  0.0;
00172 }
00173 
00174 inline double ILinearSystem::VectorB( int _i )
00175 {
00176     int ni = vecB->Size();
00177 
00178     if ( _i>=0 && _i<ni )
00179             return (*vecB)( _i );
00180     else
00181         return 0.0;
00182 }
00183 
00184 inline void ILinearSystem::MatrixA( int _i, int _j, double _val )
00185 {    
00186         int lni = lsize.width;
00187     int lnj = lsize.height;
00188 
00189     if ( _i>=0 && _i<lni && _j>=0 && _j<lnj ) 
00190                 (*matA)( _i, _j )= _val;
00191 }
00192 
00193 inline void ILinearSystem::VectorX( int _i, double _val )
00194 {
00195     int ni = vecX->Size();
00196 
00197     if ( _i>=0 && _i<ni )
00198            (*vecX)( _i ) = _val;
00199 }
00200 
00201 inline void ILinearSystem::VectorB( int _i, double _val )
00202 {
00203     int ni = vecB->Size();
00204 
00205     if ( _i>=0 && _i<ni )
00206            (*vecB)( _i ) = _val;
00207 }
00208 
00209 } // csfl namespace
00210 
00211 #endif// __CSFL_SYS_MATH_LINEARSYSTEM_H__

 

CFD Project | Documents | Downloads | Contact us | Use Terms

 

© SINMEC/EMC/UFSC, 2001.

All rights reserved.

Last Update: Jan. 18, 2002

 Webmaster