numjs icon indicating copy to clipboard operation
numjs copied to clipboard

Extend multiply and divide functions to accept scalar values for both arguments

Open pppp606 opened this issue 2 years ago • 1 comments

Summary

This PR aims to extend the functionality of the multiply and divide functions in the numjs library by allowing them to accept scalar numbers for both a and b arguments.

Changes

Updated the type signatures for multiply and divide functions to accept number as a possible type for both a and b parameters.

Why this change is needed

The current implementation of multiply and divide functions allows for a combination of NdArray and scalar numbers, but they don't allow two scalar numbers. By allowing scalar numbers for both arguments, we increase the versatility and user-friendliness of these functions without introducing any breaking changes.

Examples

Before

multiply([1, 2], 3);  // Works
multiply(3, [1, 2]);  // Works
multiply(3, 4);       // Doesn't work

After

multiply([1, 2], 3);  // Works
multiply(3, [1, 2]);  // Works
multiply(3, 4);       // Works

pppp606 avatar Sep 04 '23 06:09 pppp606

@grimmer0125 Hello grimmer0125,

First of all, thank you for your hard work on this fork of numjs, it's a valuable resource.

I've noticed that the multiply and divide functions currently don't allow scalar values for both a and b arguments, and thought extending this functionality could be useful.

I've attached a pull request that makes these changes. Would you mind taking a look? I hope it doesn't create any inconvenience for you.

Thank you for considering my contribution. I look forward to your feedback.

Best regards 😇

pppp606 avatar Sep 04 '23 06:09 pppp606