libMesh
type_vector.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_TYPE_VECTOR_H
21 #define LIBMESH_TYPE_VECTOR_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/compare_types.h"
26 #include "libmesh/tensor_tools.h"
27 
28 // C++ includes
29 #include <cstdlib> // *must* precede <cmath> for proper std:abs() on PGI, Sun Studio CC
30 #include <cmath>
31 #include <complex>
32 
33 namespace libMesh
34 {
35 
36 // Forward declarations
37 template <typename T> class TypeTensor;
38 template <typename T> class VectorValue;
39 template <typename T> class TensorValue;
40 
51 template <typename T>
52 class TypeVector
53 {
54  template <typename T2>
55  friend class TypeVector;
56 
57  friend class TypeTensor<T>;
58 
59 protected:
60 
65  TypeVector ();
66 
71  TypeVector (const T x,
72  const T y=0,
73  const T z=0);
74 
79  template <typename Scalar1, typename Scalar2, typename Scalar3>
80  TypeVector (typename
82  const Scalar1>::type x,
83  typename
85  const Scalar2>::type y=0,
86  typename
88  const Scalar3>::type z=0);
89 
96  template <typename Scalar>
97  TypeVector (const Scalar x,
98  typename
100  const Scalar>::type * sfinae = libmesh_nullptr);
101 
102 public:
103 
107  typedef T value_type;
108 
112  template <typename T2>
113  TypeVector (const TypeVector<T2> & p);
114 
118  ~TypeVector ();
119 
123  template <typename T2>
124  void assign (const TypeVector<T2> &);
125 
129  template <typename Scalar>
130  typename boostcopy::enable_if_c<
132  TypeVector &>::type
133  operator = (const Scalar & libmesh_dbg_var(p))
134  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
135 
139  const T & operator () (const unsigned int i) const;
140  const T & slice (const unsigned int i) const { return (*this)(i); }
141 
145  T & operator () (const unsigned int i);
146  T & slice (const unsigned int i) { return (*this)(i); }
147 
153  template <typename T2>
155  operator + (const TypeVector<T2> &) const;
156 
162  template <typename T2>
163  const TypeVector<T> & operator += (const TypeVector<T2> &);
164 
168  template <typename T2>
169  void add (const TypeVector<T2> &);
170 
174  template <typename T2>
175  void add_scaled (const TypeVector<T2> &, const T);
176 
182  template <typename T2>
184  operator - (const TypeVector<T2> &) const;
185 
191  template <typename T2>
192  const TypeVector<T> & operator -= (const TypeVector<T2> &);
193 
197  template <typename T2>
198  void subtract (const TypeVector<T2> &);
199 
204  template <typename T2>
205  void subtract_scaled (const TypeVector<T2> &, const T);
206 
210  TypeVector<T> operator - () const;
211 
217  template <typename Scalar>
218  typename boostcopy::enable_if_c<
219  ScalarTraits<Scalar>::value,
221  operator * (const Scalar) const;
222 
228  const TypeVector<T> & operator *= (const T);
229 
235  template <typename Scalar>
236  typename boostcopy::enable_if_c<
237  ScalarTraits<Scalar>::value,
239  operator / (const Scalar) const;
240 
246  const TypeVector<T> & operator /= (const T);
247 
254  template <typename T2>
256  operator * (const TypeVector<T2> &) const;
257 
261  template <typename T2>
263  contract (const TypeVector<T2> &) const;
264 
268  template <typename T2>
270  cross(const TypeVector<T2> & v) const;
271 
275  TypeVector<T> unit() const;
276 
283 #ifdef LIBMESH_ENABLE_DEPRECATED
284  Real size() const;
285 #endif
286 
291  Real norm() const;
292 
299 #ifdef LIBMESH_ENABLE_DEPRECATED
300  Real size_sq() const;
301 #endif
302 
307  Real norm_sq() const;
308 
312  void zero();
313 
318  bool relative_fuzzy_equals(const TypeVector<T> & rhs,
319  Real tol = TOLERANCE) const;
320 
325  bool absolute_fuzzy_equals(const TypeVector<T> & rhs,
326  Real tol = TOLERANCE) const;
327 
335  bool operator == (const TypeVector<T> & rhs) const;
336 
340  bool operator != (const TypeVector<T> & rhs) const;
341 
348  bool operator < (const TypeVector<T> & rhs) const;
349 
356  bool operator <= (const TypeVector<T> & rhs) const;
357 
364  bool operator > (const TypeVector<T> & rhs) const;
365 
372  bool operator >= (const TypeVector<T> & rhs) const;
373 
377  void print(std::ostream & os = libMesh::out) const;
378 
387  friend std::ostream & operator << (std::ostream & os, const TypeVector<T> & t)
388  {
389  t.print(os);
390  return os;
391  }
392 
399  void write_unformatted (std::ostream & out, const bool newline = true) const;
400 
401 protected:
402 
406  T _coords[LIBMESH_DIM];
407 };
408 
409 
410 
411 
412 
413 //------------------------------------------------------
414 // Inline functions
415 
416 template <typename T>
417 inline
419 {
420  _coords[0] = 0;
421 
422 #if LIBMESH_DIM > 1
423  _coords[1] = 0;
424 #endif
425 
426 #if LIBMESH_DIM > 2
427  _coords[2] = 0;
428 #endif
429 }
430 
431 
432 
433 template <typename T>
434 inline
436  const T y,
437  const T z)
438 {
439  _coords[0] = x;
440 
441 #if LIBMESH_DIM > 1
442  _coords[1] = y;
443 #else
444  libmesh_assert_equal_to (y, 0);
445 #endif
446 
447 #if LIBMESH_DIM > 2
448  _coords[2] = z;
449 #else
450  libmesh_assert_equal_to (z, 0);
451 #endif
452 }
453 
454 
455 template <typename T>
456 template <typename Scalar1, typename Scalar2, typename Scalar3>
457 inline
460  const Scalar1>::type x,
461  typename
463  const Scalar2>::type y,
464  typename
466  const Scalar3>::type z)
467 {
468  _coords[0] = x;
469 
470 #if LIBMESH_DIM > 1
471  _coords[1] = y;
472 #else
473  libmesh_assert_equal_to (y, 0);
474 #endif
475 
476 #if LIBMESH_DIM > 2
477  _coords[2] = z;
478 #else
479  libmesh_assert_equal_to (z, 0);
480 #endif
481 }
482 
483 
484 
485 template <typename T>
486 template <typename Scalar>
487 inline
489  typename
490  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
491  const Scalar>::type * /*sfinae*/)
492 {
493  _coords[0] = x;
494 
495 #if LIBMESH_DIM > 1
496  _coords[1] = 0;
497 #endif
498 
499 #if LIBMESH_DIM > 2
500  _coords[2] = 0;
501 #endif
502 }
503 
504 
505 
506 template <typename T>
507 template <typename T2>
508 inline
510 {
511  // copy the nodes from vector p to me
512  for (unsigned int i=0; i<LIBMESH_DIM; i++)
513  _coords[i] = p._coords[i];
514 }
515 
516 
517 
518 template <typename T>
519 inline
521 {
522 }
523 
524 
525 
526 template <typename T>
527 template <typename T2>
528 inline
530 {
531  for (unsigned int i=0; i<LIBMESH_DIM; i++)
532  _coords[i] = p._coords[i];
533 }
534 
535 
536 
537 template <typename T>
538 inline
539 const T & TypeVector<T>::operator () (const unsigned int i) const
540 {
541  libmesh_assert_less (i, LIBMESH_DIM);
542 
543  return _coords[i];
544 }
545 
546 
547 
548 template <typename T>
549 inline
550 T & TypeVector<T>::operator () (const unsigned int i)
551 {
552  libmesh_assert_less (i, LIBMESH_DIM);
553 
554  return _coords[i];
555 }
556 
557 
558 
559 template <typename T>
560 template <typename T2>
561 inline
564 {
565  typedef typename CompareTypes<T, T2>::supertype TS;
566 #if LIBMESH_DIM == 1
567  return TypeVector<TS> (_coords[0] + p._coords[0]);
568 #endif
569 
570 #if LIBMESH_DIM == 2
571  return TypeVector<TS> (_coords[0] + p._coords[0],
572  _coords[1] + p._coords[1]);
573 #endif
574 
575 #if LIBMESH_DIM == 3
576  return TypeVector<TS> (_coords[0] + p._coords[0],
577  _coords[1] + p._coords[1],
578  _coords[2] + p._coords[2]);
579 #endif
580 
581 }
582 
583 
584 
585 template <typename T>
586 template <typename T2>
587 inline
589 {
590  this->add (p);
591 
592  return *this;
593 }
594 
595 
596 
597 template <typename T>
598 template <typename T2>
599 inline
601 {
602 #if LIBMESH_DIM == 1
603  _coords[0] += p._coords[0];
604 #endif
605 
606 #if LIBMESH_DIM == 2
607  _coords[0] += p._coords[0];
608  _coords[1] += p._coords[1];
609 #endif
610 
611 #if LIBMESH_DIM == 3
612  _coords[0] += p._coords[0];
613  _coords[1] += p._coords[1];
614  _coords[2] += p._coords[2];
615 #endif
616 
617 }
618 
619 
620 
621 template <typename T>
622 template <typename T2>
623 inline
624 void TypeVector<T>::add_scaled (const TypeVector<T2> & p, const T factor)
625 {
626 #if LIBMESH_DIM == 1
627  _coords[0] += factor*p(0);
628 #endif
629 
630 #if LIBMESH_DIM == 2
631  _coords[0] += factor*p(0);
632  _coords[1] += factor*p(1);
633 #endif
634 
635 #if LIBMESH_DIM == 3
636  _coords[0] += factor*p(0);
637  _coords[1] += factor*p(1);
638  _coords[2] += factor*p(2);
639 #endif
640 
641 }
642 
643 
644 
645 template <typename T>
646 template <typename T2>
647 inline
650 {
651  typedef typename CompareTypes<T, T2>::supertype TS;
652 
653 #if LIBMESH_DIM == 1
654  return TypeVector<TS>(_coords[0] - p._coords[0]);
655 #endif
656 
657 #if LIBMESH_DIM == 2
658  return TypeVector<TS>(_coords[0] - p._coords[0],
659  _coords[1] - p._coords[1]);
660 #endif
661 
662 #if LIBMESH_DIM == 3
663  return TypeVector<TS>(_coords[0] - p._coords[0],
664  _coords[1] - p._coords[1],
665  _coords[2] - p._coords[2]);
666 #endif
667 
668 }
669 
670 
671 
672 template <typename T>
673 template <typename T2>
674 inline
676 {
677  this->subtract (p);
678 
679  return *this;
680 }
681 
682 
683 
684 template <typename T>
685 template <typename T2>
686 inline
688 {
689  for (unsigned int i=0; i<LIBMESH_DIM; i++)
690  _coords[i] -= p._coords[i];
691 }
692 
693 
694 
695 template <typename T>
696 template <typename T2>
697 inline
698 void TypeVector<T>::subtract_scaled (const TypeVector<T2> & p, const T factor)
699 {
700  for (unsigned int i=0; i<LIBMESH_DIM; i++)
701  _coords[i] -= factor*p(i);
702 }
703 
704 
705 
706 template <typename T>
707 inline
709 {
710 
711 #if LIBMESH_DIM == 1
712  return TypeVector(-_coords[0]);
713 #endif
714 
715 #if LIBMESH_DIM == 2
716  return TypeVector(-_coords[0],
717  -_coords[1]);
718 #endif
719 
720 #if LIBMESH_DIM == 3
721  return TypeVector(-_coords[0],
722  -_coords[1],
723  -_coords[2]);
724 #endif
725 
726 }
727 
728 
729 
730 template <typename T>
731 template <typename Scalar>
732 inline
733 typename boostcopy::enable_if_c<
734  ScalarTraits<Scalar>::value,
736 TypeVector<T>::operator * (const Scalar factor) const
737 {
738  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
739 
740 #if LIBMESH_DIM == 1
741  return TypeVector<SuperType>(_coords[0]*factor);
742 #endif
743 
744 #if LIBMESH_DIM == 2
745  return TypeVector<SuperType>(_coords[0]*factor,
746  _coords[1]*factor);
747 #endif
748 
749 #if LIBMESH_DIM == 3
750  return TypeVector<SuperType>(_coords[0]*factor,
751  _coords[1]*factor,
752  _coords[2]*factor);
753 #endif
754 }
755 
756 
757 
758 template <typename T, typename Scalar>
759 inline
760 typename boostcopy::enable_if_c<
761  ScalarTraits<Scalar>::value,
763 operator * (const Scalar factor,
764  const TypeVector<T> & v)
765 {
766  return v * factor;
767 }
768 
769 
770 
771 template <typename T>
772 inline
774 {
775 #if LIBMESH_DIM == 1
776  _coords[0] *= factor;
777 #endif
778 
779 #if LIBMESH_DIM == 2
780  _coords[0] *= factor;
781  _coords[1] *= factor;
782 #endif
783 
784 #if LIBMESH_DIM == 3
785  _coords[0] *= factor;
786  _coords[1] *= factor;
787  _coords[2] *= factor;
788 #endif
789 
790  return *this;
791 }
792 
793 
794 
795 template <typename T>
796 template <typename Scalar>
797 inline
798 typename boostcopy::enable_if_c<
799  ScalarTraits<Scalar>::value,
801 TypeVector<T>::operator / (const Scalar factor) const
802 {
803  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
804 
805  typedef typename CompareTypes<T, Scalar>::supertype TS;
806 
807 #if LIBMESH_DIM == 1
808  return TypeVector<TS>(_coords[0]/factor);
809 #endif
810 
811 #if LIBMESH_DIM == 2
812  return TypeVector<TS>(_coords[0]/factor,
813  _coords[1]/factor);
814 #endif
815 
816 #if LIBMESH_DIM == 3
817  return TypeVector<TS>(_coords[0]/factor,
818  _coords[1]/factor,
819  _coords[2]/factor);
820 #endif
821 
822 }
823 
824 
825 
826 
827 template <typename T>
828 inline
829 const TypeVector<T> &
831 {
832  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
833 
834  for (unsigned int i=0; i<LIBMESH_DIM; i++)
835  _coords[i] /= factor;
836 
837  return *this;
838 }
839 
840 
841 
842 
843 template <typename T>
844 template <typename T2>
845 inline
848 {
849 #if LIBMESH_DIM == 1
850  return _coords[0]*p._coords[0];
851 #endif
852 
853 #if LIBMESH_DIM == 2
854  return (_coords[0]*p._coords[0] +
855  _coords[1]*p._coords[1]);
856 #endif
857 
858 #if LIBMESH_DIM == 3
859  return (_coords[0]*p(0) +
860  _coords[1]*p(1) +
861  _coords[2]*p(2));
862 #endif
863 }
864 
865 template <typename T>
866 template <typename T2>
867 inline
870 {
871  return (*this)*(p);
872 }
873 
874 
875 
876 template <typename T>
877 template <typename T2>
880 {
881  typedef typename CompareTypes<T, T2>::supertype TS;
882  libmesh_assert_equal_to (LIBMESH_DIM, 3);
883 
884  // | i j k |
885  // |(*this)(0) (*this)(1) (*this)(2)|
886  // | p(0) p(1) p(2) |
887 
888  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
889  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
890  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
891 }
892 
893 
894 
895 #ifdef LIBMESH_ENABLE_DEPRECATED
896 template <typename T>
897 inline
899 {
900  libmesh_deprecated();
901  return this->norm();
902 }
903 #endif
904 
905 
906 
907 template <typename T>
908 inline
910 {
911  return std::sqrt(this->norm_sq());
912 }
913 
914 
915 
916 template <typename T>
917 inline
919 {
920  for (unsigned int i=0; i<LIBMESH_DIM; i++)
921  _coords[i] = 0.;
922 }
923 
924 
925 
926 #ifdef LIBMESH_ENABLE_DEPRECATED
927 template <typename T>
928 inline
930 {
931  libmesh_deprecated();
932  return this->norm_sq();
933 }
934 #endif
935 
936 
937 
938 template <typename T>
939 inline
941 {
942 #if LIBMESH_DIM == 1
943  return (TensorTools::norm_sq(_coords[0]));
944 #endif
945 
946 #if LIBMESH_DIM == 2
947  return (TensorTools::norm_sq(_coords[0]) +
949 #endif
950 
951 #if LIBMESH_DIM == 3
952  return (TensorTools::norm_sq(_coords[0]) +
955 #endif
956 }
957 
958 
959 
960 template <typename T>
961 inline
963 {
964 #if LIBMESH_DIM == 1
965  return (std::abs(_coords[0] - rhs._coords[0])
966  <= tol);
967 #endif
968 
969 #if LIBMESH_DIM == 2
970  return (std::abs(_coords[0] - rhs._coords[0]) +
971  std::abs(_coords[1] - rhs._coords[1])
972  <= tol);
973 #endif
974 
975 #if LIBMESH_DIM == 3
976  return (std::abs(_coords[0] - rhs._coords[0]) +
977  std::abs(_coords[1] - rhs._coords[1]) +
978  std::abs(_coords[2] - rhs._coords[2])
979  <= tol);
980 #endif
981 }
982 
983 
984 
985 template <typename T>
986 inline
988 {
989 #if LIBMESH_DIM == 1
990  return this->absolute_fuzzy_equals(rhs, tol *
991  (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
992 #endif
993 
994 #if LIBMESH_DIM == 2
995  return this->absolute_fuzzy_equals(rhs, tol *
996  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
997  std::abs(_coords[1]) + std::abs(rhs._coords[1])));
998 #endif
999 
1000 #if LIBMESH_DIM == 3
1001  return this->absolute_fuzzy_equals(rhs, tol *
1002  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
1003  std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
1004  std::abs(_coords[2]) + std::abs(rhs._coords[2])));
1005 #endif
1006 }
1007 
1008 
1009 
1010 template <typename T>
1011 inline
1013 {
1014 #if LIBMESH_DIM == 1
1015  return (_coords[0] == rhs._coords[0]);
1016 #endif
1017 
1018 #if LIBMESH_DIM == 2
1019  return (_coords[0] == rhs._coords[0] &&
1020  _coords[1] == rhs._coords[1]);
1021 #endif
1022 
1023 #if LIBMESH_DIM == 3
1024  return (_coords[0] == rhs._coords[0] &&
1025  _coords[1] == rhs._coords[1] &&
1026  _coords[2] == rhs._coords[2]);
1027 #endif
1028 }
1029 
1030 
1031 
1032 template <typename T>
1033 inline
1035 {
1036  return (!(*this == rhs));
1037 }
1038 
1039 
1040 //------------------------------------------------------
1041 // Non-member functions on TypeVectors
1042 
1043 // Compute a * (b.cross(c)) without creating a temporary
1044 // for the cross product. Equivalent to the determinant
1045 // of the 3x3 tensor:
1046 // [a0, a1, a2]
1047 // [b0, b1, b2]
1048 // [c0, c1, c2]
1049 template <typename T>
1050 inline
1052  const TypeVector<T> & b,
1053  const TypeVector<T> & c)
1054 {
1055  // We only support cross products when LIBMESH_DIM==3, same goes for this.
1056  libmesh_assert_equal_to (LIBMESH_DIM, 3);
1057 
1058  return
1059  a(0)*(b(1)*c(2) - b(2)*c(1)) -
1060  a(1)*(b(0)*c(2) - b(2)*c(0)) +
1061  a(2)*(b(0)*c(1) - b(1)*c(0));
1062 }
1063 
1064 
1065 
1070 template <typename T>
1071 inline
1073  const TypeVector<T> & c)
1074 {
1075  // We only support cross products when LIBMESH_DIM==3, same goes for this.
1076  libmesh_assert_equal_to (LIBMESH_DIM, 3);
1077 
1078  T x = b(1)*c(2) - b(2)*c(1),
1079  y = b(0)*c(2) - b(2)*c(0),
1080  z = b(0)*c(1) - b(1)*c(0);
1081 
1082  return x*x + y*y + z*z;
1083 }
1084 
1085 
1086 
1090 template <typename T>
1091 inline
1093  const TypeVector<T> & c)
1094 {
1095  // We only support cross products when LIBMESH_DIM==3, same goes for this.
1096  libmesh_assert_equal_to (LIBMESH_DIM, 3);
1097 
1098  return std::sqrt(cross_norm_sq(b,c));
1099 }
1100 
1101 } // namespace libMesh
1102 
1103 #endif // LIBMESH_TYPE_VECTOR_H
bool operator>=(const TypeVector< T > &rhs) const
Definition: type_vector.C:152
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
double abs(double a)
bool operator==(const TypeVector< T > &rhs) const
Definition: type_vector.h:1012
const T & slice(const unsigned int i) const
Definition: type_vector.h:140
bool operator>(const TypeVector< T > &rhs) const
Definition: type_vector.C:138
CompareTypes< T, T2 >::supertype contract(const TypeVector< T2 > &) const
Definition: type_vector.h:869
void add_scaled(const TypeVector< T2 > &, const T)
Add a scaled value to this vector without creating a temporary.
Definition: type_vector.h:624
T cross_norm(const TypeVector< T > &b, const TypeVector< T > &c)
Calls cross_norm_sq() and takes the square root of the result.
Definition: type_vector.h:1092
void write_unformatted(std::ostream &out, const bool newline=true) const
Unformatted print to the stream out.
Definition: type_vector.C:92
Real norm() const
Definition: type_vector.h:909
const class libmesh_nullptr_t libmesh_nullptr
static const Real TOLERANCE
TypeVector< T > operator-() const
Definition: type_vector.h:708
The libMesh namespace provides an interface to certain functionality in the library.
TypeVector< typename CompareTypes< T, T2 >::supertype > operator+(const TypeVector< T2 > &) const
Add two vectors.
Definition: type_vector.h:563
const TypeVector< T > & operator+=(const TypeVector< T2 > &)
Add to this vector.
Definition: type_vector.h:588
void add(const TypeVector< T2 > &)
Add to this vector without creating a temporary.
Definition: type_vector.h:600
const TypeVector< T > & operator/=(const T)
Divide each entry of this vector by scalar value.
Definition: type_vector.h:830
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
Definition: tensor_tools.h:32
T cross_norm_sq(const TypeVector< T > &b, const TypeVector< T > &c)
Compute |b x c|^2 without creating the extra temporary produced by calling b.cross(c).norm_sq().
Definition: type_vector.h:1072
T triple_product(const TypeVector< T > &a, const TypeVector< T > &b, const TypeVector< T > &c)
Definition: type_vector.h:1051
void zero()
Set all entries of the vector to 0.
Definition: type_vector.h:918
PetscErrorCode Vec x
void subtract(const TypeVector< T2 > &)
Subtract from this vector without creating a temporary.
Definition: type_vector.h:687
T value_type
Helper typedef for C++98 generic programming.
Definition: type_vector.h:107
void print(std::ostream &os=libMesh::out) const
Formatted print, by default to libMesh::out.
Definition: type_vector.C:64
bool operator!=(const TypeVector< T > &rhs) const
Definition: type_vector.h:1034
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const
Definition: type_vector.h:879
This class defines a vector in LIBMESH_DIM dimensional space of type T.
Definition: tensor_tools.h:30
PetscErrorCode Vec Mat libmesh_dbg_var(j)
Real norm_sq() const
Definition: type_vector.h:940
void subtract_scaled(const TypeVector< T2 > &, const T)
Subtract a scaled value from this vector without creating a temporary.
Definition: type_vector.h:698
TypeVector< T > unit() const
Definition: type_vector.C:37
TypeVector()
Empty constructor.
Definition: type_vector.h:418
const TypeVector< T > & operator-=(const TypeVector< T2 > &)
Subtract from this vector.
Definition: type_vector.h:675
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:962
OStreamProxy out
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator/(const Scalar) const
Divide each entry of this vector by scalar value.
Definition: type_vector.h:801
void assign(const TypeVector< T2 > &)
Assign to this vector without creating a temporary.
Definition: type_vector.h:529
~TypeVector()
Destructor.
Definition: type_vector.h:520
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator*(const Scalar) const
Multiply this vector by a scalar value.
Definition: type_vector.h:736
const T & operator()(const unsigned int i) const
Definition: type_vector.h:539
T & slice(const unsigned int i)
Definition: type_vector.h:146
Real size_sq() const
Definition: type_vector.h:929
Real size() const
Definition: type_vector.h:898
const TypeVector< T > & operator*=(const T)
Multiply this vector by a scalar value.
Definition: type_vector.h:773
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector & >::type operator=(const Scalar &libmesh_dbg_var(p))
Assignment-from-scalar operator.
Definition: type_vector.h:133
bool relative_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:987