The Wayback Machine - https://web.archive.org/web/20201110113446/https://github.com/yokaze/python-multi-array
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Overview

python-multi-array exports std::shared_ptr<boost::multi_array<T, N>> for

T: bool, uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32 and floa64
N: 1 to 8.

The library serves a powerful tool to cooperate python and its extension modules written in C++. You can create arrays and set values in python, make heavy calculation in C++ (OpenMP and every other C++ tools are available,) and get back to python and display the results using matplotlib.

The array is allocated via multi_array.make.

>>> import numpy, multi_array
>>> multi_array.make((4, 2), numpy.float32)
<multi_array.shared_float_matrix object at 0x10aeb3f50>)

The array itself has simple I/O APIs:

>>> x = multi_array.make((4, 2), numpy.float32)
>>> x.num_dimensions()
2
>>> x.num_elements()
8
>>> x.shape()
(4, 2)
>>> x[1, 1] = 3
>>> x[1, 1]
3.0

and conversion APIs with numpy.ndarray.

>>> x.set(scipy.rand(4, 2))
>>> type(x.get())
<type 'numpy.ndarray'>
>>> x.get()
array([[ 0.91382688,  0.374331  ],
       [ 0.43389955,  0.5571261 ],
       [ 0.6937117 ,  0.40599877],
       [ 0.80906659,  0.75029951]], dtype=float32)

Setup

$ make

will build multi_array.so in the same directory.

Documentation

Full documentation is available on GitHub Wiki.

Requirements

  • NumPy
  • boost 1.63.0+ ... v1.63.0 or later is required to use Boost.Python NumPy Extension.

Contact

If you have any question about the library, feel free to contact me: https://github.com/yokaze

About

A python wrapper for boost::multi_array

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.