Skip to content

Conversation

akern40
Copy link
Collaborator

@akern40 akern40 commented Dec 26, 2024

This is one of two PRs I'm working on that start to "traitify" ndarray. This trait is like the Ndarray trait suggested by @bluss in #339, but is slightly broader: it's meant to encapsulate not just actual ndarray types, but anything that could act like a multidimensional array. This includes Vecs, slices, arrays, and (critically) scalars that implement ScalarOperand.

The motivation for me was trying to design a set of methods expanded numerical methods, addressing #1462 (and others). My goal was to have these methods

  1. Work for types that implement the associated num_traits traits, i.e., abs for T: Signed.
  2. Have both array-creating and array-mutating variants
  3. Broadcast amongst all arguments
  4. Work for arrays and scalars interchangeably

I was able to accomplish 1-3 with existing infrastructure, but you can see in #1462 that I was struggling with (4). This trait would allow me to accomplish all of these tasks.

Feedback is greatly welcome. Keep an eye out for two more upcoming PRs:

  1. An implementation of the math stuff above that uses ArrayLike, to close #14632
  2. A PR with the Ndarray trait, following the design of NdArray trait #339

Note: This PR uses #1440 so should be merged after that.

This was referenced Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant