new NdArray()
Multidimensional, homogeneous array of fixed-size items
The number of dimensions and items in an array is defined by its shape, which is a tuple of N positive
integers that specify the sizes of each dimension. The type of items in the array is specified by a separate
data-type object (dtype), one of which is associated with each NdArray.
- Source:
Members
dtype
Data-type of the array’s elements.
Properties:
Type | Description |
---|---|
String |
- Source:
- See:
-
- {dtypes} for more information
inspect
Stringify the array to make it readable in the console, by a human.
- Source:
(readonly) ndim
Number of array dimensions.
Properties:
Type | Description |
---|---|
Number |
- Source:
(readonly) shape
The shape of the array
Properties:
Type | Description |
---|---|
Array |
- Source:
(readonly) T
Permute the dimensions of the array.
Properties:
Type | Description |
---|---|
String |
- Source:
Methods
add(x, copyopt) → {NdArray}
Add `x` to the array, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
NdArray | Array | number | |||
copy |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- NdArray
assign(x, copyopt) → {NdArray}
Assign `x` to the array, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
NdArray | Array | number | |||
copy |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- NdArray
clone() → {NdArray}
Create a full copy of the array
- Source:
Returns:
- Type
- NdArray
convolve(filter)
Returns the discrete, linear convolution of the array using the given filter.
Parameters:
Name | Type | Description |
---|---|---|
filter |
Array | NdArray |
- Source:
divide(x, copyopt) → {NdArray}
Divide array by `x`, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
NdArray | Array | number | |||
copy |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- NdArray
dot(x) → {NdArray}
Dot product of two arrays.
Parameters:
Name | Type | Description |
---|---|---|
x |
Array | NdArray |
- Source:
Returns:
- Type
- NdArray
equal(array) → {boolean}
Return true if two arrays have the same shape and elements, false otherwise.
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | NdArray |
- Source:
Returns:
- Type
- boolean
exp(copyopt) → {NdArray}
Calculate the exponential of all elements in the array, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
copy |
boolean |
<optional> |
true | set to false to modify the array rather than create a new one |
- Source:
Returns:
- Type
- NdArray
flatten() → {NdArray}
Return a copy of the array collapsed into one dimension using row-major order (C-style)
- Source:
Returns:
- Type
- NdArray
hi() → {NdArray}
Return a sliced view of the array.
- Source:
Returns:
- Type
- NdArray
Example
arr = nj.arange(4*4).reshape(4,4)
// array([[ 0, 1, 2, 3],
// [ 4, 5, 6, 7],
// [ 8, 9, 10, 11],
// [ 12, 13, 14, 15]])
arr.hi(3,3)
// array([[ 0, 1, 2],
// [ 4, 5, 6],
// [ 8, 9, 10]])
arr.lo(1,1).hi(2,2)
// array([[ 5, 6],
// [ 9, 10]])
lo() → {NdArray}
Return a shifted view of the array. Think of it as taking the upper left corner of the image and dragging it inward
- Source:
Returns:
- Type
- NdArray
Example
arr = nj.arange(4*4).reshape(4,4)
// array([[ 0, 1, 2, 3],
// [ 4, 5, 6, 7],
// [ 8, 9, 10, 11],
// [ 12, 13, 14, 15]])
arr.lo(1,1)
// array([[ 5, 6, 7],
// [ 9, 10, 11],
// [ 13, 14, 15]])
log(copyopt) → {NdArray}
Calculate the natural logarithm of all elements in the array, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
copy |
boolean |
<optional> |
true | set to false to modify the array rather than create a new one |
- Source:
Returns:
- Type
- NdArray
max() → {Number}
Return the maximum value of the array
- Source:
Returns:
- Type
- Number
mean() → {number}
Return the arithmetic mean of array elements.
- Source:
Returns:
- Type
- number
min() → {Number}
Return the minimum value of the array
- Source:
Returns:
- Type
- Number
mod(x, copyopt) → {NdArray}
Return element-wise remainder of division.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
NdArray | Array | number | |||
copy |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- NdArray
multiply(x, copyopt) → {NdArray}
Multiply array by `x`, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
NdArray | Array | number | |||
copy |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- NdArray
negative() → {NdArray}
Return the inverse of the array, element-wise.
- Source:
Returns:
- Type
- NdArray
pick(…axis) → {NdArray}
Return a subarray by fixing a particular axis
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
axis |
number | null |
<repeatable> |
- Source:
Returns:
- Type
- NdArray
Example
arr = nj.arange(4*4).reshape(4,4)
// array([[ 0, 1, 2, 3],
// [ 4, 5, 6, 7],
// [ 8, 9, 10, 11],
// [ 12, 13, 14, 15]])
arr.pick(1)
// array([ 4, 5, 6, 7])
arr.pick(null, 1)
// array([ 1, 5, 9, 13])
pow(x, copyopt) → {NdArray}
Raise array elements to powers from given array, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
NdArray | Array | number | |||
copy |
boolean |
<optional> |
true | set to false to modify the array rather than create a new one |
- Source:
Returns:
- Type
- NdArray
reshape(The) → {NdArray}
Gives a new shape to the array without changing its data.
Parameters:
Name | Type | Description |
---|---|---|
The |
Array | number | new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions. |
- Source:
Returns:
a new view object if possible, a copy otherwise,
- Type
- NdArray
round(copyopt) → {NdArray}
Round array to the to the nearest integer.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
copy |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- NdArray
sqrt(copyopt) → {NdArray}
Calculate the positive square-root of all elements in the array, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
copy |
boolean |
<optional> |
true | set to false to modify the array rather than create a new one |
- Source:
Returns:
- Type
- NdArray
std({ddof:0}) → {number}
Returns the standard deviation, a measure of the spread of a distribution, of the array elements.
Parameters:
Name | Type | Description |
---|---|---|
{ddof:0} |
object |
- Source:
Returns:
- Type
- number
subtract(x, copyopt) → {NdArray}
Subtract `x` to the array, element-wise.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
NdArray | Array | number | |||
copy |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- NdArray
sum() → {number}
Sum of array elements.
- Source:
Returns:
- Type
- number
toJSON() → {*}
Stringify object to JSON
- Source:
Returns:
- Type
- *
tolist() → {Array}
Converts {NdArray} to a native JavaScript {Array}
- Source:
Returns:
- Type
- Array
toString() → {string}
Stringify the array to make it readable by a human.
- Source:
Returns:
- Type
- string
transpose(…axesopt) → {NfdArray}
Permute the dimensions of the array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
axes |
number |
<optional> <repeatable> |
- Source:
Returns:
- Type
- NfdArray