LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Vector.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008, 2009, 2010, 2011 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 #ifndef NDARRAY_Vector_h_INCLUDED
24 #define NDARRAY_Vector_h_INCLUDED
25 
27 
28 #include <boost/type_traits/is_arithmetic.hpp>
29 #include <boost/iterator/reverse_iterator.hpp>
30 #include <boost/mpl/int.hpp>
31 #include <boost/utility/enable_if.hpp>
32 #include <boost/preprocessor/repetition/repeat.hpp>
33 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
34 #include <boost/preprocessor/repetition/enum.hpp>
35 
36 #include <iostream>
37 
38 #include "ndarray_fwd.h"
39 #include "ndarray/types.h"
40 
42 #define NDARRAY_MAKE_VECTOR_MAX 8
43 
44 #define NDARRAY_MAKE_VECTOR_ARG_SPEC(Z,I,DATA) T v ## I
45 #define NDARRAY_MAKE_VECTOR_SET_SPEC(Z,I,DATA) r[I] = v ## I;
46 
47 #define NDARRAY_MAKE_VECTOR_SPEC(Z,N,DATA) \
48  template <typename T> \
49  inline Vector<T,N> makeVector( \
50  BOOST_PP_ENUM(N,NDARRAY_MAKE_VECTOR_ARG_SPEC,unused) \
51  ) { \
52  Vector<T,N> r; \
53  BOOST_PP_REPEAT(N,NDARRAY_MAKE_VECTOR_SET_SPEC,unused) \
54  return r; \
55  }
56 
58 
59 namespace ndarray {
60 
61 namespace detail {
62 
63 template <typename T, bool isArithmetic=boost::is_arithmetic<T>::value>
64 struct DefaultValue {
65  static T get() { return T(); }
66 };
67 
68 template <typename T>
69 struct DefaultValue<T,true> {
70  static T get() { return T(0); }
71 };
72 
73 } // namespace detail
74 
77 
89 template <
90  typename T,
91  int N
92  >
93 struct Vector {
94 
95  typedef T Element;
96  typedef T Value;
97  typedef T & Reference;
98  typedef T const & ConstReference;
99  typedef T * Iterator;
100  typedef T const * ConstIterator;
101 
102  typedef Value value_type;
107  typedef boost::reverse_iterator<T*> reverse_iterator;
108  typedef boost::reverse_iterator<const T*> const_reverse_iterator;
109  typedef T * pointer;
110  typedef int difference_type;
111  typedef int size_type;
112 
113 
114  typedef boost::mpl::int_<N> ND;
115 
116  size_type size() const { return N; }
117  size_type max_size() const { return N; }
118  bool empty() const { return N==0; }
119  iterator begin() { return elems; }
122  const_iterator begin() const { return elems; }
124  iterator end() { return elems+N; }
126  const_iterator end() const { return elems+N; }
135 
137  reference front() { return *elems; }
139  reference back() { return *(elems+N-1); }
141  const_reference front() const { return *elems; }
143  const_reference back() const { return *(elems+N-1); }
144 
146  reference operator[](int i) { return elems[i]; }
148  const_reference operator[](int i) const { return elems[i]; }
149 
151  template <int Start, int Stop>
152  Vector<T,Stop-Start> getRange() const {
153  Vector<T,Stop-Start> r;
154  std::copy(begin() + Start, begin()+Stop, r.begin());
155  return r;
156  }
157 
159  template <int M> Vector<T,M> first() const {
160  Vector<T,M> r;
161  std::copy(begin(), begin() + M, r.begin());
162  return r;
163  }
164 
166  template <int M> Vector<T,M> last() const {
167  Vector<T,M> r;
168  std::copy(begin() + (N - M), begin() + N, r.begin());
169  return r;
170  }
171 
173  friend std::ostream& operator<<(std::ostream& os, Vector<T,N> const & obj) {
174  os << "(";
175  std::copy(obj.begin(), obj.end(), std::ostream_iterator<T>(os,","));
176  return os << ")";
177  }
178 
185 
187  template <typename U>
188  explicit Vector(U scalar) {
189  this->template operator=(scalar);
190  }
191 
193  template <typename U>
194  explicit Vector(Vector<U,N> const & other) {
195  this->template operator=(other);
196  }
197 
199  bool operator==(Vector const & other) const {
200  return std::equal(begin(), end(), other.begin());
201  }
202 
204  bool operator!=(Vector const & other) const {
205  return !(*this == other);
206  }
207 
209  T sum() const {
210  T r = 0;
211  for (ConstIterator i = begin(); i != end(); ++i) r += (*i);
212  return r;
213  }
214 
216  T product() const {
217  T r = 1;
218  for (ConstIterator i = begin(); i != end(); ++i) r *= (*i);
219  return r;
220  }
221 
223  Vector reverse() const {
224  Vector r;
225  std::copy(begin(), end(), r.rbegin());
226  return r;
227  }
228 
229 
231  template <typename U>
232  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
233  operator = (Vector<U,N> const & other) {
234  typename Vector<U,N>::ConstIterator j = other.begin();
235  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) = (*j);
236  return *this;
237  }
239  template <typename U>
240  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
241  operator = (U scalar) {
242  for (Iterator i = begin(); i != end(); ++i) (*i) = scalar;
243  return *this;
244  }
245 
247  template <typename U>
248  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
249  operator += (Vector<U,N> const & other) {
250  typename Vector<U,N>::ConstIterator j = other.begin();
251  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) += (*j);
252  return *this;
253  }
255  template <typename U>
256  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
257  operator += (U scalar) {
258  for (Iterator i = begin(); i != end(); ++i) (*i) += scalar;
259  return *this;
260  }
261 
263  template <typename U>
264  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
265  operator -= (Vector<U,N> const & other) {
266  typename Vector<U,N>::ConstIterator j = other.begin();
267  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) -= (*j);
268  return *this;
269  }
271  template <typename U>
272  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
273  operator -= (U scalar) {
274  for (Iterator i = begin(); i != end(); ++i) (*i) -= scalar;
275  return *this;
276  }
277 
279  template <typename U>
280  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
281  operator *= (Vector<U,N> const & other) {
282  typename Vector<U,N>::ConstIterator j = other.begin();
283  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) *= (*j);
284  return *this;
285  }
287  template <typename U>
288  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
289  operator *= (U scalar) {
290  for (Iterator i = begin(); i != end(); ++i) (*i) *= scalar;
291  return *this;
292  }
293 
295  template <typename U>
296  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
297  operator /= (Vector<U,N> const & other) {
298  typename Vector<U,N>::ConstIterator j = other.begin();
299  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) /= (*j);
300  return *this;
301  }
303  template <typename U>
304  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
305  operator /= (U scalar) {
306  for (Iterator i = begin(); i != end(); ++i) (*i) /= scalar;
307  return *this;
308  }
309 
311  template <typename U>
312  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
313  operator %= (Vector<U,N> const & other) {
314  typename Vector<U,N>::ConstIterator j = other.begin();
315  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) %= (*j);
316  return *this;
317  }
319  template <typename U>
320  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
321  operator %= (U scalar) {
322  for (Iterator i = begin(); i != end(); ++i) (*i) %= scalar;
323  return *this;
324  }
325 
327  template <typename U>
328  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
329  operator &= (Vector<U,N> const & other) {
330  typename Vector<U,N>::ConstIterator j = other.begin();
331  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) &= (*j);
332  return *this;
333  }
335  template <typename U>
336  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
337  operator &= (U scalar) {
338  for (Iterator i = begin(); i != end(); ++i) (*i) &= scalar;
339  return *this;
340  }
341 
343  template <typename U>
344  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
345  operator ^= (Vector<U,N> const & other) {
346  typename Vector<U,N>::ConstIterator j = other.begin();
347  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) ^= (*j);
348  return *this;
349  }
351  template <typename U>
352  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
353  operator ^= (U scalar) {
354  for (Iterator i = begin(); i != end(); ++i) (*i) ^= scalar;
355  return *this;
356  }
357 
359  template <typename U>
360  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
361  operator |= (Vector<U,N> const & other) {
362  typename Vector<U,N>::ConstIterator j = other.begin();
363  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) |= (*j);
364  return *this;
365  }
367  template <typename U>
368  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
369  operator |= (U scalar) {
370  for (Iterator i = begin(); i != end(); ++i) (*i) |= scalar;
371  return *this;
372  }
373 
375  template <typename U>
376  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
377  operator <<= (Vector<U,N> const & other) {
378  typename Vector<U,N>::ConstIterator j = other.begin();
379  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) <<= (*j);
380  return *this;
381  }
383  template <typename U>
384  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
385  operator <<= (U scalar) {
386  for (Iterator i = begin(); i != end(); ++i) (*i) <<= scalar;
387  return *this;
388  }
389 
391  template <typename U>
392  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
393  operator >>= (Vector<U,N> const & other) {
394  typename Vector<U,N>::ConstIterator j = other.begin();
395  for (Iterator i = begin(); i != end(); ++i, ++j) (*i) >>= (*j);
396  return *this;
397  }
399  template <typename U>
400  typename boost::enable_if<boost::is_convertible<U,T>,Vector&>::type
401  operator >>= (U scalar) {
402  for (Iterator i = begin(); i != end(); ++i) (*i) >>= scalar;
403  return *this;
404  }
405 
406  T elems[N];
407 };
408 
410 template <typename T>
411 struct Vector<T,0> {
412 
413  typedef T Element;
414  typedef T Value;
415  typedef T & Reference;
416  typedef T const & ConstReference;
417  typedef T * Iterator;
418  typedef T const * ConstIterator;
419 
420  typedef Value value_type;
425  typedef boost::reverse_iterator<T*> reverse_iterator;
426  typedef boost::reverse_iterator<const T*> const_reverse_iterator;
427  typedef T * pointer;
428  typedef int difference_type;
429  typedef int size_type;
430 
431 
432  typedef boost::mpl::int_<0> ND;
433 
434  size_type size() const { return 0; }
435  size_type max_size() const { return 0; }
436  bool empty() const { return true; }
437  iterator begin() { return 0; }
440  const_iterator begin() const { return 0; }
442  iterator end() { return 0; }
444  const_iterator end() const { return 0; }
453 
455  reference front() { NDARRAY_ASSERT(false); return 0; }
457  reference back() { return NDARRAY_ASSERT(false); return 0; }
459  const_reference front() const { NDARRAY_ASSERT(false); return 0; }
461  const_reference back() const { NDARRAY_ASSERT(false); return 0; }
462 
464  reference operator[](int i) { NDARRAY_ASSERT(false); return 0; }
466  const_reference operator[](int i) const { NDARRAY_ASSERT(false); return 0; }
467 
469  template <int Start, int Stop>
470  Vector<T,Stop-Start> getRange() const {
471  return Vector<T,Stop-Start>();
472  }
473 
475  template <int M> Vector<T,M> first() const {
476  return Vector<T,M>();
477  }
478 
480  template <int M> Vector<T,M> last() const {
481  return Vector<T,M>();
482  }
483 
485  friend std::ostream& operator<<(std::ostream& os, Vector<T,0> const & obj) {
486  return os << "()";
487  }
488 
494  Vector() {}
495 
497  template <typename U>
498  explicit Vector(U scalar) {}
499 
501  template <typename U>
502  explicit Vector(Vector<U,0> const & other) {}
503 
505  bool operator==(Vector const & other) const { return true; }
506 
508  bool operator!=(Vector const & other) const { return false; }
509 
511  T sum() const { return 0; }
512 
514  T product() const { return 1; }
515 
517  Vector reverse() const { return Vector(); }
518 
519 };
520 
521 
523 template <typename T, int N, int M>
524 inline Vector<T,N+M> concatenate(Vector<T,N> const & a, Vector<T,M> const & b) {
525  Vector<T,N+M> r;
526  std::copy(a.begin(),a.end(),r.begin());
527  std::copy(b.begin(),b.end(),r.begin()+N);
528  return r;
529 }
530 
532 template <typename T, int N>
533 inline Vector<T,N+1> concatenate(Vector<T,N> const & a, T const & b) {
534  Vector<T,N+1> r;
535  std::copy(a.begin(),a.end(),r.begin());
536  r[N] = b;
537  return r;
538 }
539 
541 template <typename T, int N>
542 inline Vector<T,N+1> concatenate(T const & a, Vector<T,N> const & b) {
543  Vector<T,N+1> r;
544  r[0] = a;
545  std::copy(b.begin(),b.end(),r.begin()+1);
546  return r;
547 }
548 
549 #ifndef DOXYGEN
550 BOOST_PP_REPEAT_FROM_TO(1, NDARRAY_MAKE_VECTOR_MAX, NDARRAY_MAKE_VECTOR_SPEC, unused)
551 #else
552 
557 template <typename T, int N>
558 Vector<T,N> makeVector(T v1, T v2, ..., T vN);
559 #endif
560 
562 template <typename T, int N>
563 inline Vector<T,N> operator~(Vector<T,N> const & vector) {
564  Vector<T,N> r(vector);
565  for (typename Vector<T,N>::Iterator i = r.begin(); i != r.end(); ++i) (*i) = ~(*i);
566  return r;
567 }
568 
570 template <typename T, int N>
571 inline Vector<T,N> operator!(Vector<T,N> const & vector) {
572  Vector<T,N> r(vector);
573  for (typename Vector<T,N>::Iterator i = r.begin(); i != r.end(); ++i) (*i) = !(*i);
574  return r;
575 }
576 
577 
579  template <typename T, typename U, int N>
580  Vector<typename Promote<T,U>::Type,N>
581  operator +(Vector<T,N> const & a, Vector<U,N> const & b) {
583  return r += b;
584  }
586  template <typename T, typename U, int N>
587  Vector<typename Promote<T,U>::Type,N>
588  operator +(Vector<T,N> const & a, U b) {
590  return r += b;
591  }
593  template <typename T, typename U, int N>
594  Vector<typename Promote<T,U>::Type,N>
595  operator +(U a, Vector<T,N> const & b) {
597  return r += b;
598  }
599 
601  template <typename T, typename U, int N>
602  Vector<typename Promote<T,U>::Type,N>
603  operator -(Vector<T,N> const & a, Vector<U,N> const & b) {
605  return r -= b;
606  }
608  template <typename T, typename U, int N>
609  Vector<typename Promote<T,U>::Type,N>
610  operator -(Vector<T,N> const & a, U b) {
612  return r -= b;
613  }
615  template <typename T, typename U, int N>
616  Vector<typename Promote<T,U>::Type,N>
617  operator -(U a, Vector<T,N> const & b) {
619  return r -= b;
620  }
621 
623  template <typename T, typename U, int N>
624  Vector<typename Promote<T,U>::Type,N>
625  operator *(Vector<T,N> const & a, Vector<U,N> const & b) {
627  return r *= b;
628  }
630  template <typename T, typename U, int N>
631  Vector<typename Promote<T,U>::Type,N>
632  operator *(Vector<T,N> const & a, U b) {
634  return r *= b;
635  }
637  template <typename T, typename U, int N>
638  Vector<typename Promote<T,U>::Type,N>
639  operator *(U a, Vector<T,N> const & b) {
641  return r *= b;
642  }
643 
645  template <typename T, typename U, int N>
646  Vector<typename Promote<T,U>::Type,N>
647  operator /(Vector<T,N> const & a, Vector<U,N> const & b) {
649  return r /= b;
650  }
652  template <typename T, typename U, int N>
653  Vector<typename Promote<T,U>::Type,N>
654  operator /(Vector<T,N> const & a, U b) {
656  return r /= b;
657  }
659  template <typename T, typename U, int N>
660  Vector<typename Promote<T,U>::Type,N>
661  operator /(U a, Vector<T,N> const & b) {
663  return r /= b;
664  }
665 
667  template <typename T, typename U, int N>
668  Vector<typename Promote<T,U>::Type,N>
669  operator %(Vector<T,N> const & a, Vector<U,N> const & b) {
671  return r %= b;
672  }
674  template <typename T, typename U, int N>
675  Vector<typename Promote<T,U>::Type,N>
676  operator %(Vector<T,N> const & a, U b) {
678  return r %= b;
679  }
681  template <typename T, typename U, int N>
682  Vector<typename Promote<T,U>::Type,N>
683  operator %(U a, Vector<T,N> const & b) {
685  return r %= b;
686  }
687 
689  template <typename T, typename U, int N>
690  Vector<typename Promote<T,U>::Type,N>
691  operator &(Vector<T,N> const & a, Vector<U,N> const & b) {
693  return r &= b;
694  }
696  template <typename T, typename U, int N>
697  Vector<typename Promote<T,U>::Type,N>
698  operator &(Vector<T,N> const & a, U b) {
700  return r &= b;
701  }
703  template <typename T, typename U, int N>
704  Vector<typename Promote<T,U>::Type,N>
705  operator &(U a, Vector<T,N> const & b) {
707  return r &= b;
708  }
709 
711  template <typename T, typename U, int N>
712  Vector<typename Promote<T,U>::Type,N>
713  operator ^(Vector<T,N> const & a, Vector<U,N> const & b) {
715  return r ^= b;
716  }
718  template <typename T, typename U, int N>
719  Vector<typename Promote<T,U>::Type,N>
720  operator ^(Vector<T,N> const & a, U b) {
722  return r ^= b;
723  }
725  template <typename T, typename U, int N>
726  Vector<typename Promote<T,U>::Type,N>
727  operator ^(U a, Vector<T,N> const & b) {
729  return r ^= b;
730  }
731 
733  template <typename T, typename U, int N>
734  Vector<typename Promote<T,U>::Type,N>
735  operator |(Vector<T,N> const & a, Vector<U,N> const & b) {
737  return r |= b;
738  }
740  template <typename T, typename U, int N>
741  Vector<typename Promote<T,U>::Type,N>
742  operator |(Vector<T,N> const & a, U b) {
744  return r |= b;
745  }
747  template <typename T, typename U, int N>
748  Vector<typename Promote<T,U>::Type,N>
749  operator |(U a, Vector<T,N> const & b) {
751  return r |= b;
752  }
753 
755  template <typename T, typename U, int N>
756  Vector<typename Promote<T,U>::Type,N>
757  operator <<(Vector<T,N> const & a, Vector<U,N> const & b) {
759  return r <<= b;
760  }
762  template <typename T, typename U, int N>
763  Vector<typename Promote<T,U>::Type,N>
764  operator <<(Vector<T,N> const & a, U b) {
766  return r <<= b;
767  }
769  template <typename T, typename U, int N>
770  Vector<typename Promote<T,U>::Type,N>
771  operator <<(U a, Vector<T,N> const & b) {
773  return r <<= b;
774  }
775 
777  template <typename T, typename U, int N>
778  Vector<typename Promote<T,U>::Type,N>
779  operator >>(Vector<T,N> const & a, Vector<U,N> const & b) {
781  return r >>= b;
782  }
784  template <typename T, typename U, int N>
785  Vector<typename Promote<T,U>::Type,N>
786  operator >>(Vector<T,N> const & a, U b) {
788  return r >>= b;
789  }
791  template <typename T, typename U, int N>
792  Vector<typename Promote<T,U>::Type,N>
793  operator >>(U a, Vector<T,N> const & b) {
795  return r >>= b;
796  }
797 
799 
800 } // namespace ndarray
801 
802 #endif // !NDARRAY_Vector_h_INCLUDED
Vector()
Default constructor.
Definition: Vector.h:184
< unspecified-expression-type > operator-(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:408
Iterator iterator
Definition: Vector.h:103
ConstReference const_reference
Definition: Vector.h:106
iterator end()
Return an iterator to the end of the Vector.
Definition: Vector.h:442
size_type size() const
Return the size of the Vector.
Definition: Vector.h:434
Vector< T, M > first() const
Create a new Vector from the first M elements of this.
Definition: Vector.h:475
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator|=(Vector< U, N > const &other)
Augmented |= assignment from another vector.
Definition: Vector.h:361
Vector< T, M > last() const
Create a new Vector from the last M elements of this.
Definition: Vector.h:480
bool operator==(Vector const &other) const
Return true if elements of other are equal to the elements of this.
Definition: Vector.h:505
ConstIterator const_iterator
Definition: Vector.h:104
size_type max_size() const
Return the size of the Vector.
Definition: Vector.h:117
const_reference operator[](int i) const
Return a const_reference to the element with the given index.
Definition: Vector.h:148
reference operator[](int i)
Return a reference to the element with the given index.
Definition: Vector.h:146
bool operator!=(Vector const &other) const
Return false if any elements of other are not equal to the elements of this.
Definition: Vector.h:508
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator=(Vector< U, N > const &other)
Augmented = assignment from another vector.
Definition: Vector.h:233
bool operator==(Vector const &other) const
Return true if elements of other are equal to the elements of this.
Definition: Vector.h:199
< unspecified-expression-type > operator~(ExpressionBase< Operand > const &operand)
Definition: operators.h:1158
< unspecified-expression-type > operator/(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:494
T product() const
Return the product of all elements.
Definition: Vector.h:514
T const & ConstReference
Definition: Vector.h:98
reference front()
Return a reference to the first element.
Definition: Vector.h:455
Vector(U scalar)
Construct with copies of a scalar.
Definition: Vector.h:188
const_iterator begin() const
Return a const_iterator to the beginning of the Vector.
Definition: Vector.h:122
int difference_type
Definition: Vector.h:110
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator*=(Vector< U, N > const &other)
Augmented *= assignment from another vector.
Definition: Vector.h:281
reverse_iterator rend()
Return a reverse_iterator to the end of the reversed Vector.
Definition: Vector.h:450
SelectEigenView< T >::Type copy(Eigen::EigenBase< T > const &other)
Copy an arbitrary Eigen expression into a new EigenView.
Definition: eigen.h:390
boost::reverse_iterator< T * > reverse_iterator
Definition: Vector.h:425
reference back()
Return a reference to the last element.
Definition: Vector.h:457
const_reference operator[](int i) const
Return a const_reference to the element with the given index.
Definition: Vector.h:466
const_reverse_iterator rend() const
Return a const_reverse_iterator to the end of the reversed Vector.
Definition: Vector.h:134
T sum() const
Return the sum of all elements.
Definition: Vector.h:511
reverse_iterator rend()
Return a reverse_iterator to the end of the reversed Vector.
Definition: Vector.h:132
Vector()
Default constructor.
Definition: Vector.h:494
< unspecified-expression-type > operator+(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:365
Vector reverse() const
Return a Vector with the elements reversed.
Definition: Vector.h:223
reference back()
Return a reference to the last element.
Definition: Vector.h:139
Reference reference
Definition: Vector.h:105
Forward declarations and default template parameters for ndarray.
bool empty() const
Return true if size() == 0.
Definition: Vector.h:436
T product() const
Return the product of all elements.
Definition: Vector.h:216
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator&=(Vector< U, N > const &other)
Augmented &amp;= assignment from another vector.
Definition: Vector.h:329
#define NDARRAY_ASSERT(ARG)
Definition: ndarray_fwd.h:51
Vector< T, Stop-Start > getRange() const
Create a new Vector that is a subset of this.
Definition: Vector.h:470
T * Iterator
Definition: Vector.h:99
ConstIterator const_iterator
Definition: Vector.h:422
ConstReference const_reference
Definition: Vector.h:424
Value value_type
Definition: Vector.h:102
A fixed-size 1D array class.
Definition: Vector.h:93
T const * ConstIterator
Definition: Vector.h:100
bool empty() const
Return true if size() == 0.
Definition: Vector.h:118
reference operator[](int i)
Return a reference to the element with the given index.
Definition: Vector.h:464
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator-=(Vector< U, N > const &other)
Augmented -= assignment from another vector.
Definition: Vector.h:265
Numeric type traits.
bool operator!=(Vector const &other) const
Return false if any elements of other are not equal to the elements of this.
Definition: Vector.h:204
Vector< T, M > last() const
Create a new Vector from the last M elements of this.
Definition: Vector.h:166
boost::reverse_iterator< const T * > const_reverse_iterator
Definition: Vector.h:426
iterator begin()
Return an iterator to the beginning of the Vector.
Definition: Vector.h:120
const_reference front() const
Return a const_reference to the first element.
Definition: Vector.h:459
Vector< T, N > operator!(Vector< T, N > const &vector)
Unary negation for Vector.
Definition: Vector.h:571
Reference reference
Definition: Vector.h:423
const_reverse_iterator rbegin() const
Return a const_reverse_iterator to the beginning of the reversed Vector.
Definition: Vector.h:448
Vector< T, N > makeVector(T v1, T v2,..., T vN)
Variadic constructor for Vector.
T const & ConstReference
Definition: Vector.h:416
const_reverse_iterator rbegin() const
Return a const_reverse_iterator to the beginning of the reversed Vector.
Definition: Vector.h:130
< unspecified-expression-type > operator*(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:451
const_reverse_iterator rend() const
Return a const_reverse_iterator to the end of the reversed Vector.
Definition: Vector.h:452
Vector< T, M > first() const
Create a new Vector from the first M elements of this.
Definition: Vector.h:159
< unspecified-expression-type > operator^(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:580
< unspecified-expression-type > operator%(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:537
const_reference back() const
Return a const_reference to the last element.
Definition: Vector.h:143
iterator end()
Return an iterator to the end of the Vector.
Definition: Vector.h:124
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator/=(Vector< U, N > const &other)
Augmented /= assignment from another vector.
Definition: Vector.h:297
boost::reverse_iterator< const T * > const_reverse_iterator
Definition: Vector.h:108
Vector(Vector< U, 0 > const &other)
Converting copy constructor.
Definition: Vector.h:502
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator>>=(Vector< U, N > const &other)
Augmented &gt;&gt;= assignment from another vector.
Definition: Vector.h:393
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator^=(Vector< U, N > const &other)
Augmented ^= assignment from another vector.
Definition: Vector.h:345
< unspecified-expression-type > equal(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:796
reverse_iterator rbegin()
Return a reverse_iterator to the beginning of the reversed Vector.
Definition: Vector.h:128
const_reference front() const
Return a const_reference to the first element.
Definition: Vector.h:141
< unspecified-expression-type > operator&(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:666
afw::table::Key< double > b
size_type size() const
Return the size of the Vector.
Definition: Vector.h:116
const_iterator end() const
Return a const_iterator to the end of the Vector.
Definition: Vector.h:126
T & Reference
Definition: Vector.h:97
Vector< T, Stop-Start > getRange() const
Create a new Vector that is a subset of this.
Definition: Vector.h:152
T const * ConstIterator
Definition: Vector.h:418
Vector(Vector< U, N > const &other)
Converting copy constructor.
Definition: Vector.h:194
const_iterator begin() const
Return a const_iterator to the beginning of the Vector.
Definition: Vector.h:440
const_iterator end() const
Return a const_iterator to the end of the Vector.
Definition: Vector.h:444
const_reference back() const
Return a const_reference to the last element.
Definition: Vector.h:461
boost::reverse_iterator< T * > reverse_iterator
Definition: Vector.h:107
boost::mpl::int_< N > ND
Definition: Vector.h:114
reference front()
Return a reference to the first element.
Definition: Vector.h:137
Vector< T, N+M > concatenate(Vector< T, N > const &a, Vector< T, M > const &b)
Concatenate two Vectors into a single long Vector.
Definition: Vector.h:524
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator%=(Vector< U, N > const &other)
Augmented %= assignment from another vector.
Definition: Vector.h:313
Vector(U scalar)
Construct with copies of a scalar.
Definition: Vector.h:498
< unspecified-expression-type > operator|(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:623
T sum() const
Return the sum of all elements.
Definition: Vector.h:209
size_type max_size() const
Return the size of the Vector.
Definition: Vector.h:435
reverse_iterator rbegin()
Return a reverse_iterator to the beginning of the reversed Vector.
Definition: Vector.h:446
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator<<=(Vector< U, N > const &other)
Augmented &lt;&lt;= assignment from another vector.
Definition: Vector.h:377
Vector reverse() const
Return a Vector with the elements reversed.
Definition: Vector.h:517
< unspecified-expression-type > operator>>(ExpressionBase< Operand > const &operand, Scalar const &scalar)
Definition: operators.h:752
boost::mpl::int_< 0 > ND
Definition: Vector.h:432
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator+=(Vector< U, N > const &other)
Augmented += assignment from another vector.
Definition: Vector.h:249