SparseVectorInline.cxx
1 // Copyright (C) 2003-2011 Marc DuruflĂ©
2 // Copyright (C) 2001-2011 Vivien Mallet
3 //
4 // This file is part of the linear-algebra library Seldon,
5 // http://seldon.sourceforge.net/.
6 //
7 // Seldon is free software; you can redistribute it and/or modify it under the
8 // terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 2.1 of the License, or (at your option)
10 // any later version.
11 //
12 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 // more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with Seldon. If not, see http://www.gnu.org/licenses/.
19 
20 
21 #ifndef SELDON_FILE_SPARSE_VECTOR_INLINE_CXX
22 
23 #include "SparseVector.hxx"
24 
25 namespace Seldon
26 {
27 
28 
29  /****************
30  * CONSTRUCTORS *
31  ****************/
32 
33 
35 
38  template <class T, class Allocator>
40  Vector<T, VectFull, Allocator>()
41  {
42  index_ = NULL;
43  }
44 
45 
47 
50  template <class T, class Allocator>
53  Vector<T, VectFull, Allocator>()
54  {
55  this->index_ = NULL;
56  Copy(V);
57  }
58 
59 
61 
67  template <class T, class Allocator>
69  {
70  ReallocateVector(i);
71  }
72 
73 
74  /**************
75  * DESTRUCTOR *
76  **************/
77 
78 
80  template <class T, class Allocator>
82  {
83  Clear();
84  }
85 
86 
87  /**********************************
88  * ELEMENT ACCESS AND AFFECTATION *
89  **********************************/
90 
91 
93 
97  template <class T, class Allocator>
100  {
101 
102 #ifdef SELDON_CHECK_BOUNDS
103  CheckBounds(i, this->m_, "Vector<VectSparse>");
104 #endif
105 
106  return this->data_[i];
107  }
108 
109 
111 
115  template <class T, class Allocator>
118  {
119 
120 #ifdef SELDON_CHECK_BOUNDS
121  CheckBounds(i, this->m_, "Vector<VectSparse>");
122 #endif
123 
124  return this->data_[i];
125  }
126 
127 
129 
133  template <class T, class Allocator>
135  {
136 
137 #ifdef SELDON_CHECK_BOUNDS
138  CheckBounds(i, this->m_, "Vector<VectSparse>");
139 #endif
140 
141  return this->index_[i];
142  }
143 
144 
146 
150  template <class T, class Allocator>
152  {
153 
154 #ifdef SELDON_CHECK_BOUNDS
155  CheckBounds(i, this->m_, "Vector<VectSparse>");
156 #endif
157 
158  return this->index_[i];
159  }
160 
161 
163 
168  template <class T, class Allocator>
171  {
172  this->Copy(X);
173 
174  return *this;
175  }
176 
177 
178  /*******************
179  * BASIC FUNCTIONS *
180  *******************/
181 
182 
188  template <class T, class Allocator>
190  {
191  return this->index_;
192  }
193 
194 
196 
200  template <class T, class Allocator>
202  {
203  return sizeof(*this) + (sizeof(T) + sizeof(int))*size_t(this->m_);
204  }
205 
206 } // namespace Seldon.
207 
208 #define SELDON_FILE_SPARSE_VECTOR_INLINE_CXX
209 #endif
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::Vector< T, VectSparse, Allocator >
Sparse vector class.
Definition: SparseVector.hxx:29
Seldon
Seldon namespace.
Definition: Array.cxx:24