// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// The array class is only available starting with cxx11. Emulate our own here // if needed. Beware, msvc still doesn't advertise itself as a c++11 compiler! // Moreover, CUDA doesn't support the STL containers, so we use our own instead. #if (__cplusplus <= 199711L && EIGEN_COMP_MSVC < 1900) || defined(EIGEN_GPUCC) || defined(EIGEN_AVOID_STL_ARRAY)
// Comparison operator // Todo: implement !=, <, <=, >, and >= template<class T, std::size_t N>
EIGEN_DEVICE_FUNC booloperator==(const array<T,N>& lhs, const array<T,N>& rhs) { for (std::size_t i = 0; i < N; ++i) { if (lhs[i] != rhs[i]) { returnfalse;
}
} returntrue;
}
namespace internal { template<std::size_t I_, class T, std::size_t N>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& array_get(array<T,N>& a) { return a[I_];
} template<std::size_t I_, class T, std::size_t N>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& array_get(const array<T,N>& a) { return a[I_];
}
template<class T, std::size_t N> struct array_size<array<T,N> > { enum { value = N };
}; template<class T, std::size_t N> struct array_size<array<T,N>& > { enum { value = N };
}; template<class T, std::size_t N> struct array_size<const array<T,N> > { enum { value = N };
}; template<class T, std::size_t N> struct array_size<const array<T,N>& > { enum { value = N };
};
} // end namespace internal
} // end namespace Eigen
#else
// The compiler supports c++11, and we're not targeting cuda: use std::array as Eigen::array #include <array> namespace Eigen {
template <typename T, std::size_t N> using array = std::array<T, N>;
namespace internal { /* std::get is only constexpr in C++14, not yet in C++11 * - libstdc++ from version 4.7 onwards has it nevertheless, * so use that * - libstdc++ older versions: use _M_instance directly * - libc++ all versions so far: use __elems_ directly * - all other libs: use std::get to be portable, but * this may not be constexpr
*/ #ifdefined(__GLIBCXX__) && __GLIBCXX__ < 20120322 #define STD_GET_ARR_HACK a._M_instance[I_] #elifdefined(_LIBCPP_VERSION) #define STD_GET_ARR_HACK a.__elems_[I_] #else #define STD_GET_ARR_HACK std::template get<I_, T, N>(a) #endif
template<std::size_t I_, class T, std::size_t N> constexpr inline T& array_get(std::array<T,N>& a) { return (T&) STD_GET_ARR_HACK; } template<std::size_t I_, class T, std::size_t N> constexpr inline T&& array_get(std::array<T,N>&& a) { return (T&&) STD_GET_ARR_HACK; } template<std::size_t I_, class T, std::size_t N> constexpr inline T const& array_get(std::array<T,N> const& a) { return (T const&) STD_GET_ARR_HACK; }
#undef STD_GET_ARR_HACK
} // end namespace internal
} // end namespace Eigen
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.