Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef CCOLMATRIX_HPP
00044 #define CCOLMATRIX_HPP 1
00045
00046
00047 #include <cstdlib>
00048 #include <iostream>
00049 #include "matrix.hpp"
00050 #include "error.hpp"
00051
00052
00075 class CColMatrix : public Matrix {
00076 int _n;
00077 int _m;
00078 int _nz;
00079 int _asize;
00080 int *_ptr;
00081 int *_row;
00082 double *_val;
00083
00084 void reallocate( void );
00085 void allocate( void );
00086
00087 double get_check( int i, int j ) const;
00088 double &set_check( int i, int j );
00089 double get_no_check( int i, int j ) const;
00090 double &set_no_check( int i, int j );
00091
00092 void clear_check( int i, int j );
00093 void clear_no_check( int i, int j );
00094
00095 void build( const class CColMatrix &mat );
00096 void build( const class CRowMatrix &mat );
00097 void build( const class CoordMatrix &mat );
00098
00099 public:
00100
00101
00102
00103
00104
00107 CColMatrix();
00108
00111 CColMatrix( int n, int m );
00112
00121 CColMatrix( int n, int m, int nz,
00122 int *ptr, int *row, double *val );
00123
00126 CColMatrix( const CColMatrix &mat );
00127
00133 CColMatrix( const class CRowMatrix &mat );
00134
00137 CColMatrix( const class CoordMatrix &mat );
00138
00141 CColMatrix( const class Matrix &mat );
00142
00145 ~CColMatrix();
00146
00147
00148
00149
00150
00153 int columns( void ) const { return( _m ); }
00154
00157 int rows( void ) const { return( _n ); }
00158
00161 void size( int &n, int &m ) const { n = _n; m = _m; }
00162
00165 int nz_elements( void ) const { return( _nz ); }
00166
00169 int capacity( void ) const { return( _asize ); }
00170
00171
00172
00173
00174
00179 void resize( int n, int m );
00180
00187 void merge( CColMatrix &mat );
00188
00191 void clear( void );
00192
00197 void clear( int i, int j );
00198
00201 void reserve( int size );
00202
00206 void order_ascending( void );
00207
00211 bool check_ascending( void );
00212
00215 void debug_print( std::ostream &os ) const;
00216
00217
00218
00219
00220
00226 double get( int i, int j ) const;
00227
00246 double &set( int i, int j );
00247
00256 void set_column( int j, int N, const int *row, const double *val );
00257
00273 void construct_add( int i, int j, double val );
00274
00275
00276
00277
00278
00282 int &ptr( int i ) { return( _ptr[i] ); }
00283
00287 int &row( int i ) { return( _row[i] ); }
00288
00292 double &val( int i ) { return( _val[i] ); }
00293
00297 const int &ptr( int i ) const { return( _ptr[i] ); }
00298
00302 const int &row( int i ) const { return( _row[i] ); }
00303
00307 const double &val( int i ) const { return( _val[i] ); }
00308
00316 void set_nz( int nz );
00317
00318
00319
00320
00321
00324 CColMatrix &operator=( const CColMatrix &mat );
00325
00332 CColMatrix &operator=( const class CRowMatrix &mat );
00333
00337 CColMatrix &operator=( const class CoordMatrix &mat );
00338
00342 CColMatrix &operator=( const Matrix &mat );
00343
00344
00345
00346
00347
00348
00349
00350 void multiply_by_vector( Vector &x, const Vector &b ) const;
00351
00357 void lower_unit_solve( Vector &x, const Vector &b ) const;
00358
00365 void upper_diag_solve( Vector &x, const Vector &b ) const;
00366
00367
00368 friend class CRowMatrix;
00369 friend class CoordMatrix;
00370 friend class Vector;
00371 friend class HBIO;
00372 };
00373
00374
00375 inline double CColMatrix::get( int i, int j ) const
00376 {
00377 #ifdef SPM_RANGE_CHECK
00378 return( get_check( i, j ) );
00379 #else
00380 return( get_no_check( i, j ) );
00381 #endif
00382 }
00383
00384
00385 inline double &CColMatrix::set( int i, int j )
00386 {
00387 #ifdef SPM_RANGE_CHECK
00388 return( set_check( i, j ) );
00389 #else
00390 return( set_no_check( i, j ) );
00391 #endif
00392 }
00393
00394
00395 inline void CColMatrix::clear( int i, int j )
00396 {
00397 #ifdef SPM_RANGE_CHECK
00398 clear_check( i, j );
00399 #else
00400 clear_no_check( i, j );
00401 #endif
00402 }
00403
00404
00405 #endif
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427