Add Fastor library
This commit is contained in:
39
noarch/include/Fastor/tensor/ScalarIndexing.h
Normal file
39
noarch/include/Fastor/tensor/ScalarIndexing.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef SCALAR_INDEXING_NONCONST_H
|
||||
#define SCALAR_INDEXING_NONCONST_H
|
||||
|
||||
|
||||
// Scalar indexing non-const
|
||||
//----------------------------------------------------------------------------------------------------------//
|
||||
template<typename... Args, typename std::enable_if<sizeof...(Args)==dimension_t::value &&
|
||||
is_arithmetic_pack<Args...>::value,bool>::type =0>
|
||||
FASTOR_INLINE T& operator()(Args ... args) {
|
||||
return _data[get_flat_index(args...)];
|
||||
}
|
||||
template<typename Arg, typename std::enable_if<1==dimension_t::value &&
|
||||
is_arithmetic_pack<Arg>::value,bool>::type =0>
|
||||
FASTOR_INLINE T& operator[](Arg arg) {
|
||||
return _data[get_flat_index(arg)];
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------//
|
||||
|
||||
#endif // SCALAR_INDEXING_NONCONST_H
|
||||
|
||||
|
||||
#ifndef SCALAR_INDEXING_CONST_H
|
||||
#define SCALAR_INDEXING_CONST_H
|
||||
|
||||
// Scalar indexing const
|
||||
//----------------------------------------------------------------------------------------------------------//
|
||||
template<typename... Args, typename std::enable_if<sizeof...(Args)==dimension_t::value &&
|
||||
is_arithmetic_pack<Args...>::value,bool>::type =0>
|
||||
constexpr FASTOR_INLINE const T& operator()(Args ... args) const {
|
||||
return _data[get_flat_index(args...)];
|
||||
}
|
||||
template<typename Arg, typename std::enable_if<1==dimension_t::value &&
|
||||
is_arithmetic_pack<Arg>::value,bool>::type =0>
|
||||
constexpr FASTOR_INLINE const T& operator[](Arg arg) const {
|
||||
return _data[get_flat_index(arg)];
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------//
|
||||
|
||||
#endif // SCALAR_INDEXING_CONST_H
|
||||
Reference in New Issue
Block a user