NArray Methods
NArray comes with a lot of methods to help your perform numerical operations.
transpose
Returns transpose of the NArray.
flatten
Returns Array which is a flattened version of the NArray.
get
It either returns an Array with elements or the element found at the specified path.
Calling it without any path specified will return the whole Array in the shape of an NArray.
It is a costly function and takes more time than any other function.
You can also use negative index to get element
map
Works similar to Array.prototype.map
add
It can be used to add 2 NArrays of the same size or can be used to increment NArray by a specified number
Note: For this operation to work both the NArrays should have same number of elements or an error will be thrown
sub
It can be used to subtract 2 NArrays of the same size or can be used to decrement NArray by a specified number
Note: For this operation to work both the NArrays should have same number of elements or an error will be thrown
mul
It can be used to multiply 2 NArrays of the same size as each other or can be used to multiply NArray by a specified number
Note: For this operation to work both the NArrays should have same number of elements or an error will be thrown
div
It can be used to divide 2 NArrays of the same size as each other or can be used to divide NArray by a specified number
Note: For this operation to work both the NArrays should have same number of elements or an error will be thrown
pow
It can be used to raise 2 NArrays of the same size as each other or can be used to raise NArray by a specified number
Note: For this operation to work both the NArrays should have same number of elements or an error will be thrown
dot
Performs dot multiplication of NArrays.
- If both NArrays are 1d then it uses mul(y)
- If any of the NArray.ndim >= 2 then normal matrix dot product is done
jsonify
Returns a pretty-print version of the NArray.
sum
Returns the sum of the elements of NArray.
- If the axis is not defined, returns the sum of all elements,
- If the axis is defined, returns the sum of elements for the axis
max
Returns the max element and its index as object.
diag
Returns diagonal matrix, only works on 1 and 2-d NArrays.
toString()
Returns string version of the NArray object.
The returned string version will be truncated based on printThreshold