dimforge / dimforge/nalgebra

Some shorthand suggestions

Open
#703 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Math loves huge and complex expressions, which is why math libraries tend to provide more sugary shorthands and use more abbreviations than is the norm in other areas of programming. Overall, `nalgebra` follows this rule very well and already provides a bunch of ways to keep common computations concise and readable.

However, in the latest refactoring of an nalgebra-based codebase of mine, I discovered a few more shorthands which could be helpful, for the kind of code I am writing at least. So here they are as suggestions for future `nalgebra` API evolution:

- `column()` is a bit long for a very frequently called method. I would personally provide a `col()` shortcut, and maybe go as far as to similarly shorten everything else with a "column" in its name in the next major API rework / breakage.
- `component_mul()` is very long, and its `component_mul_assign()` variant is obviously worse. It would be much nicer if Rust had element-wise operators like some math-oriented languages do, but failing that, can I have something like a `cmul()` shortcut?
- `transpose()` is a bit long too, but maybe that's for the best as it isn't something that people should be doing frequently?

As a more general comment, it seems to me that the upcoming const generics API rework could be a good occasion to revisit whether `nalgebra` can live with fewer slicing methods without losing concision and performance. It's clear that unless significantly reworked, the standard rust `Index` trait isn't going to help us much here, due to its hard requirement to emit a reference as output. But perhaps something in the spirit of [`ndarray`'s slicing DSL](https://docs.rs/ndarray/0.13.0/ndarray/macro.s.html) could work out?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.