Changeset 2989
- Timestamp:
- 07/02/08 06:37:47 (5 months ago)
- Location:
- trunk/linbox/linbox/vector
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/linbox/linbox/vector/pair.h
r1404 r2989 1 1 // ======================================================================= // (C) Linbox 2000 2 2 // Pair of I and T : struct { column index, value } 3 // Time-stamp: < 19 Sep 03 11:00:25 Jean-Guillaume.Dumas@imag.fr>3 // Time-stamp: <23 May 08 13:21:05 Jean-Guillaume.Dumas@imag.fr> 4 4 // ======================================================================= 5 5 #ifndef _LIN_PAIR_H_ … … 10 10 // 11 11 /// Pair of I and T : struct { column index, value } 12 template<class T, class I = unsigned long> class Pair {12 template<class I, class T> class Pair { 13 13 public: 14 typedef Pair< T, I> Self_t;14 typedef Pair<I, T> Self_t; 15 15 typedef T Type_t; 16 16 typedef I first_type; 17 typedef T second_type; 18 17 19 // ~Pair() {}; 18 20 Pair() {}; 19 21 20 Pair(const I jj, const T& val) : _j(jj),_value(val){};21 Pair(const Self_t& p) : _j(p._j),_value(p._value){};22 Pair(const I jj, const T& val) :first(jj),second(val){}; 23 Pair(const Self_t& p) :first(p.first),second(p.second){}; 22 24 23 25 24 T getvalue() const { return _value; };26 T getvalue() const { return second; }; 25 27 26 I getindex() const { return _j; };27 I j() const { return _j; };28 I getindex() const { return first; }; 29 I j() const { return first; }; 28 30 29 T affect(const T& val) { return _value= val; };30 T change_value(const T& val) { return _value= val; };31 T affect(const T& val) { return second = val; }; 32 T change_value(const T& val) { return second = val; }; 31 33 32 I change_j(const I jj) { return _j= jj; };33 I change_index(const I jj) { return _j= jj; };34 I change_j(const I jj) { return first = jj; }; 35 I change_index(const I jj) { return first = jj; }; 34 36 35 37 36 38 Self_t assign(const T& val) { 37 _value= val;39 second = val; 38 40 return *this; 39 41 }; 40 42 41 43 Self_t assign(const I jj, const T& val) { 42 _value= val;43 _j= jj;44 second = val; 45 first = jj; 44 46 return *this; 45 47 }; 46 48 47 I decr() { return -- _j; };48 I operator--() { return -- _j; };49 I operator--(int) { return _j--; };50 I incr() { return ++ _j; };51 I operator++() { return ++ _j; };52 I operator++(int) { return _j++; };49 I decr() { return --first; }; 50 I operator--() { return --first; }; 51 I operator--(int) { return first--; }; 52 I incr() { return ++first; }; 53 I operator++() { return ++first; }; 54 I operator++(int) { return first++; }; 53 55 54 friend inline std::istream& operator>> (std::istream& is, Pair<T, I>& a) { 55 I jj; 56 T val; 57 is >> jj >> val; 58 a._value=val; a._j=jj; 59 // a = Pair<T, I>(jj,val); 56 friend inline std::istream& operator>> (std::istream& is, Pair<I, T>& a) { 57 is >> a.first >> a.second; 60 58 return is; 61 }; 59 } 62 60 63 friend inline std::ostream& operator<< (std::ostream& o, const Pair<T, I> a){ 64 // return o << a.j() << " " << a.getvalue() ; 65 return o << a._j << " " << a._value ; 66 }; 61 friend inline std::ostream& operator<< (std::ostream& o, const Pair<I, T> a){ 62 return o << a.first << " " << a.second ; 63 } 67 64 68 65 69 p rivate:70 I _j;71 T _value;66 public: 67 I first; 68 T second; 72 69 }; 73 70 -
trunk/linbox/linbox/vector/sparse.h
r2371 r2989 1 1 // ======================================================================= // (C) Linbox 2000 2 2 // Sparse Vector : vector< Pair<T> > and an additional actual size 3 // Time-stamp: < 15 Jul 05 10:27:48Jean-Guillaume.Dumas@imag.fr>3 // Time-stamp: <23 May 08 13:21:31 Jean-Guillaume.Dumas@imag.fr> 4 4 // ======================================================================= 5 5 #ifndef _SPARSE_VECTOR_H_ … … 23 23 // --------------------------------------------------- 24 24 // 25 /** \brief vector< Pair<T > > and actualsize25 /** \brief vector< Pair<T,I> > and actualsize 26 26 \ingroup vector 27 27 */ 28 template<class T, class I = unsigned long>29 class Sparse_Vector : public _IBB_VECTOR_< Pair< T, I> > {28 template<class T, class I = unsigned int> 29 class Sparse_Vector : public _IBB_VECTOR_< Pair<I, T> > { 30 30 public: 31 typedef Pair< T, I> Element;31 typedef Pair<I, T> Element; 32 32 typedef T Type_t; 33 33 typedef Sparse_Vector<T, I> Self_t; … … 38 38 39 39 Sparse_Vector() {}; 40 Sparse_Vector(size_t n) : _IBB_VECTOR_< Pair< T, I> >(n), _rsize(0) {};41 Sparse_Vector(size_t n, size_t rn) : _IBB_VECTOR_< Pair< T, I> >(n), _rsize(rn) {};40 Sparse_Vector(size_t n) : _IBB_VECTOR_< Pair<I, T> >(n), _rsize(0) {}; 41 Sparse_Vector(size_t n, size_t rn) : _IBB_VECTOR_< Pair<I, T> >(n), _rsize(rn) {}; 42 42 ~Sparse_Vector() {}; 43 43 -
trunk/linbox/linbox/vector/vector-traits.h
r2619 r2989 205 205 { 206 206 public: 207 inline bool operator () (const std::pair <size_t, T> &i, const size_t j) const 207 template<typename PairType> 208 inline bool operator () (const PairType &i, const size_t j) const 208 209 { return i.first < j; } 209 210 };
