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

Commit b767eff

Browse files
author
Rue Yokaze
authored
add overview
1 parent c9dd6b5 commit b767eff

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

‎README.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,50 @@
1-
# python-multi-array
2-
A python wrapper for boost::multi_array
3-
4-
# Install
5-
1+
# Overview
2+
python-multi-array exports ```std::shared_ptr<boost::multi_array<T, N>>``` for
63
```
7-
$ make
4+
T: bool, uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32 and floa64
5+
N: 1 to 8.
86
```
97

10-
You may change the include directory by editing setup.py.
8+
The library serves a powerful tool to cooperate python and its extension modules written in C++.
9+
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.
1110

12-
# Usage
11+
The array is allocated via multi_array.make.
12+
```python
13+
>>> import numpy, multi_array
14+
>>> multi_array.make((4, 2), numpy.float32)
15+
<multi_array.shared_float_matrix object at 0x10aeb3f50>)
16+
```
17+
18+
The array itself has simple I/O APIs:
19+
```python
20+
>>> x = multi_array.make((4, 2), numpy.float32)
21+
>>> x.num_dimensions()
22+
2
23+
>>> x.num_elements()
24+
8
25+
>>> x.shape()
26+
(4, 2)
27+
>>> x[1, 1] = 3
28+
>>> x[1, 1]
29+
3.0
30+
```
1331

32+
and conversion APIs with numpy.ndarray.
1433
```python
15-
>>> import multi_array, scipy
16-
>>> x = multi_array.make((2, 4), multi_array.float32)
17-
>>> x.set(scipy.rand(2, 4))
34+
>>> x.set(scipy.rand(4, 2))
35+
>>> type(x.get())
36+
<type'numpy.ndarray'>
1837
>>> x.get()
19-
array([[ 0.9504686 , 0.37968314, 0.93876582, 0.17501496],
20-
[ 0.87398338, 0.83764452, 0.69423091, 0.29122856]], dtype=float32)
21-
>>> x[1, 2]
22-
0.6942309141159058
38+
array([[ 0.91382688, 0.374331 ],
39+
[ 0.43389955, 0.5571261 ],
40+
[ 0.6937117 , 0.40599877],
41+
[ 0.80906659, 0.75029951]], dtype=float32)
42+
```
43+
44+
# Install
45+
2346
```
47+
$ make
48+
```
49+
50+
You may change the include directory by editing setup.py.

0 commit comments

Comments
(0)

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