Skip to content

Convenient Vec methods#372

Merged
JamesMcClung merged 15 commits intopsc-code:mainfrom
JamesMcClung:pr/vec-methods
Jan 15, 2026
Merged

Convenient Vec methods#372
JamesMcClung merged 15 commits intopsc-code:mainfrom
JamesMcClung:pr/vec-methods

Conversation

@JamesMcClung
Copy link
Collaborator

@JamesMcClung JamesMcClung commented Jan 8, 2026

Mostly adds lots of mathematical methods to Vec:

  • Reduce a single vector with sum, prod, mag, mag2
  • Convert to an int vec with fint
  • Vector products with dot and cross
  • Elementwise and reductive min and max
  • Invert with inv
  • Iterate over N-dimensional indices with VecRange

Also adds an overload to rng::Uniform::get.

Most of these features aren't used in this PR. Future PRs will use them extensively, however.

Copy link
Contributor

@germasch germasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks!

For the multi-d iteration, I guess I'll say that generally it'd be preferable to get rid of such loops altogether, and instead use gtensor expressions. But that's a bigger project, and may not work everywhere, anyway.

@JamesMcClung
Copy link
Collaborator Author

What gtensor expressions do you mean?

@JamesMcClung JamesMcClung merged commit 89a6a36 into psc-code:main Jan 15, 2026
6 checks passed
@JamesMcClung JamesMcClung deleted the pr/vec-methods branch January 15, 2026 20:29
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.

2 participants