-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heterogeneously dimensioned linear algebra #39
Comments
That is an interesting idea. If I understand you correctly, we'd have some sort of derive macro for structs with heterogeneous dimensions that automatically implements All of that should be possible to autogenerate, but then we'd still need support for transformations between the two representations, i.e. heterogeneous matrices that have some kind of
One thought on this: It might be possible to do some dimensional analysis at run-time too. For example if we had some kind of mutable matrix, we could define struct DimensionedMatrix {
m: Matrix,
row_dimensions: Vec<Dimension>,
column_dimensions: Vec<Dimension>,
} where fn add_entry<const D: Dimension>(matrix: &mut DimensionedMatrix, i: usize, j: usize, q: Quantity<f64, D>) {
matrix[i][j] = q.value_unchecked();
match matrix.row_dimension(i) {
Some(dimension) => assert_eq!(dimension, D);
None => matrix.store_row_dimension(i, D);
}
match matrix.column_dimension(j) {
Some(dimension) => assert_eq!(dimension, D);
None => matrix.store_column_dimension(j, D);
}
} of course this comes at performance and memory cost, so it might be something you only want to do in test runs to verify the code and then have it disabled for actual runs. Then again, the runtime cost would be O(n m) with O(n+m) memory, so maybe it might even be tolerable in some applications? Of course I am leaving many implementation details to the imagination here, but I am mainly wondering if this is something that would be interesting in applications? |
Extracted from the discussion in #36:
@jedbrown
@Tehforsch
@jedbrown
The text was updated successfully, but these errors were encountered: