Home Reference Source Repository

Function

Static Public Summary
public

Pointwise Math.abs(x)

public

Pointwise Math.acos(x)

public

Pointwise add

public

Pointwise and

public

Pointwise Math.asin(x)

public

Pointwise Math.atan(x)

public

Pointwise Math.atan2(x, y)

public

Pointwise band

public

Pointwise Math.bnot(x)

public

Pointwise bor

public

Pointwise bxor

public

Pointwise Math.ceil(x)

public

Pointwise clone(x)

public

Pointwise Math.cos(x)

public

Determinant of matix

public

Create diagonal matrix from vector

public

dim(x: Array): Array

Get Array dimensions

public

Pointwise div

public

dot(x: Array | Number, y: Array | Number): Array | Number

public

eig(A: any, maxiter: any): *

Eigenvalues of real matrices

public

Pointwise eq

public

Pointwise Math.exp(x)

public

fft(m: any): *

Fast Fourier transform

public

Pointwise Math.floor(x)

public

Pointwise geq

public

getBlock(x: Array, from: Array, to: Array): Array

Extract a block from a matrix

public
Get the diagonal of a matrix
public

Pointwise gt

public

Generate identity matrix of given size

public

ifft(m: any): *

Inverse FFT

public

inv(x: Array): Array

Inverse of an matrix

public

Pointwise leq

public

Generate evenly spaced values

public

Pointwise Math.log(x)

public

Pointwise lshift

public

Pointwise lt

public

Pointwise mod

public

Pointwise mul

public

Pointwise Math.neg(x)

public

negtranspose(x: any): *

neg transpose

public

Pointwise neq

public

Square root of the sum of the squares of the entries of x

public

Pointwise Math.not(x)

public

Sum of the squares of the entries of x

public

Pointwise or

public

Create a pointwise function

public

Create a pointwise function of two arguments

public

Pointwise Math.pow(x, y)

public

random(size: Array): Array

Create an Array of random numbers

public

reciprocal(): *

public

rep(s: Array, v: Array): Array

Create an Array by duplicating values

public

Pointwise Math.round(x)

public

Pointwise rrshift

public

Pointwise rshift

public

same(x: Array, y: Array): Boolean

x and y are entrywise identical 
public

setBlock(x: Array, from: Array, to: Array, B: Array): Array

Set a block of a matrix

public

Pointwise Math.sin(x)

public

Create pointwise function for sparse matrix operating on none zero arguments

public

spPointwise2(fun: *): *

public

Pointwise Math.sqrt(x)

public

Pointwise sub

public

sup(x: *, s: *, k: *): *

public

Pointwise Math.tan(x)

public

Tensor product ret[i][j] = x[i]*y[j]

public

Matrix transpose

Static Public

