-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
add MatRef|MatMut::from_*_slice #54
Conversation
aa93ff5
to
efe9016
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
==========================================
+ Coverage 92.72% 92.74% +0.02%
==========================================
Files 49 49
Lines 51783 51876 +93
==========================================
+ Hits 48016 48114 +98
+ Misses 3767 3762 -5
☔ View full report in Codecov by Sentry. |
efe9016
to
92c791a
Compare
ncols: usize, | ||
) -> Self { | ||
Self::from_column_major_slice(slice, ncols, nrows).transpose() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sarah-ek ,
Great library!
What would you recommend to go back from Matrix to slice/vec?
Somehow using as_ptr
?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe...
// Given matrix holds a `Mat`
let mut vec = vec![];
for i in 0..matrix.ncols() {
vec.extend_from_slice(matrix.col_ref(i));
}
vec
for a column-major vec, and possibly a variation with with transpose
for row-major?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for MatRef
/MatMut
there's currently no user-facing api for going back to a slice. in the future i'd like to add something like matrix.col(3).try_as_column_major_slice()
, and matrix.row(2).try_as_row_major_slice
which would return an Option<&[E]>
(or more specifically GroupFor<E, &[E::Unit]>
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha.
Thank you!
No description provided.