- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Documentation
        Rue Yokaze edited this page Jul 1, 2017 
        ·
        1 revision
      
    | Name | Description | 
|---|---|
| make | create array of specified shape and type | 
| Name | Description | 
|---|---|
| num_dimensions | number of dimensions | 
| num_elements | total number of elements | 
| element | element type | 
| shape | array size | 
| reset | clear values | 
| get | copy of array in numpy.ndarray | 
| set | reset array with numpy.ndarray | 
| __getitem__ | get array element via index operator | 
| __setitem__ | set array element via index operator | 
allocates a boost::multi_array of specified shape and data type.
[array_type] multi_array.make(shape, dtype)
Example
>>> import multi_array
>>> x = multi_array.make([2, 3], multi_array.float32)
>>> x
<multi_array.shared_float_matrix object at 0x105f570c8>returns the number of dimensions of the array.
int x.num_dimensions()
Example
>>> x = multi_array.make([2, 2, 2], multi_array.float32)
>>> x.num_dimensions()
3returns the total number of elements of the array.
int x.num_elements()
Example
>>> x = multi_array.make([1, 2, 3, 4], multi_array.float32)
>>> x.num_elements()
24returns the data type of the array.
possible values are
bool8, uint8, uint16, uint32, uint64,
int8, int16, int32, int64, float32, float64, all defined in numpy.
dtype x.element()
Example
>>> x = multi_array.make([3, 3], multi_array.int32)
>>> x.element()
dtype('int32')returns the shape of the array.
tuple x.shape()
Example
>>> x = multi_array.make([2, 3, 4], multi_array.float32)
>>> x.shape()
(2, 3, 4)clears all the element values of the array with zero.
x.reset()
Example
>>> x = multi_array.make([2, 2], multi_array.float32)
>>> x.set(numpy.random.rand(2, 2))
>>> x.get()
array([[ 0.97381461,  0.22102854],
       [ 0.87702358,  0.76791102]], dtype=float32)
>>> x.reset()
>>> x.get()
array([[ 0.,  0.],
       [ 0.,  0.]], dtype=float32)returns a copy of the array stored in numpy.ndarray.
numpy.ndarray x.get()
Example
>>> x = multi_array.make(4, multi_array.float32)
>>> x[1] = 10
>>> x.get()
array([  0.,  10.,   0.,   0.], dtype=float32)resets the array with values from a numpy.ndarray.
x.set(numpy.ndarray nd)
Example
>>> x = multi_array.make([2, 2], multi_array.float32)
>>> x.set(numpy.array([[1, 2], [3, 4]]))
>>> x.get()
array([[ 1.,  2.],
       [ 3.,  4.]], dtype=float32)returns the value at the supplied index.
[numeric_type] x[index]
Example
>>> x = multi_array.make(4, multi_array.float32)
>>> x[1] = 10
>>> x[1]
10.0resets the value at the index.
x[index] = [numeric_type]
Example
>>> x = multi_array.make(4, multi_array.float32)
>>> x[1] = 10
>>> x.get()
array([  0.,  10.,   0.,   0.], dtype=float32)