00001
00002
00003
00004
00005
00006
00007 #ifndef SYNAPS_LINALG_MATRSPS_H
00008 #define SYNAPS_LINALG_MATRSPS_H
00009
00010 #include <synaps/init.h>
00011 #include <synaps/arithm/GENERIC.h>
00012 #include <synaps/linalg/MethodName.h>
00013 #include <synaps/linalg/sparse.h>
00014
00015 __BEGIN_NAMESPACE_SYNAPS
00016
00017
00024 template<class C, class R=sparse::rep2d<C> > struct MatrSps
00025 {
00026 shared_object<R> data;
00027 R & rep() {return (*data);}
00028 const R & rep() const {return (*data);}
00029
00030 typedef typename R::size_type size_type;
00031 typedef C value_type;
00032 typedef MatrSps<C,R> self_t;
00033
00034 MatrSps() {}
00035 MatrSps(const R & r): data(r) {}
00036 MatrSps(int m, int n): data(R(m,n)) {}
00037 MatrSps(int m, int n, int nz) : data(R(n,m,nz)) {}
00038 MatrSps(int m, int n, int nz, value_type* t, size_type* idx):
00039 data(R(m,n,nz,t,idx)) {}
00040
00041 MatrSps(const char * str): data(R(str)) {}
00042 MatrSps(const self_t & M): data(M.data) {}
00043 template<class T>
00044 MatrSps(const VAL<T> & M)
00045 {
00046 using let::assign; assign(*this,M.rep());
00047 }
00048
00049 self_t & operator=(const self_t & M) {data=M.data; return *this;}
00050 template<class T>
00051 self_t & operator=(const VAL<T> & M)
00052 {
00053 using let::assign;assign(*this,M.rep()); return *this;
00054 }
00055
00056 self_t & transpose () {rep().transpose(); return *this;}
00057
00058 size_type nbrow() const {return rep().nbrow();}
00059 size_type nbcol() const {return rep().nbcol();}
00060 size_type nzero() const {return rep().nzero();}
00061
00062 value_type operator() (size_type i, size_type j) const {return rep()(i,j);}
00063
00064 self_t & operator*=(const value_type & c);
00065 self_t & operator/=(const value_type & c);
00066
00067 self_t & swaprow(size_type i, size_type j);
00068 self_t & swapcol(size_type, size_type);
00069 self_t & permrow(size_type *pivot);
00070 self_t & permcol(size_type *pivot);
00071
00072 };
00073
00078 template<class C,class R>
00079 inline void WriteToHSL(const MatrSps<C,R> & M, const char *file_to_write)
00080 {
00081 writetoHSL(M.rep(), file_to_write);
00082 }
00083
00088 template<class C,class R>
00089 inline void readFromHSL(MatrSps<C,R> & M, const char *file_to_write)
00090 {
00091 readfromHSL(M.rep(), file_to_write);
00092 }
00093
00094
00095
00097 template<class C,class R>
00098 std::ostream & operator<<(std::ostream & os, const MatrSps<C,R> & m)
00099 {
00100 return print(os,m.rep());
00101 }
00102
00103
00104 __END_NAMESPACE_SYNAPS
00105
00106
00107 #ifndef SEPARATE_COMPILATION
00108 #include "synaps/linalg/MatrSps.C"
00109 #endif
00110
00111
00112 #endif // SYNAPS_LINALG_MATRSPS_H
00113