Methods
abs(x) → {NDArray}
Returns the absolute value of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { abs } from 'vectorious/core/abs';
abs([-1, -2, -3]) // => array([1, 2, 3])
Source
acos(x) → {NDArray}
Returns the arccosine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { acos } from 'vectorious/core/acos';
acos([-1, 0, 1]); // => array([3.141592653589793, 1.5707963267948966, 0])
Source
acosh(x) → {NDArray}
Returns the hyperbolic arccosine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { acosh } from 'vectorious/core/acosh';
acosh([1, 2, 3]); // => array([0, 1.316957950592041, 1.7627471685409546])
Source
add(x, y) → {NDArray}
Adds y
multiplied by alpha
to x
.
Accelerated with BLAS ?axpy
.
Parameters
Returns
-
NDArray
Example
import { add } from 'vectorious/core/add';
add([1, 2, 3], [4, 5, 6]); // => array([5, 7, 9])
Source
angle(x, y) → {number}
Determines the angle between the x
and y
Parameters
Returns
-
number
Example
import { angle } from 'vectorious/core/angle';
angle([1, 2, 3], [4, 5, 6]); // => 0.22572622788897287
Source
array() → {NDArray}
array(...args)
is an alias for new v(...args)
Parameters
- ...args
Returns
-
NDArray
Example
import { array } from 'vectorious/core/array';
array([1, 2, 3]); // => array([1, 2, 3])
Source
asin(x) → {NDArray}
Returns the arcsine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { asin } from 'vectorious/core/asin';
asin([-1, 0, 1]) // => array([-1.5707963705062866, 0, 1.5707963705062866])
Source
asinh(x) → {NDArray}
Returns the hyperbolic arcsine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { asinh } from 'vectorious/core/asinh';
asinh([0, 1, 2]) // => array([0, 0.8813735842704773, 1.4436354637145996])
Source
atan(x) → {NDArray}
Returns the arctangent of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { atan } from 'vectorious/core/atan';
atan([1, 2, 3]); // => array([0.7853981852531433, 1.1071487665176392, 1.249045729637146])
Source
atanh(x) → {NDArray}
Returns the hyperbolic arctangent of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { atanh } from 'vectorious/core/atanh';
atanh([0, -0.5]); // => array([0, -0.5493061542510986])
Source
augment(x, y) → {NDArray}
Augments x
and y
.
Parameters
Returns
-
NDArray
Example
import { augment } from 'vectorious/core/augment';
augment([[1, 2], [3, 4]], [[1], [2]]); // => array([[1, 2, 1], [3, 4, 2]])
Source
binOp(x, y) → {NDArray}
Perform binary operation f
on y
in x
.
Parameters
Returns
-
NDArray
Example
import { binOp } from 'vectorious/core/binOp';
binOp([1, 2, 3], [4, 5, 6], (a, b) => a + b); // => array([[5, 7, 9])
Source
cbrt(x) → {NDArray}
Returns the cube root of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { cbrt } from 'vectorious/core/cbrt';
cbrt([1, 8, 27]); // => array([1, 2, 3])
Source
ceil(x) → {NDArray}
Returns smallest integer greater than or equal to of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { ceil } from 'vectorious/core/ceil';
ceil([0.5, 1.5, 2.5]); // => array([1, 2, 3])
Source
check(x)
Asserts if indices i, j, ..., n
are within the bounds of x
Parameters
-
x
NDArray
-
...indices
Array.<Number>
Example
import { check } from 'vectorious/core/check';
check([0.5, 1.5, 2.5], 3); // Error: index out of bounds
Throws
-
index out of bounds
- Type
-
Error
Source
combine(x, y) → {NDArray}
Combines the vector x
with y
Parameters
Returns
-
NDArray
Example
import { combine } from 'vectorious/core/combine';
combine([1, 2, 3], [4, 5, 6]); // => array([1, 2, 3, 4, 5, 6])
Source
copy(x) → {NDArray}
Makes a copy of x
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { copy } from 'vectorious/core/copy';
copy([1, 2, 3]); // => array([1, 2, 3])
Source
cos(x) → {NDArray}
Returns the cosine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { cos } from 'vectorious/core/cos';
cos([0, Math.PI / 2, Math.PI]); // => array([1, 0, -1])
Source
cosh(x) → {NDArray}
Returns the hyperbolic cosine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { cosh } from 'vectorious/core/cosh';
cosh([0, 1, 2]); // => array([1, 1.5430806875228882, 3.762195587158203])
Source
cross(x, y) → {NDArray}
Computes the cross product of the x
and the vector y
This operation can only calculated for vectors with three components.
Otherwise it throws an exception.
Parameters
Returns
-
NDArray
Example
import { cross } from 'vectorious/core/cross';
cross([1, 2, 3], [4, 5, 6]); // => array([-3, 6, -3])
Source
det(x) → {Number}
Gets the determinant of x
.
Parameters
-
x
NDArray
Returns
-
Number
Example
import { det } from 'vectorious/core/det';
det([[0, 1], [2, 3]]); // => -2
Source
diagonal(x) → {NDArray}
Gets the diagonal of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { diagonal } from 'vectorious/core/diagonal';
diagonal([[1, 2], [3, 4]]); // => array([1, 4])
Source
dot(x, y) → {Number}
Performs dot multiplication with x
and y
.
Accelerated with BLAS ?dot
.
Parameters
Returns
-
Number
Example
import { dot } from 'vectorious/core/dot';
dot([1, 2, 3], [4, 5, 6]); // => 32
Source
eig(x) → {Array.<NDArray>}
Gets eigenvalues and eigenvectors of x
using the Jacobi method.
Accelerated with LAPACK ?geev
.
Parameters
-
x
NDArray
Returns
-
Array.<NDArray>
Example
import { eig } from 'vectorious/core/eig';
eig([[1, 0, 0], [0, 2, 0], [0, 0, 3]]); // => [array([1, 2, 3]), array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])]
Source
equals(x, y, tolerance) → {Boolean}
Checks if x
and y
are equal.
Parameters
Returns
-
Boolean
Example
import { equals } from 'vectorious/core/equals';
equals([1, 2, 3], [1, 2, 3]); // => true
Source
equidimensional(x, y)
Asserts if x
and y
have the same shape
Parameters
Deprecated
- Yes
Example
import { equidimensional } from 'vectorious/core/equidimensional';
equidimensional([1, 2, 3], [1, 2]); // Error: shapes 3 and 2 do not match
Throws
-
shapes x and y do not match
- Type
-
Error
Source
equilateral(x, y)
Asserts if x
and y
have the same length
Parameters
Deprecated
- Yes
Example
import { equilateral } from 'vectorious/core/equilateral';
equilateral([1, 2, 3], [1, 2]); // Error: lengths 3 and 2 do not match
Throws
-
lengths x and y do not match
- Type
-
Error
Source
exp(x) → {NDArray}
Returns e^x of each element of x
, where x is the argument,
and e is Euler's constant (2.718…), the base of the natural logarithm.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { exp } from 'vectorious/core/exp';
exp([1, 2, 3]); // => array([2.7182817459106445, 7.389056205749512, 20.08553695678711])
Source
expm1(x) → {NDArray}
Returns subtracting 1 from exp(x) of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { expm1 } from 'vectorious/core/expm1';
expm1([1, 2, 3]); // => array([1.7182817459106445, 6.389056205749512, 19.08553695678711])
Source
eye(n) → {NDArray}
Creates an identity matrix of size n
and type type
.
Parameters
-
n
Number
Returns
-
NDArray
Example
import { eye } from 'vectorious/core/eye';
eye(2); // => array([[1, 0], [0, 1]])
Source
fill(x, value) → {NDArray}
Fills x
with a scalar value
Parameters
-
x
NDArray
-
value
Number
Returns
-
NDArray
Example
import { fill } from 'vectorious/core/fill';
fill([1, 2, 3], 0); // => array([0, 0, 0])
Source
floor(x) → {NDArray}
Returns the largest integer less than or equal to a number of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { floor } from 'vectorious/core/floor';
floor([1.5, 2.5, 3.5]); // => array([1, 2, 3])
Source
forEach(x, f)
Equivalent to TypedArray.prototype.forEach
.
Parameters
-
x
NDArray
-
f
function
Example
import { forEach } from 'vectorious/core/forEach';
forEach([1, 2, 3], console.log);
// 1 0 [ 1, 2, 3 ]
// 2 1 [ 1, 2, 3 ]
// 3 2 [ 1, 2, 3 ]
Source
fround(x) → {NDArray}
Returns the nearest single precision float representation of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { fround } from 'vectorious/core/fround';
fround([-5.05, 5.05]); // => array([-5.050000190734863, 5.050000190734863])
Source
gauss(x) → {NDArray}
Gauss-Jordan elimination (i.e. returns the reduced row echelon form) of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { gauss } from 'vectorious/core/gauss';
gauss([[1, 2, 3], [4, 5, 6]]); // => array([[1, 0, -1], [-0, 1, 2]])
Source
get(x) → {Number}
Gets the element at i, j, ..., n
from x
Parameters
-
x
NDArray
-
...indices
Array.<Number>
Returns
-
Number
Example
import { get } from 'vectorious/core/get';
get([1, 2, 3], 2); // 3
Source
inv(x) → {NDArray}
Determines the inverse of x
.
Accelerated with LAPACK ?getrf
and ?getri
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { inv } from 'vectorious/core/inv';
inv([[2, -1, 0], [-1, 2, -1], [0, -1, 2]]); // => array([[0.75, 0.5, 0.25], [0.5, 1, 0.5], [0.25, 0.5, 0.75]])
Source
log(x) → {NDArray}
Returns the natural logarithm (log_e, also ln) of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { log } from 'vectorious/core/log';
log([1, 2, 3]); // => array([0, 0.6931471824645996, 1.0986123085021973])
Source
log1p(x) → {NDArray}
Returns the natural logarithm (log_e, also ln) of 1 + x for each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { log1p } from 'vectorious/core/log1p';
log1p([1, 2, 3]); // => array([0.6931471824645996, 1.0986123085021973, 1.3862943649291992])
Source
log2(x) → {NDArray}
Returns the base 2 logarithm of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { log2 } from 'vectorious/core/log2';
log2([1, 2, 4]); // => array([0, 1, 2])
Source
log10(x) → {NDArray}
Returns the base 10 logarithm of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { log10 } from 'vectorious/core/log10';
log10([10, 100, 1000]); // => array([1, 2, 3])
Source
lu(x) → {Array.<NDArray, Int32Array>}
Performs full LU decomposition on x
.
Accelerated with LAPACK ?getrf
.
Parameters
-
x
NDArray
Returns
-
Array.<NDArray, Int32Array>
Example
import { lu } from 'vectorious/core/lu';
lu([[1, 3, 5], [2, 4, 7], [1, 1, 0]]); // => [array([[1, 0, 0], [0.5, 1, 0], [0.5, -1, 1]]), array([[2, 4, 7], [0, 1, 1.5], [0, 0, -2]]), Int32Array([2, 2, 3])]
Source
lu_factor(x) → {Array.<(NDArray|Int32Array)>}
Performs LU factorization on x
.
Accelerated with LAPACK ?getrf
.
Parameters
-
x
NDArray
Returns
-
Array.<(NDArray|Int32Array)>
Example
import { lu_factor } from 'vectorious/core/lu_factor';
lu_factor([[1, 3, 5], [2, 4, 7], [1, 1, 0]]); // => [array([[2, 4, 7], [0.5, 1, 1.5], [0.5, -1, -2]]), Int32Array([2, 2, 3])]
Source
magic(n) → {NDArray}
Creates a magic square matrix of size n
Parameters
-
n
Number
Returns
-
NDArray
Example
import { magic } from 'vectorious/core/magic';
magic(3); // => array([[8, 1, 6], [3, 5, 7], [4, 9, 2]])
Source
map(x) → {NDArray}
Equivalent to TypedArray.prototype.map
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { map } from 'vectorious/core/map';
map([1, 2, 3], value => -value); // => array([-1, -2, -3])
Source
matrix(r, c) → {NDArray}
Creates a matrix of r
rows and c
columns.
Parameters
-
r
Number
-
c
Number
Returns
-
NDArray
Example
import { matrix } from 'vectorious/core/matrix';
matrix(2, 2); // => array([[0, 0], [0, 0]])
Source
max(x) → {Number}
Gets the maximum value (largest) element of x
.
Accelerated with BLAS i?amax
.
Parameters
-
x
NDArray
Returns
-
Number
Example
import { max } from 'vectorious/core/max';
max([1, 2, 3]); // => 3
Source
mean(x) → {Number}
Gets the arithmetic mean of x
.
Parameters
-
x
NDArray
Returns
-
Number
Example
import { mean } from 'vectorious/core/mean';
mean([1, 2, 3]); // => 2
Source
min(x) → {Number}
Gets the minimum value (smallest) element of x
.
Parameters
-
x
NDArray
Returns
-
Number
Example
import { min } from 'vectorious/core/min';
min([1, 2, 3]); // => 1
Source
multiply(x, y) → {NDArray}
Multiplies two matrices x
and y
of matching dimensions.
Accelerated with BLAS ?gemm
.
Parameters
Returns
-
NDArray
Example
import { multiply } from 'vectorious/core/multiply';
multiply([[1, 2]], [[1], [2]]); // => array([[5]])
Source
norm(x) → {Number}
Calculates the norm of current array (also called L2 norm or Euclidean length).
Accelerated with BLAS ?nrm2
.
Parameters
-
x
NDArray
Returns
-
Number
Example
import { norm } from 'vectorious/core/norm';
norm([1, 2, 3]); // => 3.7416574954986572
Source
normalize(x) → {NDArray}
Normalizes x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { normalize } from 'vectorious/core/normalize';
normalize([1, 2, 3]); // => array([0.26726123690605164, 0.5345224738121033, 0.8017836809158325])
Source
ones() → {NDArray}
Creates an array containing ones (1
) of shape shape
Parameters
-
...shape
Array.<Number>
Returns
-
NDArray
Example
import { ones } from 'vectorious/core/ones';
ones(3); // => array([1, 1, 1])
Source
pow(x, exponent) → {NDArray}
Returns each element of x
to the exponent power, that is, element^exponent.
Parameters
-
x
NDArray
-
exponent
Number
Returns
-
NDArray
Example
import { pow } from 'vectorious/core/pow';
pow([1, 2, 3], 2); // => array([1, 4, 9])
Source
prod(x) → {Number}
Product of all elements of x
.
Parameters
-
x
NDArray
Returns
-
Number
Example
import { prod } from 'vectorious/core/prod';
prod([1, 2, 3]); // => 6
Source
product(x, y) → {NDArray}
Hadamard product of x
and y
Parameters
Returns
-
NDArray
Example
import { product } from 'vectorious/core/product';
product([1, 2, 3], [4, 5, 6]); // => array([4, 10, 18])
Source
project(x, y) → {NDArray}
Projects the y
onto x
using the projection formula (y * (x * y / y * y))
.
Parameters
Returns
-
NDArray
Example
import { project } from 'vectorious/core/project';
project([1, 2, 3], [4, 5, 6]); // => array([1.6623376607894897, 2.0779221057891846, 2.49350643157959])
Source
push(x, value) → {NDArray}
Pushes a new value
into x
.
Parameters
-
x
NDArray
-
value
Number
Returns
-
NDArray
Example
import { push } from 'vectorious/core/push';
push([1, 2, 3], 4); // => array([1, 2, 3, 4])
Source
random() → {NDArray}
Creates a vector containing random samples from a uniform distribution over [0, 1)
of shape shape
Parameters
-
...shape
Array.<Number>
Returns
-
NDArray
Example
import { random } from 'vectorious/core/random';
random(3); // => array([0.27496153116226196, 0.7581521272659302, 0.3682245910167694])
Source
range(start, step, stop) → {NDArray}
Creates an array containing a range (can be either ascending or descending)
of numbers specified by the arguments provided (e.g. NDArray.range(0, .5, 2)
gives an array containing all numbers in the interval [0, 2)
separated by
steps of 0.5
)
Parameters
-
start
Number
-
step
Number
-
stop
Number
Returns
-
NDArray
Example
import { range } from 'vectorious/core/range';
range(1, 2, 9); // => array([1, 3, 5, 7])
Source
rank(x, tolerance) → {Number}
Finds the rank of x
using gaussian elimination.
Parameters
-
x
NDArray
-
tolerance
Number
Returns
-
Number
Example
import { rank } from 'vectorious/core/rank';
rank([[1, 1, 1], [2, 2, 2], [3, 3, 3]]); // => 1
Source
reciprocal(x) → {NDArray}
Gets the element-wise reciprocal of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { reciprocal } from 'vectorious/core/reciprocal';
reciprocal([1, 2, 3]); // => array([1, 0.5, 0.3333333432674408])
Source
reduce(x, f, initialValue) → {Number}
Equivalent to TypedArray.prototype.reduce
.
Parameters
-
x
NDArray
-
f
function
-
initialValue
Number
Returns
-
Number
Example
import { reduce } from 'vectorious/core/reduce';
reduce([1, 2, 3], (a, b) => a + b, 0); // => 6
Source
reshape(x) → {NDArray}
Reshapes x
Parameters
-
x
NDArray
-
...shape
Array.<Number>
Returns
-
NDArray
Example
import { reshape } from 'vectorious/core/reshape';
reshape([1, 2, 3, 4], 2, 2); // => array([[1, 2], [3, 4]])
Source
round(x) → {NDArray}
Returns the value of each element of x
rounded to the nearest integer.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { round } from 'vectorious/core/round';
round([1.2, 2.8, 3.5]); // => array([1, 3, 4])
Source
row_add(x, dest, source, scalar) → {NDArray}
Adds a multiple of one row multiplied by scalar
to another inside x
.
Parameters
-
x
NDArray
-
dest
Number
-
source
Number
-
scalar
Number
Returns
-
NDArray
Example
import { row_add } from 'vectorious/core/row_add';
row_add([[1, 2], [3, 4]], 1, 0, 2); // => array([[1, 2], [5, 8]])
Source
scale(x, scalar) → {NDArray}
Multiplies all elements of x
with a specified scalar
.
Accelerated with BLAS ?scal
.
Parameters
-
x
NDArray
-
scalar
Number
Returns
-
NDArray
Example
import { scale } from 'vectorious/core/scale';
scale([1, 2, 3], 2); // => array([2, 4, 6])
Source
set(x, value) → {NDArray}
Sets the element at i, j, ..., n
to value
.
Parameters
-
x
NDArray
-
...indices
Array.<Number>
-
value
Number
Returns
-
NDArray
Example
import { set } from 'vectorious/core/set';
set([1, 2, 3], 1, 0); // => array([1, 0, 3])
Source
sign(x) → {NDArray}
Returns the sign of each element of x
, indicating
whether it is positive, negative or zero.
Parameters
-
x
Number
Returns
-
NDArray
Example
import { sign } from 'vectorious/core/sign';
sign([1, 2, 3]); // => array([1, 1, 1])
Source
sin(x) → {NDArray}
Returns the sine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { sin } from 'vectorious/core/sin';
sin([0, Math.PI / 2, Math.PI]); // => array([0, 1, 0])
Source
sinh(x) → {NDArray}
Returns the hyperbolic sine of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { sinh } from 'vectorious/core/sinh';
sinh([1, 2, 3]); // => array([1.175201177597046, 3.6268603801727295, 10.017874717712402])
Source
slice(x, begin, end, step) → {NDArray}
Slices x
in the corresponding dimension
Parameters
-
x
NDArray
-
begin
Number
-
end
Number
-
step
Number
Returns
-
NDArray
Example
import { slice } from 'vectorious/core/slice';
slice([1, 2, 3, 4], 0, 4, 2); // => array([1, 3])
Source
solve(x, y) → {NDArray}
Solves the equation AX = B (where A is x
and B is y
).
Accelerated with LAPACK ?gesv
.
Parameters
Returns
-
NDArray
Example
import { solve } from 'vectorious/core/solve';
solve([[1, 3, 5], [2, 4, 7], [1, 1, 0]], [[1], [3], [5]]); // => array([[3.25], [1.75], [-1.5]])
Source
sqrt(x) → {NDArray}
Returns the positive square root of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { sqrt } from 'vectorious/core/sqrt';
sqrt([1, 4, 9]); // => array([1, 2, 3])
Source
square(x)
Asserts if x
is square.
Parameters
-
x
NDArray
Example
import { square } from 'vectorious/core/square';
square([1, 2, 3]); // Error: matrix is not square
Throws
-
matrix is not square
- Type
-
Error
Source
subtract(x) → {NDArray}
Subtracts y
from x
.
Accelerated with BLAS ?axpy
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { subtract } from 'vectorious/core/subtract';
subtract([1, 2, 3], [1, 1, 1]); // => array([0, 1, 2])
Source
sum(x) → {Number}
Sum of x
Parameters
-
x
NDArray
Returns
-
Number
Example
import { sum } from 'vectorious/core/sum';
sum([1, 2, 3]); // => 6
Source
swap(x, i, j) → {NDArray}
Swaps two rows i
and j
in x
.
Parameters
-
x
NDArray
-
i
Number
-
j
Number
Returns
-
NDArray
Example
import { swap } from 'vectorious/core/swap';
swap([[1, 2], [3, 4]], 0, 1); // => array([[3, 4], [1, 2]])
Source
tan(x) → {NDArray}
Returns the tangent of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { tan } from 'vectorious/core/tan';
tan([1, 2, 3]); // => array([1.5574077367782593, -2.185039758682251, -0.14254654943943024])
Source
tanh(x) → {NDArray}
Returns the hyperbolic tangent of each element of x
.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { tanh } from 'vectorious/core/tanh';
tanh([1, 2, 3]); // => array([0.7615941762924194, 0.9640275835990906, 0.9950547814369202])
Source
toArray(x) → {Array}
Converts x
into a JavaScript array.
Parameters
-
x
NDArray
Returns
-
Array
Example
import { toArray } from 'vectorious/core/toArray';
toArray([1, 2, 3]); // => [1, 2, 3]
Source
toString(x) → {String}
Converts x
into a readable formatted string.
Parameters
-
x
NDArray
Returns
-
String
Example
import { toString } from 'vectorious/core/toString';
toString([1, 2, 3]); // => '1,2,3'
Source
trace(x) → {Number}
Gets the trace of x
(the sum of all diagonal elements).
Parameters
-
x
NDArray
Returns
-
Number
Example
import { trace } from 'vectorious/core/trace';
trace([[1, 2], [3, 4]]); // => 5
Source
transpose(x) → {NDArray}
Transposes x
(mirror across the diagonal).
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { transpose } from 'vectorious/core/transpose';
transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); // => array([[1, 4, 7], [2, 5, 8], [3, 6, 9]])
Source
trunc(x) → {NDArray}
Returns the integer part of each element of x
,
removing any fractional digits.
Parameters
-
x
NDArray
Returns
-
NDArray
Example
import { trunc } from 'vectorious/core/trunc';
trunc([1.2, 2.8, 3.5]); // => array([1, 2, 3])
Source
zeros() → {NDArray}
Creates an array containing zeros (0
) of shape shape
Parameters
-
...shape
Array.<Number>
Returns
-
NDArray
Example
import { zeros } from 'vectorious/core/zeros';
zeros(3); // => array([0, 0, 0])