Namespace NumSharp
Classes
- MethodImplOptionsConstants
Method implementation option constants for use with MethodImplAttribute.
- NDArray
An array object represents a multidimensional, homogeneous array of fixed-size items.
An associated data-type object describes the format of each element in the array (its byte-order,
how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)
- NumPyRandom
A class that serves as numpy.random.RandomState in python.
- Randomizer
Represents a pseudo-random number generator, which is a device that produces a sequence of numbers that meet certain statistical requirements for randomness.
Equivalent of Random.
- Slice
<br />NDArray can be indexed using slicing
A slice is constructed by start:stop:step notation
Examples:
a[start:stop] # items start through stop-1
a[start:] # items start through the rest of the array
a[:stop] # items from the beginning through stop-1
The key point to remember is that the :stop value represents the first value that is not
in the selected slice. So, the difference between stop and start is the number of elements
selected (if step is 1, the default).
There is also the step value, which can be used with any of the above:
a[:] # a copy of the whole array
a[start:stop:step] # start through not past stop, by step
The other feature is that start or stop may be a negative number, which means it counts
from the end of the array instead of the beginning. So:
a[-1] # last item in the array
a[-2:] # last two items in the array
a[:-2] # everything except the last two items
Similarly, step may be a negative number:
a[::- 1] # all items in the array, reversed
a[1::- 1] # the first two items, reversed
a[:-3:-1] # the last two items, reversed
a[-3::- 1] # everything except the last two items, reversed
NumSharp is kind to the programmer if there are fewer items than
you ask for. For example, if you ask for a[:-2] and a only contains one element, you get an
empty list instead of an error.Sometimes you would prefer the error, so you have to be aware
that this may happen.
Adapted from Greg Hewgill's answer on Stackoverflow: https://stackoverflow.com/questions/509211/understanding-slice-notation
Note: special IsIndex == true
It will pick only a single value at Start in this dimension effectively reducing the Shape of the sliced matrix by 1 dimension.
It can be used to reduce an N-dimensional array/matrix to a (N-1)-dimensional array/matrix
Example:
a=[[1, 2], [3, 4]]
a[:, 1] returns the second column of that 2x2 matrix as a 1-D vector
- np
API bridge between NumSharp and Python NumPy
Structs
- NativeRandomState
Represents the stored state of Randomizer.
- Shape
Represents a shape of an N-D array. Immutable after construction (NumPy-aligned).
Interfaces
- IIndex
Represents a class that can be served as an index, e.g. ndarray[new Slice(...)]
Enums
- ArrayFlags
NumPy-aligned array flags. Cached at shape creation for O(1) access. Matches numpy/core/include/numpy/ndarraytypes.h flag definitions.
- NPTypeCode
Represents all available types in numpy.