10#if !defined(MiniTensor_Vector_h)
11#define MiniTensor_Vector_h
18#include <Kokkos_Core.hpp>
29template<
typename T, Index N>
35template<
typename T, Index N = DYNAMIC>
108 template<
class ArrayT>
122 template<
class ArrayT>
138 template<
class ArrayT>
156 template<
class ArrayT>
176 template<
class ArrayT>
198 template<
class ArrayT>
217 template<
class ArrayT>
221 Index const dimension,
233 template<
class ArrayT>
237 Index const dimension,
251 template<
class ArrayT>
255 Index const dimension,
271 template<
class ArrayT>
275 Index const dimension,
293 template<
class ArrayT>
297 Index const dimension,
317 template<
class ArrayT>
321 Index const dimension,
367 Vector(T
const & s0, T
const & s1, T
const & s2);
442template<
typename S,
typename T, Index N>
451template<
typename S,
typename T, Index N>
460template<
typename T, Index N>
469template<
typename S,
typename T, Index N>
471typename Promote<S, T>::type
478template<
typename T, Index N>
487template<
typename T, Index N>
498template<
typename S,
typename T, Index N>
509template<
typename S,
typename T, Index N>
520template<
typename S,
typename T, Index N>
531template<
typename S,
typename T, Index N>
540template<
typename S,
typename T, Index N>
542typename Promote<S, T>::type
550template<
typename S,
typename T, Index N>
559template<
typename T, Index N>
568template<
typename T, Index N>
577template<
typename T, Index N>
586template<
typename T, Index N>
594template<
typename T, Index N>
605template<
typename T, Index N>
606std::pair<Vector<T, N>, T>
615template<
typename T, Index N>
625template<
typename T, Index N>
638template<
typename T, Index N>
650template<
typename T, Index N>
661template<
typename T, Index N>
669template<
typename T, Index N>
680template<
typename T, Index N>
681template<
class ArrayT>
692template<
typename T, Index N>
693template<
class ArrayT>
705template<
typename T, Index N>
706template<
class ArrayT>
719template<
typename T, Index N>
720template<
class ArrayT>
741template<
typename T, Index N>
742template<
class ArrayT>
765template<
typename T, Index N>
766template<
class ArrayT>
791template<
typename T, Index N>
792template<
class ArrayT>
796 Index const dimension,
804template<
typename T, Index N>
805template<
class ArrayT>
809 Index const dimension,
818template<
typename T, Index N>
819template<
class ArrayT>
823 Index const dimension,
839template<
typename T, Index N>
840template<
class ArrayT>
844 Index const dimension,
862template<
typename T, Index N>
863template<
class ArrayT>
867 Index const dimension,
887template<
typename T, Index N>
888template<
class ArrayT>
892 Index const dimension,
915template<
typename T, Index N>
923template<
typename T, Index N>
934template<
typename T, Index N>
945template<
typename T, Index N>
963template<
typename T, Index N>
982template<
typename T, Index N>
992template<
typename T, Index N>
1003template<
typename T, Index N>
1008 return get_dimension();
1014template<
typename T, Index N>
1019 return static_cast<Index>(1);
1025template<
typename T, Index N>
1037template<
typename T, Index N>
1048template<
typename T, Index N>
1059template<
typename T, Index N>
1070template<
typename T, Index N>
1081template<
typename S,
typename T, Index N>
1097template<
typename S,
typename T, Index N>
1099Vector<typename Promote<S, T>::type, N>
1113template<
typename T, Index N>
1129template<
typename S,
typename T, Index N>
1131typename Promote<S, T>::type
1140template<
typename T, Index N>
1152template<
typename T, Index N>
1164template<
typename S,
typename T, Index N>
1167lazy_disable_if<order_1234<S>, apply_vector<Promote<S, T>, N>>::type
1181template<
typename S,
typename T, Index N>
1184lazy_disable_if<order_1234<S>, apply_vector<Promote<S, T>, N>>::type
1198template<
typename S,
typename T, Index N>
1200Vector<typename Promote<S, T>::type, N>
1214template<
typename S,
typename T, Index N>
1216Vector<typename Promote<S, T>::type, N>
1230template<
typename S,
typename T, Index N>
1232typename Promote<S, T>::type
1240 typename Promote<S, T>::type
1243 switch (dimension) {
1246 for (
Index i = 0; i < dimension; ++i) {
1252 s = u(0) * v(0) + u(1) * v(1) + u(2) * v(2);
1256 s = u(0) * v(0) + u(1) * v(1);
1267template<
typename S,
typename T, Index N>
1269Vector<typename Promote<S, T>::type, N>
1280 switch (dimension) {
1283 w(0) = u(1) * v(2) - u(2) * v(1);
1284 w(1) = u(2) * v(0) - u(0) * v(2);
1285 w(2) = u(0) * v(1) - u(1) * v(0);
1301template<
typename T, Index N>
1309 if (s > 0.0)
return std::sqrt(s);
1318template<
typename T, Index N>
1329 switch (dimension) {
1336 s = u(0) * u(0) + u(1) * u(1) + u(2) * u(2);
1340 s = u(0) * u(0) + u(1) * u(1);
1352template<
typename T, Index N>
1363 switch (dimension) {
1366 for (
Index i = 0; i < dimension; ++i) {
1367 s += std::abs(u(i));
1372 s = std::abs(u(0)) + std::abs(u(1)) + std::abs(u(2));
1376 s = std::abs(u(0)) + std::abs(u(1));
1387template<
typename T, Index N>
1398 switch (dimension) {
1401 for (
Index i = 0; i < dimension; ++i) {
1421template<
typename T, Index N>
1432template <
typename T, Index N>
1445 for (
Index i = 1; i < dimension; ++i) {
1446 sigma = v[i] * v[i];
1454 mu = std::sqrt(x[0] * x[0] + sigma);
1455 v[0] = x[0] > 0.0 ? -sigma / (x[0] + mu) : x[0] - mu;
1456 beta = 2.0 * v[0] * v[0] / (sigma + v[0] * v[0]);
1460 return std::make_pair(v, beta);
1472template<
typename T, Index N>
1479 for (
Index i = 0; i < dimension; ++i) {
1492template<
typename T, Index N>
1499 if (dimension == 0) {
1503 os << std::scientific << std::setprecision(17);
1505 os << std::setw(24) << u(0);
1507 for (
Index i = 1; i < dimension; ++i) {
1508 os <<
"," << std::setw(24) << u(i);
#define KOKKOS_INLINE_FUNCTION
#define MT_ERROR_EXIT(...)
KOKKOS_INLINE_FUNCTION Vector(Source const source, Index const dimension, ArrayT &data, Index index1, Index index2, Index index3, Index index4, Index index5)
KOKKOS_INLINE_FUNCTION T const & operator()(Index const i) const
KOKKOS_INLINE_FUNCTION Vector(Source const source, ArrayT &data, Index index1, Index index2, Index index3, Index index4)
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > operator+(Matrix< S, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION void minus(TensorBase< T, ST > const &A, TensorBase< T, ST > &B)
static constexpr bool IS_DYNAMIC
KOKKOS_INLINE_FUNCTION Vector()
KOKKOS_INLINE_FUNCTION Index get_num_cols() const
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > operator-(Matrix< S, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION Vector(Index const dimension, Filler const value)
std::ostream & operator<<(std::ostream &os, Matrix< T, M, N > const &A)
KOKKOS_INLINE_FUNCTION void add(TensorBase< R, SR > const &A, TensorBase< S, SS > const &B, TensorBase< T, ST > &C)
KOKKOS_INLINE_FUNCTION Vector< typename Promote< S, T >::type, N > cross(Vector< S, N > const &u, Vector< T, N > const &v)
KOKKOS_INLINE_FUNCTION Vector(Source const source, Index const dimension, ArrayT &data, Index index1, Index index2, Index index3, Index index4, Index index5, Index index6)
std::istream & operator>>(std::istream &is, Matrix< T, M, N > &A)
KOKKOS_INLINE_FUNCTION Vector(T const &s0, T const &s1, T const &s2)
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > operator/(Matrix< T, M, N > const &A, S const &s)
KOKKOS_INLINE_FUNCTION Vector< typename Promote< S, T >::type, M > operator*(Matrix< T, M, N > const &A, Vector< S, N > const &u)
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION bool equal(TensorBase< T, ST > const &A, TensorBase< T, ST > const &B)
KOKKOS_INLINE_FUNCTION Index get_dimension(Index const order) const
KOKKOS_INLINE_FUNCTION void set_dimension(Index const dimension)
KOKKOS_INLINE_FUNCTION Vector(Source const source, ArrayT &data, Index index1, Index index2, Index index3)
KOKKOS_INLINE_FUNCTION Vector(Index const dimension)
KOKKOS_INLINE_FUNCTION Index get_num_rows() const
KOKKOS_INLINE_FUNCTION Vector(Source const source, ArrayT &data, Index index1)
KOKKOS_INLINE_FUNCTION void scale(TensorBase< R, SR > const &A, S const &s, TensorBase< T, ST > &B)
KOKKOS_INLINE_FUNCTION bool operator!=(Matrix< T, M, N > const &A, Matrix< T, M, N > const &B)
std::pair< Vector< T, N >, T > house(Vector< T, N > const &x)
KOKKOS_INLINE_FUNCTION Vector(T const *data_ptr)
KOKKOS_INLINE_FUNCTION bool operator==(Matrix< T, M, N > const &A, Matrix< T, M, N > const &B)
KOKKOS_INLINE_FUNCTION Vector< typename Promote< S, T >::type, M > dot(Matrix< T, M, N > const &A, Vector< S, N > const &u)
KOKKOS_INLINE_FUNCTION Vector(Vector< T, N > const &v)
KOKKOS_INLINE_FUNCTION Vector(Index const dimension, T const *data_ptr)
KOKKOS_INLINE_FUNCTION Vector(Source const source, Index const dimension, ArrayT &data, Index index1)
static KOKKOS_INLINE_FUNCTION constexpr Index get_order()
KOKKOS_INLINE_FUNCTION Vector(Source const source, Index const dimension, ArrayT &data, Index index1, Index index2)
KOKKOS_INLINE_FUNCTION Vector(Filler const value)
KOKKOS_INLINE_FUNCTION void split(TensorBase< R, SR > const &A, S const &s, TensorBase< T, ST > &B)
KOKKOS_INLINE_FUNCTION T & operator()(Index const i, Index const)
KOKKOS_INLINE_FUNCTION Vector(T const &s0, T const &s1)
KOKKOS_INLINE_FUNCTION T & operator()(Index const i)
static constexpr Index ORDER
KOKKOS_INLINE_FUNCTION Vector(Source const source, Index const dimension, ArrayT &data, Index index1, Index index2, Index index3, Index index4)
KOKKOS_INLINE_FUNCTION bool not_equal(TensorBase< T, ST > const &A, TensorBase< T, ST > const &B)
virtual KOKKOS_INLINE_FUNCTION ~Vector()
KOKKOS_INLINE_FUNCTION Vector(Source const source, ArrayT &data, Index index1, Index index2, Index index3, Index index4, Index index5)
KOKKOS_INLINE_FUNCTION void set_dimension(Index const dimension, Index const order)
KOKKOS_INLINE_FUNCTION T const & operator()(Index const i, Index const) const
KOKKOS_INLINE_FUNCTION Vector(Source const source, Index const dimension, ArrayT &data, Index index1, Index index2, Index index3)
KOKKOS_INLINE_FUNCTION T norm_square(Vector< T, N > const &u)
KOKKOS_INLINE_FUNCTION Vector(Source const source, ArrayT &data, Index index1, Index index2, Index index3, Index index4, Index index5, Index index6)
KOKKOS_INLINE_FUNCTION void divide(TensorBase< R, SR > const &A, S const &s, TensorBase< T, ST > &B)
KOKKOS_INLINE_FUNCTION Vector(Source const source, ArrayT &data, Index index1, Index index2)
KOKKOS_INLINE_FUNCTION void subtract(TensorBase< R, SR > const &A, TensorBase< S, SS > const &B, TensorBase< T, ST > &C)
KOKKOS_INLINE_FUNCTION T norm(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION T norm_1(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION T norm_infinity(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION Quaternion< T > unit(Quaternion< T > const &q)
uint32_t Index
Indexing type.
constexpr Index DYNAMIC
Indicator for dynamic storage.
KOKKOS_INLINE_FUNCTION T abs(T const &a)
KOKKOS_INLINE_FUNCTION T max(T const &a, T const &b)