Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

yokaze/python-multi-array

Repository files navigation

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

Stars

Watchers

Forks

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /