diff --git a/src/lib/index.ts b/src/lib/index.ts index 4dd6004..8b5e72e 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -62,7 +62,7 @@ export function add( * Multiply arguments, element-wise. */ export function multiply( - a: ArbDimNumArray | NdArray, + a: ArbDimNumArray | NdArray | number, b: ArbDimNumArray | NdArray | number ): NdArray { return NdArray.new(a).multiply(b); @@ -72,7 +72,7 @@ export function multiply( * Divide `a` by `b`, element-wise. */ export function divide( - a: ArbDimNumArray | NdArray, + a: ArbDimNumArray | NdArray | number, b: ArbDimNumArray | NdArray | number ) { return NdArray.new(a).divide(b); diff --git a/test/mocha/divide.spec.ts b/test/mocha/divide.spec.ts index 747c8bd..f5774f0 100644 --- a/test/mocha/divide.spec.ts +++ b/test/mocha/divide.spec.ts @@ -39,4 +39,11 @@ describe('divide', function () { nj.divide(x1, x2); }).to.throw(); }); + it('can set a number to the argument', function () { + const a = 2; + const b = 3; + const numberResult = nj.divide(a, b); + const arrayResult = nj.divide(nj.array([a]), nj.array([b])); + expect(numberResult).to.eql(arrayResult); + }); }); diff --git a/test/mocha/multiply.spec.ts b/test/mocha/multiply.spec.ts index a7c9a4c..d590697 100644 --- a/test/mocha/multiply.spec.ts +++ b/test/mocha/multiply.spec.ts @@ -44,4 +44,11 @@ describe('multiply', function () { nj.multiply(x1, x2); }).to.throw(); }); + it('can set a number to the argument', function () { + const a = 2; + const b = 3; + const numberResult = nj.multiply(a, b); + const arrayResult = nj.multiply(nj.array([a]), nj.array([b])); + expect(numberResult).to.eql(arrayResult); + }); });