00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00040 #ifndef matpackII_h
00041 #define matpackII_h
00042
00043 #include "matpackI.h"
00044
00046
00055 class Sparse {
00056 public:
00057
00058 Sparse();
00059 Sparse(Index r, Index c);
00060 Sparse(const Sparse& m);
00061
00062
00063 void insert_row(Index r, Vector v);
00064
00065
00066 void make_I( Index r, Index c);
00067
00068
00069 void resize(Index r, Index c);
00070
00071
00072 ~Sparse();
00073
00074
00075 Index nrows() const;
00076 Index ncols() const;
00077 Index nnz() const;
00078
00079 const vector<Numeric> * data () const {return mdata;};
00080 const vector<Index> * rowind () const {return mrowind;};
00081 const vector<Index> * colptr () const {return mcolptr;};
00082
00083
00084 Numeric& rw(Index r, Index c);
00085 Numeric ro(Index r, Index c) const;
00086 Numeric operator() (Index r, Index c) const;
00087
00088
00089 Sparse& operator=(const Sparse& m);
00090
00091
00092 friend ostream& operator<<(ostream& os, const Sparse& v);
00093 friend void abs (Sparse& A, const Sparse& B );
00094 friend void mult (VectorView y, const Sparse& M, ConstVectorView x );
00095 friend void mult (MatrixView A, const Sparse& B, ConstMatrixView C );
00096 friend void mult (Sparse& A, const Sparse& B, const Sparse& C );
00097 friend void transpose (Sparse& A, const Sparse& B );
00098
00099 private:
00101 vector<Numeric> *mdata;
00103 vector<Index> *mrowind;
00105 vector<Index> *mcolptr;
00107 Index mrr;
00109 Index mcr;
00110 };
00111
00112
00113
00114 void abs( Sparse& A,
00115 const Sparse& B );
00116
00117 void mult( VectorView y,
00118 const Sparse& M,
00119 ConstVectorView x );
00120
00121 void mult( MatrixView A,
00122 const Sparse& B,
00123 ConstMatrixView C );
00124
00125 void mult( Sparse& A,
00126 const Sparse& B,
00127 const Sparse& C );
00128
00129 void transpose( Sparse& A,
00130 const Sparse& B );
00131
00132 #endif