All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseVectorProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROXY_DENSEVECTORPROXY_H_
36 #define _BLAZE_MATH_PROXY_DENSEVECTORPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
45 #include <blaze/math/shims/Clear.h>
46 #include <blaze/math/shims/Reset.h>
48 #include <blaze/system/Inline.h>
49 #include <blaze/util/Types.h>
50 
51 
52 namespace blaze {
53 
54 //=================================================================================================
55 //
56 // CLASS DEFINITION
57 //
58 //=================================================================================================
59 
60 //*************************************************************************************************
68 template< typename PT // Type of the proxy
69  , typename VT > // Type of the dense vector
70 class DenseVectorProxy : public DenseVector< PT, IsRowVector<VT>::value >
71 {
72  public:
73  //**Type definitions****************************************************************************
74  typedef typename VT::Reference Reference;
76  typedef typename VT::Pointer Pointer;
77  typedef typename VT::ConstPointer ConstPointer;
78  typedef typename VT::Iterator Iterator;
79  typedef typename VT::ConstIterator ConstIterator;
80  //**********************************************************************************************
81 
82  //**Data access functions***********************************************************************
85  inline Reference operator[]( size_t index ) const;
86 
87  inline Pointer data () const;
88  inline Iterator begin () const;
89  inline ConstIterator cbegin() const;
90  inline Iterator end () const;
91  inline ConstIterator cend () const;
93  //**********************************************************************************************
94 
95  //**Utility functions***************************************************************************
98  inline size_t size() const;
99  inline size_t capacity() const;
100  inline size_t nonZeros() const;
101  inline void reset() const;
102  inline void clear() const;
103  inline void resize( size_t n, bool preserve=true ) const;
104  inline void extend( size_t n, bool preserve=true ) const;
105  inline void reserve( size_t n ) const;
106 
107  template< typename Other > inline void scale( const Other& scalar ) const;
109  //**********************************************************************************************
110 
111  private:
112  //**Compile time checks*************************************************************************
116  //**********************************************************************************************
117 };
118 //*************************************************************************************************
119 
120 
121 
122 
123 //=================================================================================================
124 //
125 // DATA ACCESS FUNCTIONS
126 //
127 //=================================================================================================
128 
129 //*************************************************************************************************
135 template< typename PT // Type of the proxy
136  , typename VT > // Type of the dense vector
139 {
140  return (~*this).get()[index];
141 }
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
152 template< typename PT // Type of the proxy
153  , typename VT > // Type of the dense vector
155 {
156  return (~*this).get().data();
157 }
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
166 template< typename PT // Type of the proxy
167  , typename VT > // Type of the dense vector
169 {
170  return (~*this).get().begin();
171 }
172 //*************************************************************************************************
173 
174 
175 //*************************************************************************************************
180 template< typename PT // Type of the proxy
181  , typename VT > // Type of the dense vector
183 {
184  return (~*this).get().cbegin();
185 }
186 //*************************************************************************************************
187 
188 
189 //*************************************************************************************************
194 template< typename PT // Type of the proxy
195  , typename VT > // Type of the dense vector
197 {
198  return (~*this).get().end();
199 }
200 //*************************************************************************************************
201 
202 
203 //*************************************************************************************************
208 template< typename PT // Type of the proxy
209  , typename VT > // Type of the dense vector
211 {
212  return (~*this).get().cend();
213 }
214 //*************************************************************************************************
215 
216 
217 
218 
219 //=================================================================================================
220 //
221 // UTILITY FUNCTIONS
222 //
223 //=================================================================================================
224 
225 //*************************************************************************************************
230 template< typename PT // Type of the proxy
231  , typename VT > // Type of the dense vector
232 inline size_t DenseVectorProxy<PT,VT>::size() const
233 {
234  return (~*this).get().size();
235 }
236 //*************************************************************************************************
237 
238 
239 //*************************************************************************************************
244 template< typename PT // Type of the proxy
245  , typename VT > // Type of the dense vector
247 {
248  return (~*this).get().capacity();
249 }
250 //*************************************************************************************************
251 
252 
253 //*************************************************************************************************
261 template< typename PT // Type of the proxy
262  , typename VT > // Type of the dense vector
264 {
265  return (~*this).get().nonZeros();
266 }
267 //*************************************************************************************************
268 
269 
270 //*************************************************************************************************
277 template< typename PT // Type of the proxy
278  , typename VT > // Type of the dense vector
280 {
281  using blaze::reset;
282 
283  reset( (~*this).get() );
284 }
285 //*************************************************************************************************
286 
287 
288 //*************************************************************************************************
295 template< typename PT // Type of the proxy
296  , typename VT > // Type of the dense vector
298 {
299  using blaze::clear;
300 
301  clear( (~*this).get() );
302 }
303 //*************************************************************************************************
304 
305 
306 //*************************************************************************************************
321 template< typename PT // Type of the proxy
322  , typename VT > // Type of the dense vector
323 inline void DenseVectorProxy<PT,VT>::resize( size_t n, bool preserve ) const
324 {
325  (~*this).get().resize( n, preserve );
326 }
327 //*************************************************************************************************
328 
329 
330 //*************************************************************************************************
343 template< typename PT // Type of the proxy
344  , typename VT > // Type of the dense vector
345 inline void DenseVectorProxy<PT,VT>::extend( size_t n, bool preserve ) const
346 {
347  (~*this).get().extend( n, preserve );
348 }
349 //*************************************************************************************************
350 
351 
352 //*************************************************************************************************
361 template< typename PT // Type of the proxy
362  , typename VT > // Type of the dense vector
363 inline void DenseVectorProxy<PT,VT>::reserve( size_t n ) const
364 {
365  (~*this).get().reserve( n );
366 }
367 //*************************************************************************************************
368 
369 
370 //*************************************************************************************************
376 template< typename PT // Type of the proxy
377  , typename VT > // Type of the dense vector
378 template< typename Other > // Data type of the scalar value
379 inline void DenseVectorProxy<PT,VT>::scale( const Other& scalar ) const
380 {
381  (~*this).get().scale( scalar );
382 }
383 //*************************************************************************************************
384 
385 
386 
387 
388 //=================================================================================================
389 //
390 // GLOBAL FUNCTIONS
391 //
392 //=================================================================================================
393 
394 //*************************************************************************************************
397 template< typename PT, typename VT >
399  begin( const DenseVectorProxy<PT,VT>& proxy );
400 
401 template< typename PT, typename VT >
403  cbegin( const DenseVectorProxy<PT,VT>& proxy );
404 
405 template< typename PT, typename VT >
407  end( const DenseVectorProxy<PT,VT>& proxy );
408 
409 template< typename PT, typename VT >
411  cend( const DenseVectorProxy<PT,VT>& proxy );
412 
413 template< typename PT, typename VT >
414 BLAZE_ALWAYS_INLINE size_t size( const DenseVectorProxy<PT,VT>& proxy );
415 
416 template< typename PT, typename VT >
418 
419 template< typename PT, typename VT >
421 
422 template< typename PT, typename VT >
424 
425 template< typename PT, typename VT >
428 //*************************************************************************************************
429 
430 
431 //*************************************************************************************************
438 template< typename PT // Type of the proxy
439  , typename VT > // Type of the dense vector
442 {
443  return proxy.begin();
444 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
455 template< typename PT // Type of the proxy
456  , typename VT > // Type of the dense vector
459 {
460  return proxy.cbegin();
461 }
462 //*************************************************************************************************
463 
464 
465 //*************************************************************************************************
472 template< typename PT // Type of the proxy
473  , typename VT > // Type of the dense vector
475  end( const DenseVectorProxy<PT,VT>& proxy )
476 {
477  return proxy.end();
478 }
479 //*************************************************************************************************
480 
481 
482 //*************************************************************************************************
489 template< typename PT // Type of the proxy
490  , typename VT > // Type of the dense vector
493 {
494  return proxy.cend();
495 }
496 //*************************************************************************************************
497 
498 
499 //*************************************************************************************************
506 template< typename PT // Type of the proxy
507  , typename VT > // Type of the dense vector
509 {
510  return proxy.size();
511 }
512 //*************************************************************************************************
513 
514 
515 //*************************************************************************************************
522 template< typename PT // Type of the proxy
523  , typename VT > // Type of the dense vector
525 {
526  return proxy.capacity();
527 }
528 //*************************************************************************************************
529 
530 
531 //*************************************************************************************************
541 template< typename PT // Type of the proxy
542  , typename VT > // Type of the dense vector
544 {
545  return proxy.nonZeros();
546 }
547 //*************************************************************************************************
548 
549 
550 //*************************************************************************************************
559 template< typename PT // Type of the proxy
560  , typename VT > // Type of the dense vector
562 {
563  proxy.reset();
564 }
565 //*************************************************************************************************
566 
567 
568 //*************************************************************************************************
577 template< typename PT // Type of the proxy
578  , typename VT > // Type of the dense vector
580 {
581  proxy.clear();
582 }
583 //*************************************************************************************************
584 
585 } // namespace blaze
586 
587 #endif
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:237
size_t nonZeros() const
Returns the number of non-zero elements in the represented vector.
Definition: DenseVectorProxy.h:263
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:300
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
ConstIterator cbegin() const
Returns an iterator to the first element of the represented vector.
Definition: DenseVectorProxy.h:182
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
Header file for the IsRowVector type trait.
void clear() const
Clearing the represented vector.
Definition: DenseVectorProxy.h:297
Header file for the DenseVector base class.
void resize(size_t n, bool preserve=true) const
Changing the size of the represented vector.
Definition: DenseVectorProxy.h:323
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:386
void extend(size_t n, bool preserve=true) const
Extending the size of the represented vector.
Definition: DenseVectorProxy.h:345
VT::ConstReference ConstReference
Reference to a constant vector value.
Definition: DenseVectorProxy.h:75
Pointer data() const
Low-level data access to vector elements.
Definition: DenseVectorProxy.h:154
VT::ConstPointer ConstPointer
Pointer to a constant vector value.
Definition: DenseVectorProxy.h:77
VT::Iterator Iterator
Iterator over non-constant elements.
Definition: DenseVectorProxy.h:78
Proxy backend for dense vector types.The DenseVectorProxy class serves as a backend for the Proxy cla...
Definition: DenseVectorProxy.h:70
Header file for the clear shim.
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
void reset() const
Reset to the default initial value.
Definition: DenseVectorProxy.h:279
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
ConstIterator cend() const
Returns an iterator just past the last element of the represented vector.
Definition: DenseVectorProxy.h:210
size_t capacity() const
Returns the maximum capacity of the represented vector.
Definition: DenseVectorProxy.h:246
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Reference operator[](size_t index) const
Subscript operator for the direct access to vector elements.
Definition: DenseVectorProxy.h:138
RawReference get() const
Returning the value of the accessed sparse matrix element.
Definition: MatrixAccessProxy.h:360
VT::Pointer Pointer
Pointer to a non-constant vector value.
Definition: DenseVectorProxy.h:76
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
void scale(const Other &scalar) const
Scaling of the vector by the scalar value scalar ( ).
Definition: DenseVectorProxy.h:379
Iterator end() const
Returns an iterator just past the last element of the represented vector.
Definition: DenseVectorProxy.h:196
size_t size() const
Returns the current size/dimension of the represented vector.
Definition: DenseVectorProxy.h:232
VT::Reference Reference
Reference to a non-constant vector value.
Definition: DenseVectorProxy.h:74
Header file for the reset shim.
void reserve(size_t n) const
Setting the minimum capacity of the represented vector.
Definition: DenseVectorProxy.h:363
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:79
VT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: DenseVectorProxy.h:79
Header file for basic type definitions.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
System settings for the inline keywords.
Iterator begin() const
Returns an iterator to the first element of the represented vector.
Definition: DenseVectorProxy.h:168