23 #ifndef NDARRAY_casts_h_INCLUDED
24 #define NDARRAY_casts_h_INCLUDED
34 #include <boost/type_traits/add_const.hpp>
35 #include <boost/type_traits/remove_const.hpp>
36 #include <boost/mpl/comparison.hpp>
37 #include <boost/utility/enable_if.hpp>
38 #include <boost/static_assert.hpp>
43 template <
typename Array_>
46 typedef typename boost::remove_const<ComplexElement>::type
ComplexValue;
49 typedef typename ComplexValue::value_type
RealValue;
50 typedef typename boost::mpl::if_<
57 static inline Result apply(Array_
const & array,
int offset) {
59 reinterpret_cast<RealElement*>(array.getData()) + offset,
60 Access::Core::create(array.getShape(), array.getStrides() * 2, array.getManager())
74 template <
typename T_,
typename T,
int N,
int C>
78 const_cast<T_*>(array.
getData()),
87 template <
int C_,
typename T,
int N,
int C>
103 template <
int C_,
typename T,
int N,
int C>
110 for (
int i=1; i <= C_; ++i) {
116 for (
int i=0; i < -C_; ++i) {
127 template <
typename Array_>
128 typename detail::ComplexExtractor<Array_>::Result
136 template <
typename Array_>
137 typename detail::ComplexExtractor<Array_>::Result
148 template <
int Nf,
typename T,
int N,
int C>
149 inline typename boost::enable_if_c< ((C+Nf-N)>=1), ArrayRef<T,Nf,(C+Nf-N)> >::type
152 typedef typename Access::Core Core;
153 BOOST_STATIC_ASSERT(C+Nf-N >= 1);
156 for (
int n=Nf; n<N; ++n)
157 newShape[Nf-1] *= oldShape[n];
159 newStrides[Nf-1] = 1;
160 return Access::construct(input.
getData(), Core::create(newShape, newStrides, input.
getManager()));
169 template <
int Nf,
typename T,
int N,
int C>
170 inline typename boost::enable_if_c< ((C+Nf-N)>=1), ArrayRef<T,Nf,(C+Nf-N)> >::type
172 return flatten<Nf>(input.
shallow());
179 #endif // !NDARRAY_casts_h_INCLUDED
A proxy class for Array with deep assignment operators.
Definitions for ArrayRef.
Index getStrides() const
Return a Vector of the strides of all dimensions.
Array< T_, N, C > const_array_cast(Array< T, N, C > const &array)
Array< T, N, C_ > dynamic_dimension_cast(Array< T, N, C > const &array)
static Array_ construct(Element *data, CorePtr const &core)
Array< T, N, C_ > static_dimension_cast(Array< T, N, C > const &array)
A fixed-size 1D array class.
Index getShape() const
Return a Vector of the sizes of all dimensions.
detail::ComplexExtractor< Array_ >::Result getReal(Array_ const &array)
Return an ArrayRef view into the real part of a complex array.
detail::ComplexExtractor< Array_ >::Result getImag(Array_ const &array)
Return an ArrayRef view into the imaginary part of a complex array.
boost::enable_if_c< ((C+Nf-N)>=1), ArrayRef< T, Nf,(C+Nf-N)> >::type flatten(Array< T, N, C > const &input)
Create a view into an array with trailing contiguous dimensions merged.
Element * getData() const
Return a raw pointer to the first element of the array.
A multidimensional strided array.
Shallow const shallow() const
Return a Array view to this.
Manager::Ptr getManager() const
Return the opaque object responsible for memory management.