-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathArrayRef.h
More file actions
55 lines (39 loc) · 1.35 KB
/
ArrayRef.h
File metadata and controls
55 lines (39 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// -*- c++ -*-
/*
* Copyright (c) 2010-2012, Jim Bosch
* All rights reserved.
*
* ndarray is distributed under a simple BSD-like license;
* see the LICENSE file that should be present in the root
* of the source distribution, or alternately available at:
* https://github.com/ndarray/ndarray
*/
#ifndef NDARRAY_BP_ArrayRef_h_INCLUDED
#define NDARRAY_BP_ArrayRef_h_INCLUDED
#include "ndarray/bp/Array.h"
namespace ndarray {
template <typename T, int N, int C>
class ToBoostPython< ArrayRef<T,N,C> > {
public:
typedef boost::numpy::ndarray result_type;
static boost::numpy::ndarray apply(ArrayRef<T,N,C> const & array) {
return ToBoostPython< Array<T,N,C> >::apply(array);
}
};
template <typename T, int N, int C>
class FromBoostPython< ArrayRef<T,N,C> > {
public:
explicit FromBoostPython(boost::python::object const & input) : _impl(input) {}
bool convertible() { return _impl.convertible(); }
ArrayRef<T,N,C> operator()() { return ArrayRef<T,N,C>(_impl()); }
private:
FromBoostPython< Array<T,N,C> > _impl;
};
} // namespace ndarray
namespace boost { namespace numpy {
template <typename T, int N, int C>
numpy::ndarray array(::ndarray::ArrayRef<T,N,C> const & arg) {
return ::ndarray::ToBoostPython< ::ndarray::ArrayRef<T,N,C> >::apply(arg);
}
}} // namespace boost::numpy
#endif // !NDARRAY_BP_ArrayRef_h_INCLUDED