41 return Vector(v[0][idx], v[1][idx], v[2][idx]);
87 return Tensor(v[0] + other.v[0], v[1] + other.v[1], v[2] + other.v[2]);
91 return Tensor(v[0] - other.v[0], v[1] - other.v[1], v[2] - other.v[2]);
97 for (
Size i = 0; i < 3; ++i) {
98 for (
Size j = 0; j < 3; ++j) {
148 return v[0] == other.v[0] && v[1] == other.v[1] && v[2] == other.v[2];
152 return !(*
this == other);
156 stream << t.
row(0) << std::endl << t.
row(1) << std::endl << t.
row(2);
179 0.5_f *
Vector(t(0, 1) + t(1, 0), t(0, 2) + t(2, 0), t(1, 2) + t(2, 1)));
184 return Tensor(r1[0] * r2, r1[1] * r2, r1[2] * r2);
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Basic algebra for symmetric 2nd order tensors.
INLINE SymmetricTensor symmetrize(const Tensor &t)
Computes a symmetrized tensor 1/2*(t + t^T)
INLINE AffineMatrix convert(const Tensor &t)
INLINE Tensor outer(const Vector &r1, const Vector &r2)
Outer product.
INLINE Float maxElement(const Tensor &t)
Returns the maximal element of the tensor.
INLINE bool isReal(const Tensor &t)
INLINE Tensor max(const Tensor &t1, const Tensor &t2)
Component-wise maximum of two tensors.
INLINE auto abs(const Tensor &t)
Returns the tensor of absolute values.
INLINE Float norm(const Tensor &t)
INLINE Tensor clamp(const Tensor &t, const Interval &range)
Clamping all components by range.
INLINE bool almostEqual(const Tensor &t1, const Tensor &t2, const Float eps=EPS)
Checks if two tensors are equal to some given accuracy.
INLINE Float minElement(const Tensor &t)
Returns the minimal element of the tensor.
INLINE Tensor min(const Tensor &t1, const Tensor &t2)
Component-wise minimum of two tensors.
INLINE Float normSqr(const Tensor &t)
Arbitrary squared norm of the tensor.
INLINE StaticArray< Float, 6 > getComponents(const Tensor &)
BasicVector< Float > Vector
INLINE float dot(const BasicVector< float > &v1, const BasicVector< float > &v2)
Make sure the vector is trivially constructible and destructible, needed for fast initialization of a...
INLINE Vector row(const Size idx) const
Object representing a 1D interval of real numbers.
Array with fixed number of allocated elements.
Symmetric tensor of 2nd order.
INLINE Vector row(const Size idx) const
Returns a row of the matrix.
Generic 2nd-order tensor with 9 independent components.
INLINE friend Tensor operator*(const Tensor &t, const Float v)
INLINE Tensor operator-(const Tensor &other) const
INLINE Tensor & operator+=(const Tensor &other)
INLINE Tensor & operator*=(const Float value)
INLINE Vector row(const Size idx) const
INLINE Vector operator*(const Vector &u) const
INLINE Float & operator()(const Size i, const Size j)
Tensor(const Vector &v1, const Vector &v2, const Vector &v3)
Construct the matrix from vectors as rows.
INLINE friend Tensor operator*(const Float v, const Tensor &t)
INLINE Tensor transpose() const
INLINE Vector column(const Size idx) const
INLINE Tensor operator*(const Tensor &other) const
Matrix multiplication.
INLINE Float operator()(const Size i, const Size j) const
INLINE Tensor operator+(const Tensor &other) const
INLINE bool operator!=(const Tensor &other) const
INLINE Tensor & operator-=(const Tensor &other)
INLINE Tensor & operator/=(const Float value)
Tensor(const Float value)
INLINE bool operator==(const Tensor &other) const
friend std::ostream & operator<<(std::ostream &stream, const Tensor &t)