Add Fastor library

This commit is contained in:
Bassem Girgis
2025-03-22 01:17:52 -05:00
parent 5546e086f6
commit 4dd5939693
132 changed files with 55086 additions and 0 deletions

View 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