public abs(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import abs from 'mathlab/src/abs.js'

Pointwise Math.abs(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


abs(-1) // 1
abs([1, -2]) // [1, 2]
abs([[-1,2],[1,-3]]) // [[1,2],[1,3]]

public acos(m: Number | Array | Sparse): Number | Array | Sparse source

import acos from 'mathlab/src/acos.js'

Pointwise Math.acos(x)

Params:

NameTypeAttributeDescription
m Number | Array | Sparse

Return:

Number | Array | Sparse

Example:


acos(1) // Math.acos(1)
acos([1, 2]) // [Math.acos(1), Math.acos(2)]
acos([[1,2],[1,3]]) // [ [Math.acos(1), Math.acos(2)], [Math.acos(1), Math.acos(3)] ]

public add(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import add from 'mathlab/src/add.js'

Pointwise add

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


add(1, 2) // 3
add([1, 2], [2, 2]) // [3, 4]
add([[2,1], [1,2]], [[2, 2], [2, 2]])) // [ [2 + 2, 1 + 2], [1 + 2, 2 + 2] ]

public and(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import and from 'mathlab/src/and.js'

Pointwise and

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


and(1, 0) // 0
and([1, 1], [1, 0]) // [1, 0]
and([[1,1], [1,1]], [[1,0], [0,0]])) // [[1,0], [0,0]]

public asin(m: Number | Array | Sparse): Number | Array | Sparse source

import asin from 'mathlab/src/asin.js'

Pointwise Math.asin(x)

Params:

NameTypeAttributeDescription
m Number | Array | Sparse

Return:

Number | Array | Sparse

Example:


asin(1) // Math.asin(1)
asin([1, 2]) // [Math.asin(1), Math.asin(2)]
asin([[1,2],[1,3]]) // [ [Math.asin(1), Math.asin(2)], [Math.asin(1), Math.asin(3)] ]

public atan(m: Number | Array | Sparse): Number | Array | Sparse source

import atan from 'mathlab/src/atan.js'

Pointwise Math.atan(x)

Params:

NameTypeAttributeDescription
m Number | Array | Sparse

Return:

Number | Array | Sparse

Example:


atan(1) // Math.atan(1)
atan([1, 2]) // [Math.atan(1), Math.atan(2)]
atan([[1,2],[1,3]]) // [ [Math.atan(1), Math.atan(2)], [Math.atan(1), Math.atan(3)] ]

public atan2(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import atan2 from 'mathlab/src/atan2.js'

Pointwise Math.atan2(x, y)

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


atan2(1, 2) // Math.atan2(1, 2)
atan2([1, 2], [2, 2]) // [Math.atan2(1, 2), Math.atan2(2, 2)]
atan2([[2,1], [1,2]], [[2, 2], [2, 2]])) // [ [Math.atan2(2, 2), Math.atan2(1, 2)], [Math.atan2(1, 2), Math.atan2(2, 2)] ]

public band(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import band from 'mathlab/src/band.js'

Pointwise band

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


band(1, 2) // 1 & 2
band([1, 2], [2, 2]) // [1 & 2, 2 & 2]
band([[2,1], [1,2]], [[2, 2], [2, 2]])) // [ [2 & 2, 1 & 2], [1 & 2, 2 & 2] ]

public bnot(m: Number | Array | Sparse): Number | Array | Sparse source

import bnot from 'mathlab/src/bnot.js'

Pointwise Math.bnot(x)

Params:

NameTypeAttributeDescription
m Number | Array | Sparse

Return:

Number | Array | Sparse

Example:


bnot(1) // ~1
bnot([1, 2]) // [~1, ~2]
bnot([[1,2],[1,3]]) // [[~1,~2],[~1,~3]]

public bor(m1: Number | Array | Sparse, m2: Number | Array | Sparse): Number | Array | Sparse source

import bor from 'mathlab/src/bor.js'

Pointwise bor

Params:

NameTypeAttributeDescription
m1 Number | Array | Sparse
m2 Number | Array | Sparse

Return:

Number | Array | Sparse

Example:


bor(1, 2) // 1 | 2
bor([1, 2], [2, 2]) // [1 | 2, 2 | 2]
bor([[2,1], [1,2]], [[2, 2], [2, 2]])) // [ [2 | 2, 1 | 2], [1 | 2, 2 | 2] ]

public bxor(m1: Number | Array | Sparse, m2: Number | Array | Sparse): Number | Array | Sparse source

import bxor from 'mathlab/src/bxor.js'

Pointwise bxor

Params:

NameTypeAttributeDescription
m1 Number | Array | Sparse
m2 Number | Array | Sparse

Return:

Number | Array | Sparse

Example:


bxor(1, 2) // 1 ^ 2
bxor([1, 2], [2, 2]) // [1 ^ 2, 2 ^ 2]
bxor([[2,1], [1,2]], [[2, 2], [2, 2]])) // [ [2 ^ 2, 1 ^ 2], [1 ^ 2, 2 ^ 2] ]

