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

RowColumnSparseMatrix.h

Go to the documentation of this file.
00001 // RowColumnSparseMatrix.h: interface for the RowColumnSparseMatrix class.
00002 //
00004 
00005 #if !defined(AFX_ROWCOLUMNSPARSEMATRIX_H__1A61EEB6_7D45_4A7B_8BC0_51B4D77A4906__INCLUDED_)
00006 #define AFX_ROWCOLUMNSPARSEMATRIX_H__1A61EEB6_7D45_4A7B_8BC0_51B4D77A4906__INCLUDED_
00007 
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011 
00012 #include "SparseMatrix.h"
00013 #include <vector>
00014 
00015 // This is the simplest type of sparse storage.  It stores each matrix element as 
00016 // a tuple (i,j,value), where i = row and j = column.  Pointers to matrix elements
00017 // (used in sorting) are compared using the MatrixElementComparator - this particular
00018 // comparator ranks the elements in row-increasing order
00019 
00020 class RowColumnSparseMatrix : public SparseMatrix  
00021 {
00022 public:
00023         RowColumnSparseMatrix(int nRows, int nCols);
00024         virtual ~RowColumnSparseMatrix();
00025         void OrderElements();
00026         bool AddElement(int row, int col, int value);
00027         void PrintMatrix();
00028         bool RightVectorMultiply(double *colVector, int length);
00029         class MatrixElement
00030         {
00031         public:
00032                 MatrixElement(int row, int col, int value)
00033                 {
00034                         this->row = row;
00035                         this->col = col;
00036                         this->value = value;
00037                 }
00038                 virtual ~MatrixElement() {return;}
00039                 int GetRow() const {return row;}
00040                 int GetCol() const {return col;}
00041                 double GetValue() const {return value;}
00042         private:
00043                 class MatrixElementComparator
00044                 {
00045                 public:
00046                         MatrixElementComparator() {return;}
00047                         virtual ~MatrixElementComparator() {return;}
00048                         bool operator() (MatrixElement *m1, MatrixElement *m2)
00049                         {
00050                                 return m1->GetRow() < m2->GetRow();
00051                         }
00052                 };
00053         private:
00054                 int row,col;
00055                 double value;
00056         };
00057 private:
00058         std::vector<MatrixElement *> matrix;
00059 };
00060 
00061 #endif // !defined(AFX_ROWCOLUMNSPARSEMATRIX_H__1A61EEB6_7D45_4A7B_8BC0_51B4D77A4906__INCLUDED_)

Generated on Mon Nov 3 09:38:13 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002