https://github.com/yokaze/python-multi-array
A python wrapper for boost::multi_array
https://github.com/yokaze/python-multi-array
boost multi-array python
Last synced: 4 months ago
JSON representation
A python wrapper for boost::multi_array
- Host: GitHub
- URL: https://github.com/yokaze/python-multi-array
- Owner: yokaze
- License: mit
- Created: 2017-06-20T10:23:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-27T05:10:41.000Z (over 8 years ago)
- Last Synced: 2025-01-16T11:26:52.841Z (11 months ago)
- Topics: boost, multi-array, python
- Language: C++
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Overview
python-multi-array exports ```std::shared_ptr>``` 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.
```python
>>> import numpy, multi_array
>>> multi_array.make((4, 2), numpy.float32)
)
```
The array itself has simple I/O APIs:
```python
>>> 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.
```python
>>> x.set(scipy.rand(4, 2))
>>> type(x.get())
>>> 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](https://github.com/yokaze/python-multi-array/wiki).
# Requirements
- [NumPy](http://www.numpy.org/)
- [boost 1.63.0+](http://www.boost.org/) ... 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