Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:02

0001 //
0002 //  Copyright (c) 2018-2019, Cem Bassoy, cem.bassoy@gmail.com
0003 //
0004 //  Distributed under the Boost Software License, Version 1.0. (See
0005 //  accompanying file LICENSE_1_0.txt or copy at
0006 //  http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 //  The authors gratefully acknowledge the support of
0009 //  Fraunhofer IOSB, Ettlingen, Germany
0010 //
0011 
0012 #ifndef BOOST_UBLAS_TENSOR_INDEX_HPP
0013 #define BOOST_UBLAS_TENSOR_INDEX_HPP
0014 
0015 
0016 #include <cstddef>
0017 #include <array>
0018 #include <vector>
0019 
0020 namespace boost {
0021 namespace numeric {
0022 namespace ublas {
0023 namespace index {
0024 
0025 /** @brief Proxy template class for the einstein summation notation
0026  *
0027  * @note index::index_type<K> for 0<=K<=16 is used in tensor::operator()
0028  *
0029  * @tparam I wrapped integer
0030 */
0031 template<std::size_t I>
0032 struct index_type
0033 {
0034     static constexpr std::size_t value = I;
0035 
0036     constexpr bool operator == (std::size_t other) const { return value == other; }
0037     constexpr bool operator != (std::size_t other) const { return value != other; }
0038 
0039     template <std::size_t K>
0040     constexpr bool operator == (index_type<K> /*other*/) const {  return I==K; }
0041     template <std::size_t  K>
0042     constexpr bool operator != (index_type<K> /*other*/) const {  return I!=K; }
0043 
0044     constexpr bool operator == (index_type /*other*/) const {  return true;  }
0045     constexpr bool operator != (index_type /*other*/) const {  return false; }
0046 
0047     constexpr std::size_t operator()() const { return I; }
0048 };
0049 
0050 /** @brief Proxy classes for the einstein summation notation
0051  *
0052  * @note index::_a ... index::_z is used in tensor::operator()
0053 */
0054 
0055 static constexpr index_type< 0> _;
0056 static constexpr index_type< 1> _a;
0057 static constexpr index_type< 2> _b;
0058 static constexpr index_type< 3> _c;
0059 static constexpr index_type< 4> _d;
0060 static constexpr index_type< 5> _e;
0061 static constexpr index_type< 6> _f;
0062 static constexpr index_type< 7> _g;
0063 static constexpr index_type< 8> _h;
0064 static constexpr index_type< 9> _i;
0065 static constexpr index_type<10> _j;
0066 static constexpr index_type<11> _k;
0067 static constexpr index_type<12> _l;
0068 static constexpr index_type<13> _m;
0069 static constexpr index_type<14> _n;
0070 static constexpr index_type<15> _o;
0071 static constexpr index_type<16> _p;
0072 static constexpr index_type<17> _q;
0073 static constexpr index_type<18> _r;
0074 static constexpr index_type<19> _s;
0075 static constexpr index_type<20> _t;
0076 static constexpr index_type<21> _u;
0077 static constexpr index_type<22> _v;
0078 static constexpr index_type<23> _w;
0079 static constexpr index_type<24> _x;
0080 static constexpr index_type<25> _y;
0081 static constexpr index_type<26> _z;
0082 
0083 } // namespace indices
0084 
0085 }
0086 }
0087 }
0088 
0089 #endif // _BOOST_UBLAS_TENSOR_INDEX_HPP_