Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions test/mocha/divide.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
7 changes: 7 additions & 0 deletions test/mocha/multiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});