public ceil(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import ceil from 'mathlab/src/ceil.js'

Pointwise Math.ceil(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


ceil(1) // Math.ceil(1)
ceil([1, 2]) // [Math.ceil(1), Math.ceil(2)]
ceil([[1,2],[1,3]]) // [ [Math.ceil(1), Math.ceil(2)], [Math.ceil(1), Math.ceil(3)] ]

public clone(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import clone from 'mathlab/src/clone.js'

Pointwise clone(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


clone([[1,2],[1,3]]) // [[1,2],[1,3]]

public cos(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import cos from 'mathlab/src/cos.js'

Pointwise Math.cos(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


cos(1)
// returns Math.cos(1)
cos([1, 2])
// returns [Math.cos(1), Math.cos(2)]
cos([[1,2],[1,3]])
// returns [ [Math.cos(1), Math.cos(2)], [Math.cos(1), Math.cos(3)] ]

public det(x: Array): Number source

import det from 'mathlab/src/det.js'

Determinant of matix

Params:

NameTypeAttributeDescription
x Array

Return:

Number

Example:


det([[1, 2], [1, 2]])
// 0

public diag(d: Array): Array source

import diag from 'mathlab/src/diag.js'

Create diagonal matrix from vector

Params:

NameTypeAttributeDescription
d Array

Return:

Array

Example:


diag([1, 2])
// [[1, 0], 
//  [0, 2]]

public dim(x: Array): Array source

import dim from 'mathlab/src/dim.js'

Get Array dimensions

Params:

NameTypeAttributeDescription
x Array

Return:

Array

Example:


dim([[1, 2, 3], [1, 2, 2]])
// [2, 3]

public div(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import div from 'mathlab/src/div.js'

Pointwise div

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


div(1, 2)
// returns 1 / 2
div([1, 2], [2, 2])
// returns [1 / 2, 2 / 2]
div([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 / 2, 1 / 2], [1 / 2, 2 / 2] ]

public dot(x: Array | Number, y: Array | Number): Array | Number source

import dot from 'mathlab/src/dot.js'

Params:

NameTypeAttributeDescription
x Array | Number
y Array | Number

Return:

Array | Number

Example:


dot([[1, 1], [2, 1]], [1, 2])
// [3, 4]

dot([1, 2], 4)
// [4, 8]

public eig(A: any, maxiter: any): * source

import eig from 'mathlab/src/eig.js'

Eigenvalues of real matrices

Params:

NameTypeAttributeDescription
A any
maxiter any

Return:

*

public eq(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import eq from 'mathlab/src/eq.js'

Pointwise eq

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


eq(1, 2)
// returns 1 === 2
eq([1, 2], [2, 2])
// returns [1 === 2, 2 === 2]
eq([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 === 2, 1 === 2], [1 === 2, 2 === 2] ]

public exp(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import exp from 'mathlab/src/exp.js'

Pointwise Math.exp(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


exp(1)
// returns Math.exp(1)
exp([1, 2])
// returns [Math.exp(1), Math.exp(2)]
exp([[1,2],[1,3]])
// returns [ [Math.exp(1), Math.exp(2)], [Math.exp(1), Math.exp(3)] ]

public fft(m: any): * source

import {fft} from 'mathlab/src/fft.js'

Fast Fourier transform

Params:

NameTypeAttributeDescription
m any

Return:

*

public floor(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import floor from 'mathlab/src/floor.js'

Pointwise Math.floor(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


floor(1)
// returns Math.floor(1)
floor([1, 2])
// returns [Math.floor(1), Math.floor(2)]
floor([[1,2],[1,3]])
// returns [ [Math.floor(1), Math.floor(2)], [Math.floor(1), Math.floor(3)] ]

public geq(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import geq from 'mathlab/src/geq.js'

Pointwise geq

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


geq(1, 2)
// returns 1 >= 2
geq([1, 2], [2, 2])
// returns [1 >= 2, 2 >= 2]
geq([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 >= 2, 1 >= 2], [1 >= 2, 2 >= 2] ]

public getBlock(x: Array, from: Array, to: Array): Array source

import getBlock from 'mathlab/src/getBlock.js'

Extract a block from a matrix

Params:

NameTypeAttributeDescription
x Array
from Array

from position

to Array

to position

Return:

Array

Example:


getBlock([[1,2,3],
          [3,4,5]], [0,0], [1,1])
// [[1, 2],
    [3, 4]]

public getDiag(A: Array): Array source

import getDiag from 'mathlab/src/getDiag.js'
Get the diagonal of a matrix

Params:

NameTypeAttributeDescription
A Array

Return:

Array

Example:


getDiag([[1, 3], [0, 2]])
// [1, 2]

public gt(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import gt from 'mathlab/src/gt.js'

Pointwise gt

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


gt(1, 2)
// returns 1 > 2
gt([1, 2], [2, 2])
// returns [1 > 2, 2 > 2]
gt([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 > 2, 1 > 2], [1 > 2, 2 > 2] ]

public identity(n: Number): Array source

import identity from 'mathlab/src/identity.js'

Generate identity matrix of given size

Params:

NameTypeAttributeDescription
n Number

Return:

Array

Example:


identity(2)
// [[1, 0], [0, 1]]

public ifft(m: any): * source

import {ifft} from 'mathlab/src/fft.js'

Inverse FFT

Params:

NameTypeAttributeDescription
m any

Return:

*

public inv(x: Array): Array source

import inv from 'mathlab/src/inv.js'

Inverse of an matrix

Params:

NameTypeAttributeDescription
x Array

Return:

Array

Example:


inv([[1,2],[3,4]])
// [[   -2,    1],
//  [  1.5, -0.5]]

public leq(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import leq from 'mathlab/src/leq.js'

Pointwise leq

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


leq(1, 2)
// returns 1 <= 2
leq([1, 2], [2, 2])
// returns [1 <= 2, 2 <= 2]
leq([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 <= 2, 1 <= 2], [1 <= 2, 2 <= 2] ]

public linspace(a: Number, b: Number, n: Number): Array source

import linspace from 'mathlab/src/linspace.js'

Generate evenly spaced values

Params:

NameTypeAttributeDescription
a Number
b Number
n Number

Return:

Array

Example:


linspace(1, 2, 3)
// [1, 1.5, 2]

public log(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import log from 'mathlab/src/log.js'

Pointwise Math.log(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


log(1)
// returns Math.log(1)
log([1, 2])
// returns [Math.log(1), Math.log(2)]
log([[1,2],[1,3]])
// returns [ [Math.log(1), Math.log(2)], [Math.log(1), Math.log(3)] ]

public lshift(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import lshift from 'mathlab/src/lshift.js'

Pointwise lshift

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


lshift(1, 2)
// returns 1 << 2
lshift([1, 2], [2, 2])
// returns [1 << 2, 2 << 2]
lshift([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 << 2, 1 << 2], [1 << 2, 2 << 2] ]

public lt(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import lt from 'mathlab/src/lt.js'

Pointwise lt

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


lt(1, 2)
// returns 1 < 2
lt([1, 2], [2, 2])
// returns [1 < 2, 2 < 2]
lt([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 < 2, 1 < 2], [1 < 2, 2 < 2] ]

public mod(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import mod from 'mathlab/src/mod.js'

Pointwise mod

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


mod(1, 2)
// returns 1 % 2
mod([1, 2], [2, 2])
// returns [1 % 2, 2 % 2]
mod([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 % 2, 1 % 2], [1 % 2, 2 % 2] ]

public mul(m1: Number | Array | Complex | Sparse | Object, m2: Number | Array | Complex | Sparse | Object): Number | Array | Complex | Sparse source

import mul from 'mathlab/src/mul.js'

Pointwise mul

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse | Object
m2 Number | Array | Complex | Sparse | Object

Return:

Number | Array | Complex | Sparse

Example:


mul(1, 2)
// returns 1 * 2
mul([1, 2], [2, 2])
// returns [1 * 2, 2 * 2]
mul([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 * 2, 1 * 2], [1 * 2, 2 * 2] ]

public neg(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import neg from 'mathlab/src/neg.js'

Pointwise Math.neg(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


neg(1)
// returns Math.neg(1)
neg([1, 2])
// returns [Math.neg(1), Math.neg(2)]
neg([[1,2],[1,3]])
// returns [ [Math.neg(1), Math.neg(2)], [Math.neg(1), Math.neg(3)] ]

public negtranspose(x: any): * source

import negtranspose from 'mathlab/src/negtranspose.js'

neg transpose

Params:

NameTypeAttributeDescription
x any

Return:

*

public neq(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import neq from 'mathlab/src/neq.js'

Pointwise neq

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


neq(1, 2)
// returns 1 !== 2
neq([1, 2], [2, 2])
// returns [1 !== 2, 2 !== 2]
neq([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 !== 2, 1 !== 2], [1 !== 2, 2 !== 2] ]

public norm2(x: Array | Number): Number source

import norm2 from 'mathlab/src/norm2.js'

Square root of the sum of the squares of the entries of x

Params:

NameTypeAttributeDescription
x Array | Number

Return:

Number

Example:


norm2(2)
// 2
norm2([2,2])
// 2.828

public not(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import not from 'mathlab/src/not.js'

Pointwise Math.not(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


not(1)
// returns Math.not(1)
not([1, 2])
// returns [Math.not(1), Math.not(2)]
not([[1,2],[1,3]])
// returns [ [Math.not(1), Math.not(2)], [Math.not(1), Math.not(3)] ]

public nrom2Squared(x: Array | Number): Number source

import nrom2Squared from 'mathlab/src/norm2Squared.js'

Sum of the squares of the entries of x

Params:

NameTypeAttributeDescription
x Array | Number

Return:

Number

Example:


norm2Squared(2)
// 4
norm2Squared([2,2])
// 8

public or(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import or from 'mathlab/src/or.js'

Pointwise or

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


or(1, 2)
// returns 1 || 2
or([1, 2], [2, 2])
// returns [1 || 2, 2 || 2]
or([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 || 2, 1 || 2], [1 || 2, 2 || 2] ]

public pointwise(fun: Function): Function source

import pointwise from 'mathlab/src/pointwise.js'

Create a pointwise function

Params:

NameTypeAttributeDescription
fun Function

Return:

Function

Example:


function _inc (x) {
  return x + 1
}
const inc = pointwise(inc)
inc(1)                                  // 2
inc([1, 2])                             // [2, 3]
inc([[1, 2], [1, 3]])                   // [[2, 3], [2, 4]]

public pointwise2(fun: Function): Function source

import pointwise2 from 'mathlab/src/pointwise2.js'

Create a pointwise function of two arguments

Params:

NameTypeAttributeDescription
fun Function

Return:

Function

Example:


function _add (x, y) {
  return x + y
}
const add = pointwise(_add)
add(1, 2)                                // 3
add([1, 2], [1, 2])                      // [2, 4]
add([[1, 2], [1, 2]], [[1, 2], [1, 2]])  //[[2, 4], [2, 4]]

public pow(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import pow from 'mathlab/src/pow.js'

Pointwise Math.pow(x, y)

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


pow(1, 2)
// returns Math.pow(1, 2)
pow([1, 2], [2, 2])
// returns [Math.pow(1, 2), Math.pow(2, 2)]
pow([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [Math.pow(2, 2), Math.pow(1, 2)], [Math.pow(1, 2), Math.pow(2, 2)] ]

public random(size: Array): Array source

import random from 'mathlab/src/random.js'

Create an Array of random numbers

Params:

NameTypeAttributeDescription
size Array

of the random matrix

Return:

Array

array of random numbers

Example:


random([2, 3])
// [[0.05303,0.1537,0.7280],
    [0.3839,0.08818,0.6316]]

public reciprocal(): * source

import {reciprocal} from 'mathlab/src/reciprocal.js'

Return:

*

public rep(s: Array, v: Array): Array source

import rep from 'mathlab/src/rep.js'

Create an Array by duplicating values

Params:

NameTypeAttributeDescription
s Array

size of the Matrix

v Array

value

Return:

Array

Example:


rep([2,3], 0)
// [[0,0,0],
    [0,0,0]] 

rep([3], 5)
// [5,5,5]

public round(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import round from 'mathlab/src/round.js'

Pointwise Math.round(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


round(1)
// returns Math.round(1)
round([1, 2])
// returns [Math.round(1), Math.round(2)]
round([[1,2],[1,3]])
// returns [ [Math.round(1), Math.round(2)], [Math.round(1), Math.round(3)] ]

public rrshift(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import rrshift from 'mathlab/src/rrshift.js'

Pointwise rrshift

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


rrshift(1, 2)
// returns 1 >>> 2
rrshift([1, 2], [2, 2])
// returns [1 >>> 2, 2 >>> 2]
rrshift([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 >>> 2, 1 >>> 2], [1 >>> 2, 2 >>> 2] ]

public rshift(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import rshift from 'mathlab/src/rshift.js'

Pointwise rshift

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


rshift(1, 2)
// returns 1 >> 2
rshift([1, 2], [2, 2])
// returns [1 >> 2, 2 >> 2]
rshift([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 >> 2, 1 >> 2], [1 >> 2, 2 >> 2] ]

public same(x: Array, y: Array): Boolean source

import same from 'mathlab/src/same.js'
x and y are entrywise identical 

Params:

NameTypeAttributeDescription
x Array
y Array

Return:

Boolean

Example:


same([1,2], [1,2,3]) // false
same([1, 2], [1, 2]) // true

public setBlock(x: Array, from: Array, to: Array, B: Array): Array source

import setBlock from 'mathlab/src/setBlock.js'

Set a block of a matrix

Params:

NameTypeAttributeDescription
x Array
from Array
to Array
B Array

Return:

Array

Example:


setBlock([[1,2,3], [3,4,5]], [0,0], [1,1],[[2,2],[2,2]])
// [[2,2,3],[2,2,5]]

public sin(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import sin from 'mathlab/src/sin.js'

Pointwise Math.sin(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


sin(1)
// returns Math.sin(1)
sin([1, 2])
// returns [Math.sin(1), Math.sin(2)]
sin([[1,2],[1,3]])
// returns [ [Math.sin(1), Math.sin(2)], [Math.sin(1), Math.sin(3)] ]

public spPointwise(fun: Function): Function source

import spPointwise from 'mathlab/src/spPointwise.js'

Create pointwise function for sparse matrix operating on none zero arguments

Params:

NameTypeAttributeDescription
fun Function

Return:

Function

Example:


function _inc (x) {
  return x + 1
}
const inc = spPointwise(_inc)
inc(new Sparse([1,0],[0,0]))           // new Sparse([2,0],[0,0])

public spPointwise2(fun: *): * source

import spPointwise2 from 'mathlab/src/spPointwise2.js'

Params:

NameTypeAttributeDescription
fun *

Return:

*

public sqrt(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import sqrt from 'mathlab/src/sqrt.js'

Pointwise Math.sqrt(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


sqrt(1)
// returns Math.sqrt(1)
sqrt([1, 2])
// returns [Math.sqrt(1), Math.sqrt(2)]
sqrt([[1,2],[1,3]])
// returns [ [Math.sqrt(1), Math.sqrt(2)], [Math.sqrt(1), Math.sqrt(3)] ]

public sub(m1: Number | Array | Complex | Sparse, m2: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import sub from 'mathlab/src/sub.js'

Pointwise sub

Params:

NameTypeAttributeDescription
m1 Number | Array | Complex | Sparse
m2 Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


sub(1, 2)
// returns 1 - 2
sub([1, 2], [2, 2])
// returns [1 - 2, 2 - 2]
sub([[2,1], [1,2]], [[2, 2], [2, 2]]))
// returns [ [2 - 2, 1 - 2], [1 - 2, 2 - 2] ]

public sup(x: *, s: *, k: *): * source

import sup from 'mathlab/src/sup.js'

Params:

NameTypeAttributeDescription
x *
s *
k *

Return:

*

public tan(m: Number | Array | Complex | Sparse): Number | Array | Complex | Sparse source

import tan from 'mathlab/src/tan.js'

Pointwise Math.tan(x)

Params:

NameTypeAttributeDescription
m Number | Array | Complex | Sparse

Return:

Number | Array | Complex | Sparse

Example:


tan(1)
// returns Math.tan(1)
tan([1, 2])
// returns [Math.tan(1), Math.tan(2)]
tan([[1,2],[1,3]])
// returns [ [Math.tan(1), Math.tan(2)], [Math.tan(1), Math.tan(3)] ]

public tensor(x: Array | Number, y: Array | Number): Array | Number source

import tensor from 'mathlab/src/tensor.js'

Tensor product ret[i][j] = x[i]*y[j]

Params:

NameTypeAttributeDescription
x Array | Number
y Array | Number

Return:

Array | Number

Example:


tensor([1,2],[3,4])
// [[1,4],
//  [6,8]]

public transpose(x: Array): Array source

import transpose from 'mathlab/src/transpose.js'

Matrix transpose

Params:

NameTypeAttributeDescription
x Array

Return:

Array

Example:


transpose([[1,2,3],[4,5,6]])
//[[1,4],
// [2,5],
// [3,6]]