feat: extend all utils to vectors elementwise & fix parameter match grouping
This commit is contained in:
parent
f002310581
commit
3b882f3d53
5 changed files with 33 additions and 4 deletions
|
@ -18,6 +18,23 @@ describe('Vector utility functions', () => {
|
|||
assert(clone3[0] !== subj3[0])
|
||||
assert(clone3[1] !== subj3[1])
|
||||
})
|
||||
it('performs utilities elementwise', () => {
|
||||
const cplx = math.complex
|
||||
const sink = math.vector(
|
||||
NaN, -Infinity, 7,
|
||||
cplx(3, 4), cplx(3.5, -2.5), cplx(2.2), cplx(cplx(3, 4))
|
||||
)
|
||||
const t = true, f = false
|
||||
assert.deepStrictEqual(math.isnan(sink), [t, f, f, f, f, f, f])
|
||||
assert.deepStrictEqual(math.isfinite(sink), [f, f, t, t, t, t, t])
|
||||
assert.deepStrictEqual(math.isInteger(sink), [f, f, t, t, f, f, t])
|
||||
assert.deepStrictEqual(math.isReal(sink), [t, t, t, f, f, t, f])
|
||||
assert.deepStrictEqual(math.nonImaginary(sink), [t, t, t, f, f, t, t])
|
||||
assert.deepStrictEqual(math.re(sink), [NaN, -Infinity, 7, 3, 3.5, 2.2, 3])
|
||||
assert.deepStrictEqual(
|
||||
math.im(sink),
|
||||
[0, 0, 0, cplx(0, 4), cplx(0, -2.5), cplx(0, 0), cplx(cplx(0, 4))])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
import {promoteUnary} from './helpers.js'
|
||||
|
||||
export const clone = promoteUnary('clone')
|
||||
export const isnan = promoteUnary('isnan')
|
||||
export const isfinite = promoteUnary('isfinite')
|
||||
export const isInteger = promoteUnary('isInteger')
|
||||
export const isReal = promoteUnary('isReal')
|
||||
export const nonImaginary = promoteUnary('nonImaginary')
|
||||
export const re = promoteUnary('re')
|
||||
export const im = promoteUnary('im')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue