dimforge / dimforge/nalgebra

The signature of Matrix::map() seems unnecessarily restrictive

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

Description

Currently, Matrix::map() is defined as follows:

fn map N>(&self, f: F) -> Matrix

The restriction that the mapping function's return type must be the same as its input type, which does not exist when using std iterators for example, forbids several kind of useful mappings, including:

- Mapping between different scalar types (e.g. i32 <-> f32 <-> f64 <-> num::Complex)
- Partial reductions (e.g. turning a vector of vectors into a vector of scalars by folding the inner vectors)

This can be hacked around through a combination of iter() and FromIterator, but the resulting code will be relatively verbose.

Is there any particular reason why this is the case?

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.