Skip to content
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

Merged
merged 1 commit into from
Sep 13, 2023
Merged

add MatRef|MatMut::from_*_slice #54

merged 1 commit into from
Sep 13, 2023

Conversation

sarah-quinones
Copy link
Owner

No description provided.

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% 🎉

Comparison is base (752a5e3) 92.72% compared to head (92c791a) 92.74%.

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     
Files Changed Coverage Δ
faer-core/src/lib.rs 76.71% <100.00%> (+0.72%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sarah-quinones sarah-quinones merged commit 56d8f23 into main Sep 13, 2023
5 checks passed
@sarah-quinones sarah-quinones deleted the core-from-slice branch September 16, 2023 18:16
ncols: usize,
) -> Self {
Self::from_column_major_slice(slice, ncols, nrows).transpose()
}
Copy link

@grzuy grzuy Nov 9, 2023

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!

Copy link

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?

Copy link
Owner Author

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]>)

Copy link

Choose a reason for hiding this comment

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

Gotcha.

Thank you!

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