4 #ifndef CPPQEDCORE_UTILS_BLITZARRAYTRAITS_H_INCLUDED
5 #define CPPQEDCORE_UTILS_BLITZARRAYTRAITS_H_INCLUDED
10 #include <boost/mpl/int.hpp>
18 template<
typename Numtype,
int RANK>
19 struct Rank<blitz::Array<Numtype,RANK> > : boost::mpl::int_<RANK> {};
22 struct TypeID<
DArray<RANK> >
24 static const std::string value;
28 const std::string TypeID<DArray<RANK> >::value=
"DArray";
32 struct TypeID<
CArray<RANK> >
34 static const std::string value;
38 const std::string TypeID<CArray<RANK> >::value=
"CArray";
47 inline bool isStorageContiguous(
const DArray<n>& a) {
return a.isStorageContiguous();}
51 inline size_t size(
const DArray<n>& a) {
return a.size();}
55 inline std::vector<size_t> dimensions(
const DArray<n>& a) {
return std::vector<size_t>(a.extent().begin(),a.extent().end());}
59 inline const double* data(
const DArray<n>& a) {
return a.size() ? a.data() : 0;}
62 inline double* data(
DArray<n>& a) {
return const_cast<double*
>(data(
static_cast<const DArray<n>&
>(a)));}
82 inline bool isStorageContiguous(
const CArray<n>& a) {
return a.isStorageContiguous();}
86 inline size_t size(
const CArray<n>& a) {
return a.size()<<1;}
90 inline std::vector<size_t> dimensions(
const CArray<n>& a) {
return std::vector<size_t>(a.extent().begin(),a.extent().end());}
94 inline const double* data(
const CArray<n>& a) {
return a.size() ? real(a).data() : 0;}
97 inline double* data(
CArray<n>& a) {
return const_cast<double*
>(data(
static_cast<const CArray<n>&
>(a)));}
119 inline size_t subscriptLimit(
const DArray<1>& a) {
return a.size();}
125 inline size_t subscriptLimit(
const CArray<1>& a) {
return a.size();}
127 inline size_t stride(
const CArray<1>& a) {
return a.stride(0);}
145 inline size_t subscriptLimit(
const CArray<n>& a) {
return a.size();}
150 #endif // CPPQEDCORE_UTILS_BLITZARRAYTRAITS_H_INCLUDED
Namespace comprising otherwise hard-to-classify generic utilities.
blitz::Array< dcomp,RANK > CArray
A complex array of arbitrary arity.
A create(double *y, const A &a)
Clone (create a non-owning array of data y of the same memory layout as a)
blitz::Array< double, RANK > DArray
An array of doubles of arbitrary arity.
Declarations of traits functions for adapting array types to generic functions.
const A::element_type & subscript(const A &a, size_t i)
subscription of a (which might be a multi-array) with a single integer
std::complex< double > dcomp
Double-precision complex number.
Defines template aliases for real and complex arrays.