Skip to main content

Nada Array Operators

Arithmetic Operators

OperatorExampleOperation
+array1 + array2Element-wise addition with broadcasting.
-array1 - array2Element-wise subtraction with broadcasting.
*array1 * array2Element-wise multiplication with broadcasting.
/array1 / array2Element-wise division with broadcasting.
@array1 @ array2Matrix multiplication with another NadaArray.
+=array1 += array2Inplace element-wise addition with broadcasting.
-=array1 -= array2Inplace element-wise subtraction with broadcasting.
*=array1 *= array2Inplace element-wise multiplication with broadcasting.
/=array1 /= array2Inplace element-wise division with broadcasting.
@=array1 @= array2Inplace matrix multiplication with another NadaArray.

Logical Operators

OperatorExampleOperation
==array1 == array2Element-wise equality comparison.
<array1 < array2Element-wise less than comparison.
<=array1 <= array2Element-wise less than or equal to comparison.
>array1 > array2Element-wise greater than comparison.
>=array1 >= array2Element-wise greater than or equal to comparison.
-array-array1Element-wise negation.
array ** narray1 ** nElement-wise exponentiation.

Other Operators

OperatorExampleOperation
compressarray.compress(condition)Compress elements based on condition.
copyarray.copy()Create a copy of the array.
cumprodarray.cumprod()Cumulative product of elements.
cumsumarray.cumsum()Cumulative sum of elements.
diagonalarray.diagonal(offset=1)Retrieve diagonal elements.
fillarray.fill(value)Fill array with a scalar value.
flattenarray.flatten()Flatten array into a 1D array.
itemarray.item(index)Get item at specified index.
itemsetarray.itemset(index, value)Set item at specified index to value.
prodarray.prod()Product of all elements.
putarray.put(indices, values)Put values into specified indices.
ravelarray.ravel()Flatten array into a 1D array.
reshapearray.reshape(shape)Reshape array to specified shape.
resizearray.resize(new_shape)Resize array to new shape.
squeezearray.squeeze()Remove single-dimensional entries from shape.
sumarray.sum()Sum of all elements.
swapaxesarray.swapaxes(axis1, axis2)Swap two axes of the array.
takearray.take(indices)Take elements from array at specified indices.
tolistarray.tolist()Convert array to a Python list.
tracearray.trace(offset=0)Compute the trace of the array.
transposearray.transpose()Transpose array dimensions.
basearray.baseBase object of the array.
dataarray.dataData pointer to the array's memory.
flagsarray.flagsInformation about the memory layout of the array.
flatarray.flat1D iterator over the array.
itemsizearray.itemsizeSize of a single element in bytes.
nbytesarray.nbytesTotal bytes consumed by the array's elements.
ndimarray.ndimNumber of array dimensions.
shapearray.shapeShape of the array.
sizearray.sizeNumber of elements in the array.
stridesarray.stridesStrides of the array.
Tarray.TTransposed view of the array.

For more examples, please visit our Github Repository Examples.