Go to the documentation of this file.00001
00002
00003
00004
00005
00015 #include <boost/numpy.hpp>
00016 #include <iostream>
00017
00018 namespace p = boost::python;
00019 namespace np = boost::numpy;
00020
00021 int main(int argc, char **argv)
00022 {
00023
00024 Py_Initialize();
00025
00026 np::initialize();
00027
00028 p::tuple shape = p::make_tuple(3, 3);
00029
00030 np::dtype dtype = np::dtype::get_builtin<double>();
00031
00032 np::ndarray a = np::zeros(shape, dtype);
00033
00034 std::cout << "Original array:\n" << p::extract<char const *>(p::str(a)) << std::endl;
00035
00036 std::cout << "Datatype is:\n" << p::extract<char const *>(p::str(a.get_dtype())) << std::endl ;
00037
00038
00039 p::tuple for_custom_dtype = p::make_tuple("ha",dtype) ;
00040
00041
00042 p::list list_for_dtype ;
00043 list_for_dtype.append(for_custom_dtype) ;
00044
00045 np::dtype custom_dtype = np::dtype(list_for_dtype) ;
00046
00047 np::ndarray new_array = np::zeros(shape,custom_dtype);
00048
00049 }