stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

[RFC]: Array Matrix Math (Possible? Documentation?)

Open danieldjewell opened this issue 4 years ago • 2 comments

Description

One of the nice (if not obligatory) features of Numpy is the ability to perform basic arithmetic on ndarrays ... (e.g. array1+array2) [Granted, the reason this is relatively easy to implement in Python is because allows you to provide methods to handle the use of operators... I don't think JavaScript has the same option?]

Is there a way to do this with stdlib arrays (of any kind)? Right now, doing an array1+array2 results in NaN. I searched the documentation and could not find a thing on this.

At a minimum, I think a "quick start" or a cheatsheet type document would be extraordinarily helpful. Especially a "stdlib math for Numpy users" type document demonstrating some basics... something like:

  • array = np.array([1,2,3,4]) == var array = array([1,2,3,4]);
  • array.max() == ???
  • array1+array2 == ???
  • etc.

Related Issues

No response

Questions

No response

Other

No.

Checklist

  • [X] I have read and understood the Code of Conduct.
  • [X] Searched for existing issues and pull requests.
  • [X] The issue name begins with RFC:.

danieldjewell avatar Aug 06 '21 18:08 danieldjewell

:tada: Welcome! :tada:

And thank you for opening your first issue! We will get back to you shortly. :runner: :dash:

github-actions[bot] avatar Aug 06 '21 18:08 github-actions[bot]

@danieldjewell Agreed! A NumPy-to-stdlib cheatsheet is something we'd like to add. I've added it to our internal tracker.

Regarding element-wise addition, in your example, array1 + array2, unfortunately, this is not possible atm in JavaScript due to the lack of operator overloading. We are in the process, however, of adding functional APIs (e.g., add(x, y)) similar to Julia's +(x,y) ability.

Are there particular operations that you need now above others?

kgryte avatar Aug 21 '21 20:08 kgryte