39 Vec3() { std::fill_n(d, 3, T(0)); }
41 Vec3(
const T d_[3]) { std::copy(d_, d_ + 3, d); }
43 Vec3(
const T d1,
const T d2,
const T d3) {
49 const T& operator[](
const int i)
const {
return d[i]; }
51 T& operator[](
const int i) {
return d[i]; }
53 const T*
data()
const {
return d; }
55 T*
data() {
return d; }
57 inline T
norm()
const {
return std::sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); }
59 inline T normalise() {
63 for (
int i = 0; i != 3; ++i) { d[i] *= f; }
68 void set_zero() { std::fill_n(d, 3, T(0)); }
70 Vec3& assign(
const Vec3& o) {
71 std::copy(o.d, o.d + 3, d);
75 Vec3& assign(
const T o[3]) {
76 std::copy(o, o + 3, d);
80 Vec3& operator=(
const Vec3& o) {
81 std::copy(o.d, o.d + 3, d);
85 Vec3& operator+=(
const Vec3& o) {
86 for (
int i = 0; i != 3; ++i) { d[i] += o.d[i]; }
90 Vec3& operator-=(
const Vec3& o) {
91 for (
int i = 0; i != 3; ++i) { d[i] -= o.d[i]; }
95 Vec3& operator*=(
const T f) {
96 for (
int i = 0; i != 3; ++i) { d[i] *= f; }
100 Vec3& operator/=(
const T f) {
101 for (
int i = 0; i != 3; ++i) { d[i] /= f; }
105 bool operator==(
const Vec3& o)
const {
return (d[0] == o[0] && d[1] == o[1] && d[2] == o[2]); }
107 bool operator!=(
const Vec3& o)
const {
return (d[0] != o[0] || d[1] != o[1] || d[2] != o[2]); }
111inline std::ostream& operator<<(std::ostream& o,
const Vec3<T>& v) {
112 o <<
"[" << v[0] <<
"," << v[1] <<
"," << v[2] <<
"]";
117inline Vec3<T> operator+(
const Vec3<T>& v1,
const Vec3<T>& v2) {
118 return Vec3<T>(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]);
122inline Vec3<T> operator-(
const Vec3<T>& v1) {
123 return Vec3<T>(-v1[0], -v1[1], -v1[2]);
127inline Vec3<T> operator-(
const Vec3<T>& v1,
const Vec3<T>& v2) {
128 return Vec3<T>(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]);
132inline Vec3<T> operator*(
const double f,
const Vec3<T>& v) {
133 return Vec3<T>(f * v[0], f * v[1], f * v[2]);
137inline Vec3<T> operator*(
const Vec3<T>& v,
const double f) {
138 return Vec3<T>(f * v[0], f * v[1], f * v[2]);
142inline T dot(
const Vec3<T>& v1,
const Vec3<T>& v2) {
143 return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
147inline Vec3<T> outer_product(
const Vec3<T>& v1,
const Vec3<T>& v2) {
149 v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2],
150 v1[0] * v2[1] - v1[1] * v2[0]);
154inline Vec3<T> normalised(
const Vec3<T>& v) {
161inline T
norm(
const Vec3<T>& v) {
162 return std::sqrt(dot(v, v));
csda< T > norm(const csda< T > &a)
Definition b2csda.H:343
bool operator==(const csda< T1 > &a, const csda< T2 > &b)
Comparison of two csda numbers is performed on the real part only.
Definition b2csda.H:226
bool operator!=(const csda< T1 > &a, const csda< T2 > &b)
Comparison of two csda numbers is performed on the real part only.
Definition b2csda.H:244
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32