Developer Documentation
Vector11T.hh
1 /* ========================================================================= *
2  * *
3  * OPENVOLUMEMESHMesh *
4  * Copyright (c) 2001-2016, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.OPENVOLUMEMESHmesh.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OPENVOLUMEMESHMesh. *
11  * This file was originally taken from OpenMesh *
12  *---------------------------------------------------------------------------*
13  * *
14  * Redistribution and use in source and binary forms, with or without *
15  * modification, are permitted provided that the following conditions *
16  * are met: *
17  * *
18  * 1. Redistributions of source code must retain the above copyright notice, *
19  * this list of conditions and the following disclaimer. *
20  * *
21  * 2. Redistributions in binary form must reproduce the above copyright *
22  * notice, this list of conditions and the following disclaimer in the *
23  * documentation and/or other materials provided with the distribution. *
24  * *
25  * 3. Neither the name of the copyright holder nor the names of its *
26  * contributors may be used to endorse or promote products derived from *
27  * this software without specific prior written permission. *
28  * *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
31  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
32  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
33  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
34  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
35  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
36  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
37  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
38  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
39  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
40  * *
41  * ========================================================================= */
42 
43 #ifndef OPENVOLUMEMESH_SRC_OPENVOLUMEMESH_GEOMETRY_VECTOR11T_HH_
44 #define OPENVOLUMEMESH_SRC_OPENVOLUMEMESH_GEOMETRY_VECTOR11T_HH_
45 
46 #include <array>
47 #include <utility>
48 #include <algorithm>
49 #include <numeric>
50 #include <type_traits>
51 #include <cmath>
52 #include <ostream>
53 #include <istream>
54 #include <cassert>
55 #include <cstdlib>
56 
57 #include "OpenVolumeMesh/Config/Export.hh"
58 
59 namespace OpenVolumeMesh {
60 
61 namespace Geometry {
62 
63 /*
64  * Helpers for VectorT
65  */
66 template<typename ... Ts>
68 
69 template<typename To, typename From, typename ... Froms>
70 struct are_convertible_to<To, From, Froms...> {
71  static constexpr bool value = std::is_convertible<From, To>::value
72  && are_convertible_to<To, Froms...>::value;
73 };
74 
75 template<typename To, typename From>
76 struct are_convertible_to<To, From> : public std::is_convertible<From, To> {
77 };
78 
79 template<typename Scalar, int DIM>
80 class VectorT {
81 
82  static_assert(DIM >= 1, "VectorT requires positive dimensionality.");
83 
84  private:
85  using container = std::array<Scalar, DIM>;
86  container values_;
87 
88  public:
89 
90  //---------------------------------------------------------------- class info
91 
93  typedef Scalar value_type;
94 
97 
99  static constexpr int dim() {
100  return DIM;
101  }
102 
104  static constexpr size_t size() {
105  return DIM;
106  }
107 
108  static constexpr const size_t size_ = DIM;
109 
110  //-------------------------------------------------------------- constructors
111 
113  constexpr VectorT() {}
114 
118  explicit VectorT(const Scalar &v) {
119  vectorize(v);
120  }
121 
122  template<typename ... T,
123  typename = typename std::enable_if<sizeof...(T) == DIM>::type,
124  typename = typename std::enable_if<
126  // cppcheck-suppress noExplicitConstructor ; only applies to unimportant DIM==1
127  constexpr VectorT(T... vs) : values_ { {static_cast<Scalar>(vs)...} }
128  {
129  static_assert(sizeof...(T) == DIM,
130  "Invalid number of components specified in constructor.");
132  "Not all components are convertible to Scalar.");
133  }
134 
135  VectorT(const VectorT &rhs) = default;
136  VectorT(VectorT &&rhs) = default;
137  VectorT &operator=(const VectorT &rhs) = default;
138  VectorT &operator=(VectorT &&rhs) = default;
139 
144  template<typename S = Scalar, int D = DIM>
145  auto homogenized() const ->
146  typename std::enable_if<D == 4,
147  VectorT<decltype(std::declval<S>()/std::declval<S>()), DIM>>::type {
148  static_assert(D == DIM, "D and DIM need to be identical. (Never "
149  "override the default template arguments.)");
150  static_assert(std::is_same<S, Scalar>::value, "S and Scalar need "
151  "to be the same type. (Never override the default template "
152  "arguments.)");
153  return VectorT(
154  values_[0]/values_[3],
155  values_[1]/values_[3],
156  values_[2]/values_[3],
157  1);
158  }
159 
161  template<typename Iterator,
162  typename = decltype(
163  *std::declval<Iterator&>(), void(),
164  ++std::declval<Iterator&>(), void())>
165  explicit VectorT(Iterator it) {
166  std::copy_n(it, DIM, values_.begin());
167  }
168 
170  template<typename otherScalarType,
171  typename = typename std::enable_if<
172  std::is_convertible<otherScalarType, Scalar>::value>>
173  explicit VectorT(const VectorT<otherScalarType, DIM>& _rhs) {
174  operator=(_rhs);
175  }
176 
177  //--------------------------------------------------------------------- casts
178 
180  template<typename OtherScalar,
181  typename = typename std::enable_if<
182  std::is_convertible<OtherScalar, Scalar>::value>>
183  // cppcheck-suppress operatorEqRetRefThis ; false positive
184  vector_type& operator=(const VectorT<OtherScalar, DIM>& _rhs)
185  {
186  std::transform(_rhs.data(), _rhs.data() + DIM,
187  data(), [](OtherScalar rhs) {
188  return static_cast<Scalar>(std::move(rhs));
189  });
190  return *this;
191  }
192 
194  Scalar* data() { return values_.data(); }
195 
197  const Scalar *data() const { return values_.data(); }
198 
199  //----------------------------------------------------------- element access
200 
202  Scalar& operator[](size_t _i) {
203  assert(_i < DIM);
204  return values_[_i];
205  }
206 
208  const Scalar& operator[](size_t _i) const {
209  assert(_i < DIM);
210  return values_[_i];
211  }
212 
213  //---------------------------------------------------------------- comparsion
214 
216  bool operator==(const vector_type& _rhs) const {
217  return std::equal(_rhs.values_.cbegin(), _rhs.values_.cend(), values_.cbegin());
218  }
219 
221  bool operator!=(const vector_type& _rhs) const {
222  return !std::equal(_rhs.values_.cbegin(), _rhs.values_.cend(), values_.cbegin());
223  }
224 
225  //---------------------------------------------------------- scalar operators
226 
228  template<typename OtherScalar>
229  auto operator*=(const OtherScalar& _s) ->
230  typename std::enable_if<std::is_convertible<
231  decltype(this->values_[0] * _s), Scalar>::value,
232  VectorT<Scalar, DIM>&>::type {
233  for (auto& e : *this) {
234  e *= _s;
235  }
236  return *this;
237  }
238 
240  template<typename OtherScalar>
241  auto operator/=(const OtherScalar& _s) ->
242  typename std::enable_if<std::is_convertible<
243  decltype(this->values_[0] / _s), Scalar>::value,
244  VectorT<Scalar, DIM>&>::type {
245  for (auto& e : *this) {
246  e /= _s;
247  }
248  return *this;
249  }
250 
252  template<typename OtherScalar>
253  typename std::enable_if<std::is_convertible<
254  decltype(std::declval<Scalar>() * std::declval<OtherScalar>()),
255  Scalar>::value,
256  VectorT<Scalar, DIM>>::type
257  operator*(const OtherScalar& _s) const {
258  return vector_type(*this) *= _s;
259  }
260 
262  template<typename OtherScalar>
263  typename std::enable_if<std::is_convertible<
264  decltype(std::declval<Scalar>() / std::declval<OtherScalar>()),
265  Scalar>::value,
266  VectorT<Scalar, DIM>>::type
267  operator/(const OtherScalar& _s) const {
268  return vector_type(*this) /= _s;
269  }
270 
271  //---------------------------------------------------------- vector operators
272 
274  template<typename OtherScalar>
275  auto operator*=(const VectorT<OtherScalar, DIM>& _rhs) ->
276  typename std::enable_if<
277  sizeof(decltype(this->values_[0] * *_rhs.data())) >= 0,
278  vector_type&>::type {
279  for (int i = 0; i < DIM; ++i) {
280  data()[i] *= _rhs.data()[i];
281  }
282  return *this;
283  }
284 
286  template<typename OtherScalar>
287  auto operator/=(const VectorT<OtherScalar, DIM>& _rhs) ->
288  typename std::enable_if<
289  sizeof(decltype(this->values_[0] / *_rhs.data())) >= 0,
290  vector_type&>::type {
291  for (int i = 0; i < DIM; ++i) {
292  data()[i] /= _rhs.data()[i];
293  }
294  return *this;
295  }
296 
298  template<typename OtherScalar>
299  auto operator-=(const VectorT<OtherScalar, DIM>& _rhs) ->
300  typename std::enable_if<
301  sizeof(decltype(this->values_[0] - *_rhs.data())) >= 0,
302  vector_type&>::type {
303  for (int i = 0; i < DIM; ++i) {
304  data()[i] -= _rhs.data()[i];
305  }
306  return *this;
307  }
308 
310  template<typename OtherScalar>
311  auto operator+=(const VectorT<OtherScalar, DIM>& _rhs) ->
312  typename std::enable_if<
313  sizeof(decltype(this->values_[0] + *_rhs.data())) >= 0,
314  vector_type&>::type {
315  for (int i = 0; i < DIM; ++i) {
316  data()[i] += _rhs.data()[i];
317  }
318  return *this;
319  }
320 
322  template<typename OtherScalar>
323  auto operator*(const VectorT<OtherScalar, DIM>& _rhs) const ->
324  typename std::enable_if<
325  sizeof(decltype(this->values_[0] * *_rhs.data())) >= 0,
326  vector_type>::type {
327  return vector_type(*this) *= _rhs;
328  }
329 
331  template<typename OtherScalar>
332  auto operator/(const VectorT<OtherScalar, DIM>& _rhs) const ->
333  typename std::enable_if<
334  sizeof(decltype(this->values_[0] / *_rhs.data())) >= 0,
335  vector_type>::type {
336  return vector_type(*this) /= _rhs;
337  }
338 
340  template<typename OtherScalar>
341  auto operator+(const VectorT<OtherScalar, DIM>& _rhs) const ->
342  typename std::enable_if<
343  sizeof(decltype(this->values_[0] + *_rhs.data())) >= 0,
344  vector_type>::type {
345  return vector_type(*this) += _rhs;
346  }
347 
349  template<typename OtherScalar>
350  auto operator-(const VectorT<OtherScalar, DIM>& _rhs) const ->
351  typename std::enable_if<
352  sizeof(decltype(this->values_[0] - *_rhs.data())) >= 0,
353  vector_type>::type {
354  return vector_type(*this) -= _rhs;
355  }
356 
358  vector_type operator-(void) const {
359  vector_type v;
360  std::transform(values_.begin(), values_.end(), v.values_.begin(),
361  [](const Scalar &s) { return -s; });
362  return v;
363  }
364 
367  template<typename OtherScalar>
368  auto operator% (const VectorT<OtherScalar, DIM> &_rhs) const ->
369  typename std::enable_if<DIM == 3,
370  VectorT<decltype(this->values_[0] * _rhs[0] -
371  this->values_[0] * _rhs[0]),
372  DIM>>::type {
373  return {
374  values_[1] * _rhs[2] - values_[2] * _rhs[1],
375  values_[2] * _rhs[0] - values_[0] * _rhs[2],
376  values_[0] * _rhs[1] - values_[1] * _rhs[0]
377  };
378  }
379 
382  template<typename OtherScalar>
383  auto cross (const VectorT<OtherScalar, DIM> &_rhs) const ->
384  decltype(*this % _rhs)
385  {
386  return *this % _rhs;
387  }
388 
391  template<typename OtherScalar>
392  auto operator|(const VectorT<OtherScalar, DIM>& _rhs) const ->
393  decltype(*this->data() * *_rhs.data()) {
394 
395  return std::inner_product(data() + 1, data() + DIM, _rhs.data() + 1,
396  *data() * *_rhs.data());
397  }
398 
401  template<typename OtherScalar>
402  auto dot(const VectorT<OtherScalar, DIM>& _rhs) const ->
403  decltype(*this | _rhs)
404  {
405  return *this | _rhs;
406  }
407 
408  //------------------------------------------------------------ euclidean norm
409 
411 
412 
414  template<typename S = Scalar>
415  decltype(std::declval<S>() * std::declval<S>()) sqrnorm() const {
416  static_assert(std::is_same<S, Scalar>::value, "S and Scalar need "
417  "to be the same type. (Never override the default template "
418  "arguments.)");
419  typedef decltype(values_[0] * values_[0]) RESULT;
420  return std::accumulate(values_.cbegin() + 1, values_.cend(),
421  values_[0] * values_[0],
422  [](const RESULT &l, const Scalar &r) { return l + r * r; });
423  }
424 
426  template<typename S = Scalar>
427  auto norm() const ->
428  decltype(std::sqrt(std::declval<VectorT<S, DIM>>().sqrnorm())) {
429  static_assert(std::is_same<S, Scalar>::value, "S and Scalar need "
430  "to be the same type. (Never override the default template "
431  "arguments.)");
432  return std::sqrt(sqrnorm());
433  }
434 
435  template<typename S = Scalar>
436  auto length() const ->
437  decltype(std::declval<VectorT<S, DIM>>().norm()) {
438  static_assert(std::is_same<S, Scalar>::value, "S and Scalar need "
439  "to be the same type. (Never override the default template "
440  "arguments.)");
441  return norm();
442  }
443 
446  template<typename S = Scalar>
447  auto normalize() ->
448  decltype(*this /= std::declval<VectorT<S, DIM>>().norm()) {
449  static_assert(std::is_same<S, Scalar>::value, "S and Scalar need "
450  "to be the same type. (Never override the default template "
451  "arguments.)");
452  return *this /= norm();
453  }
454 
457  template<typename S = Scalar>
458  auto normalized() const ->
459  decltype(*this / std::declval<VectorT<S, DIM>>().norm()) {
460  static_assert(std::is_same<S, Scalar>::value, "S and Scalar need "
461  "to be the same type. (Never override the default template "
462  "arguments.)");
463  return *this / norm();
464  }
465 
468  template<typename S = Scalar>
469  typename std::enable_if<
470  sizeof(decltype(
471  static_cast<S>(0),
472  std::declval<VectorT<S, DIM>>().norm())) >= 0,
473  vector_type&>::type
475  static_assert(std::is_same<S, Scalar>::value, "S and Scalar need "
476  "to be the same type. (Never override the default template "
477  "arguments.)");
478  auto n = norm();
479  if (n != static_cast<decltype(norm())>(0)) {
480  *this /= n;
481  }
482  return *this;
483  }
484 
486 
487  //------------------------------------------------------------ euclidean norm
488 
490 
491 
493  Scalar l1_norm() const {
494  return std::accumulate(
495  values_.cbegin() + 1, values_.cend(), values_[0]);
496  }
497 
499  Scalar l8_norm() const {
500  return max_abs();
501  }
502 
504 
505  //------------------------------------------------------------ max, min, mean
506 
508 
509 
511  Scalar max() const {
512  return *std::max_element(values_.cbegin(), values_.cend());
513  }
514 
516  Scalar max_abs() const {
517  return std::abs(
518  *std::max_element(values_.cbegin(), values_.cend(),
519  [](const Scalar &a, const Scalar &b) {
520  return std::abs(a) < std::abs(b);
521  }));
522  }
523 
525  Scalar min() const {
526  return *std::min_element(values_.cbegin(), values_.cend());
527  }
528 
530  Scalar min_abs() const {
531  return std::abs(
532  *std::min_element(values_.cbegin(), values_.cend(),
533  [](const Scalar &a, const Scalar &b) {
534  return std::abs(a) < std::abs(b);
535  }));
536  }
537 
539  Scalar mean() const {
540  return l1_norm()/DIM;
541  }
542 
544  Scalar mean_abs() const {
545  return std::accumulate(values_.cbegin() + 1, values_.cend(),
546  std::abs(values_[0]),
547  [](const Scalar &l, const Scalar &r) {
548  return l + std::abs(r);
549  }) / DIM;
550  }
551 
553  vector_type& minimize(const vector_type& _rhs) {
554  std::transform(values_.cbegin(), values_.cend(),
555  _rhs.values_.cbegin(),
556  values_.begin(),
557  [](const Scalar &l, const Scalar &r) {
558  return std::min(l, r);
559  });
560  return *this;
561  }
562 
564  bool minimized(const vector_type& _rhs) {
565  bool result = false;
566  std::transform(values_.cbegin(), values_.cend(),
567  _rhs.values_.cbegin(),
568  values_.begin(),
569  [&result](const Scalar &l, const Scalar &r) {
570  if (l < r) {
571  return l;
572  } else {
573  result = true;
574  return r;
575  }
576  });
577  return result;
578  }
579 
581  vector_type& maximize(const vector_type& _rhs) {
582  std::transform(values_.cbegin(), values_.cend(),
583  _rhs.values_.cbegin(),
584  values_.begin(),
585  [](const Scalar &l, const Scalar &r) {
586  return std::max(l, r);
587  });
588  return *this;
589  }
590 
592  bool maximized(const vector_type& _rhs) {
593  bool result = false;
594  std::transform(values_.cbegin(), values_.cend(),
595  _rhs.values_.cbegin(),
596  values_.begin(),
597  [&result](const Scalar &l, const Scalar &r) {
598  if (l > r) {
599  return l;
600  } else {
601  result = true;
602  return r;
603  }
604  });
605  return result;
606  }
607 
609  inline vector_type min(const vector_type& _rhs) const {
610  return vector_type(*this).minimize(_rhs);
611  }
612 
614  inline vector_type max(const vector_type& _rhs) const {
615  return vector_type(*this).maximize(_rhs);
616  }
617 
619 
620  //------------------------------------------------------------ misc functions
621 
623  template<typename Functor>
624  inline vector_type apply(const Functor& _func) const {
625  vector_type result;
626  std::transform(result.values_.begin(), result.values_.end(),
627  result.values_.begin(), _func);
628  return result;
629  }
630 
632  vector_type& vectorize(const Scalar& _s) {
633  std::fill(values_.begin(), values_.end(), _s);
634  return *this;
635  }
636 
638  static vector_type vectorized(const Scalar& _s) {
639  return vector_type().vectorize(_s);
640  }
641 
643  bool operator<(const vector_type& _rhs) const {
644  return std::lexicographical_compare(
645  values_.begin(), values_.end(),
646  _rhs.values_.begin(), _rhs.values_.end());
647  }
648 
650  void swap(VectorT& _other)
651  noexcept(noexcept(std::swap(values_, _other.values_))) {
652  std::swap(values_, _other.values_);
653  }
654 
655  //------------------------------------------------------------ component iterators
656 
658 
659 
660  using iterator = typename container::iterator;
661  using const_iterator = typename container::const_iterator;
662  using reverse_iterator = typename container::reverse_iterator;
663  using const_reverse_iterator = typename container::const_reverse_iterator;
664 
665  iterator begin() noexcept { return values_.begin(); }
666  const_iterator begin() const noexcept { return values_.cbegin(); }
667  const_iterator cbegin() const noexcept { return values_.cbegin(); }
668 
669  iterator end() noexcept { return values_.end(); }
670  const_iterator end() const noexcept { return values_.cend(); }
671  const_iterator cend() const noexcept { return values_.cend(); }
672 
673  reverse_iterator rbegin() noexcept { return values_.rbegin(); }
674  const_reverse_iterator rbegin() const noexcept { return values_.crbegin(); }
675  const_reverse_iterator crbegin() const noexcept { return values_.crbegin(); }
676 
677  reverse_iterator rend() noexcept { return values_.rend(); }
678  const_reverse_iterator rend() const noexcept { return values_.crend(); }
679  const_reverse_iterator crend() const noexcept { return values_.crend(); }
680 
682 };
683 
685 template<typename Scalar, int DIM, typename OtherScalar>
686 auto operator*(const OtherScalar& _s, const VectorT<Scalar, DIM> &rhs) ->
687  decltype(rhs.operator*(_s)) {
688 
689  return rhs * _s;
690 }
691 
693 template<typename Scalar, int DIM>
694 auto operator<<(std::ostream& os, const VectorT<Scalar, DIM> &_vec) ->
695  typename std::enable_if<
696  sizeof(decltype(os << _vec[0])) >= 0, std::ostream&>::type {
697 
698  os << _vec[0];
699  for (size_t i = 1; i < DIM; ++i) {
700  os << " " << _vec[i];
701  }
702  return os;
703 }
704 
706 template<typename Scalar, int DIM>
707 auto operator>> (std::istream& is, VectorT<Scalar, DIM> &_vec) ->
708  typename std::enable_if<
709  sizeof(decltype(is >> _vec[0])) >= 0, std::istream &>::type {
710  for (size_t i = 0; i < DIM; ++i)
711  is >> _vec[i];
712  return is;
713 }
714 
717 template<typename Scalar, int DIM>
718 Scalar dot(const VectorT<Scalar, DIM>& _v1, const VectorT<Scalar, DIM>& _v2) {
719  return (_v1 | _v2);
720 }
721 
724 template<typename LScalar, typename RScalar, int DIM>
725 auto
726 cross(const VectorT<LScalar, DIM>& _v1, const VectorT<RScalar, DIM>& _v2) ->
727  decltype(_v1 % _v2) {
728  return (_v1 % _v2);
729 }
730 
733 template<typename Scalar, int DIM>
734 void swap(VectorT<Scalar, DIM>& _v1, VectorT<Scalar, DIM>& _v2)
735 noexcept(noexcept(_v1.swap(_v2))) {
736  _v1.swap(_v2);
737 }
738 
739 //== TYPEDEFS =================================================================
740 
754 typedef VectorT<float,1> Vec1f;
756 typedef VectorT<double,1> Vec1d;
757 
771 typedef VectorT<float,2> Vec2f;
773 typedef VectorT<double,2> Vec2d;
774 
788 typedef VectorT<float,3> Vec3f;
790 typedef VectorT<double,3> Vec3d;
792 typedef VectorT<bool,3> Vec3b;
793 
807 typedef VectorT<float,4> Vec4f;
809 typedef VectorT<double,4> Vec4d;
810 
824 typedef VectorT<float, 5> Vec5f;
826 typedef VectorT<double, 5> Vec5d;
827 
841 typedef VectorT<float,6> Vec6f;
843 typedef VectorT<double,6> Vec6d;
844 
845 
846 } // namespace Geometry
847 
848 using namespace Geometry;
849 
850 template <class T>
851 const std::string typeName();
852 
853 template <> OVM_EXPORT const std::string typeName<Vec2f>();
854 template <> OVM_EXPORT const std::string typeName<Vec2d>();
855 template <> OVM_EXPORT const std::string typeName<Vec2i>();
856 template <> OVM_EXPORT const std::string typeName<Vec2ui>();
857 
858 template <> OVM_EXPORT const std::string typeName<Vec3f>();
859 template <> OVM_EXPORT const std::string typeName<Vec3d>();
860 template <> OVM_EXPORT const std::string typeName<Vec3i>();
861 template <> OVM_EXPORT const std::string typeName<Vec3ui>();
862 
863 template <> OVM_EXPORT const std::string typeName<Vec4f>();
864 template <> OVM_EXPORT const std::string typeName<Vec4d>();
865 template <> OVM_EXPORT const std::string typeName<Vec4i>();
866 template <> OVM_EXPORT const std::string typeName<Vec4ui>();
867 
868 } // namespace OpenVolumeMesh
869 
870 
871 #endif /* OPENVOLUMEMESH_SRC_OPENVOLUMEMESH_GEOMETRY_VECTOR11T_HH_ */
static constexpr int dim()
returns dimension of the vector (deprecated)
Definition: Vector11T.hh:99
auto dot(const VectorT< OtherScalar, DIM > &_rhs) const -> decltype(*this|_rhs)
Definition: Vector11T.hh:402
static constexpr size_t size()
returns dimension of the vector
Definition: Vector11T.hh:104
auto length() const -> decltype(std::declval< VectorT< S, DIM >>().norm())
compute squared euclidean norm
Definition: Vector11T.hh:436
vector_type & vectorize(const Scalar &_s)
store the same value in each component (e.g. to clear all entries)
Definition: Vector11T.hh:632
void swap(VectorT &_other) noexcept(noexcept(std::swap(values_, _other.values_)))
swap with another vector
Definition: Vector11T.hh:650
VectorT(Iterator it)
construct from a value array or any other iterator
Definition: Vector11T.hh:165
std::enable_if< std::is_convertible< decltype(std::declval< Scalar >)/std::declval< OtherScalar >)), Scalar >::value, VectorT< Scalar, DIM > >::type operator/(const OtherScalar &_s) const
component-wise division by with scalar
Definition: Vector11T.hh:267
auto operator*=(const OtherScalar &_s) -> typename std::enable_if< std::is_convertible< decltype(this->values_[0] *_s), Scalar >::value, VectorT< Scalar, DIM > &>::type
component-wise self-multiplication with scalar
Definition: Vector11T.hh:229
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
Definition: Vector11T.hh:581
STL namespace.
Scalar * data()
access to Scalar array
Definition: Vector11T.hh:194
auto cross(const VectorT< OtherScalar, DIM > &_rhs) const -> decltype(*this % _rhs)
Definition: Vector11T.hh:383
std::enable_if< std::is_convertible< decltype(std::declval< Scalar >) *std::declval< OtherScalar >)), Scalar >::value, VectorT< Scalar, DIM > >::type operator*(const OtherScalar &_s) const
component-wise multiplication with scalar
Definition: Vector11T.hh:257
vector_type operator-(void) const
unary minus
Definition: Vector11T.hh:358
const Scalar & operator[](size_t _i) const
get i&#39;th element read-only
Definition: Vector11T.hh:208
Scalar max() const
return the maximal component
Definition: Vector11T.hh:511
auto homogenized() const -> typename std::enable_if< D==4, VectorT< decltype(std::declval< S >()/std::declval< S >()), DIM >>::type
Definition: Vector11T.hh:145
vector_type apply(const Functor &_func) const
component-wise apply function object with Scalar operator()(Scalar).
Definition: Vector11T.hh:624
Scalar l1_norm() const
compute L1 (Manhattan) norm
Definition: Vector11T.hh:493
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
Definition: Vector11T.hh:553
VectorT< Scalar, DIM > vector_type
type of this vector
Definition: Vector11T.hh:96
Scalar mean_abs() const
return absolute arithmetic mean
Definition: Vector11T.hh:544
bool operator!=(const vector_type &_rhs) const
component-wise comparison
Definition: Vector11T.hh:221
static vector_type vectorized(const Scalar &_s)
store the same value in each component
Definition: Vector11T.hh:638
Scalar min() const
return the minimal component
Definition: Vector11T.hh:525
auto operator/=(const OtherScalar &_s) -> typename std::enable_if< std::is_convertible< decltype(this->values_[0]/_s), Scalar >::value, VectorT< Scalar, DIM > &>::type
component-wise self-division by scalar
Definition: Vector11T.hh:241
Scalar value_type
the type of the scalar used in this template
Definition: Vector11T.hh:93
Scalar & operator[](size_t _i)
get i&#39;th element read-write
Definition: Vector11T.hh:202
auto operator|(const VectorT< OtherScalar, DIM > &_rhs) const -> decltype(*this->data() **_rhs.data())
Definition: Vector11T.hh:392
bool operator<(const vector_type &_rhs) const
lexicographical comparison
Definition: Vector11T.hh:643
auto normalized() const -> decltype(*this/std::declval< VectorT< S, DIM >>().norm())
Definition: Vector11T.hh:458
VectorT(const VectorT< otherScalarType, DIM > &_rhs)
copy & cast constructor (explicit)
Definition: Vector11T.hh:173
vector_type & operator=(const VectorT< OtherScalar, DIM > &_rhs)
cast from vector with a different scalar type
Definition: Vector11T.hh:184
auto norm() const -> decltype(std::sqrt(std::declval< VectorT< S, DIM >>().sqrnorm()))
compute euclidean norm
Definition: Vector11T.hh:427
const Scalar * data() const
access to const Scalar array
Definition: Vector11T.hh:197
vector_type min(const vector_type &_rhs) const
component-wise min
Definition: Vector11T.hh:609
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
Definition: Types.cc:154
auto normalize() -> decltype(*this/=std::declval< VectorT< S, DIM >>().norm())
Definition: Vector11T.hh:447
Scalar l8_norm() const
compute l8_norm
Definition: Vector11T.hh:499
bool operator==(const vector_type &_rhs) const
component-wise comparison
Definition: Vector11T.hh:216
constexpr VectorT()
default constructor creates uninitialized values.
Definition: Vector11T.hh:113
bool minimized(const vector_type &_rhs)
minimize values and signalize coordinate minimization
Definition: Vector11T.hh:564
Scalar min_abs() const
return the minimal absolute component
Definition: Vector11T.hh:530
Scalar mean() const
return arithmetic mean
Definition: Vector11T.hh:539
Scalar max_abs() const
return the maximal absolute component
Definition: Vector11T.hh:516
vector_type max(const vector_type &_rhs) const
component-wise max
Definition: Vector11T.hh:614
bool maximized(const vector_type &_rhs)
maximize values and signalize coordinate maximization
Definition: Vector11T.hh:592
vector_type &::type normalize_cond()
compute squared euclidean norm
Definition: Vector11T.hh:474