-
-
Notifications
You must be signed in to change notification settings - Fork 485
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 macro for concatenating matrices #1080
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5f3a748
Add macro for concatenating matrices
birktj 9f3f349
Replace DimUnify with DimEq::representative
birktj 76a15e5
Add some simple cat macro output generation tests
birktj 4aac95a
Fix formatting in cat macro code
birktj fee8302
Add random prefix to cat macro output
birktj ad87d00
Add simple quote_spanned for cat macro
birktj 03389ed
Use `generic_view_mut` in cat macro
birktj e5957f7
Fix clippy lints in cat macro
birktj c5e4a93
Clean up documentation for cat macro
birktj 578e46a
Remove identity literal from cat macro
birktj e1add3f
Allow references in input to cat macro
birktj 1cc5772
Rename cat macro to stack
birktj 92d6b84
Add more stack macro tests
birktj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use nalgebra_macros::stack; | ||
|
||
fn main() { | ||
stack![]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error: `stack` macro cannot be used without any arguments | ||
--> tests/trybuild/stack_empty.rs:4:5 | ||
| | ||
4 | stack![]; | ||
| ^^^^^^^^ | ||
| | ||
= note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use nalgebra_macros::{matrix, stack}; | ||
|
||
fn main() { | ||
let m = matrix![1, 2; 3, 4]; | ||
stack![0, m]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error: At least one element in each column must be an expression of type `Matrix` | ||
--> tests/trybuild/stack_empty_col.rs:5:5 | ||
| | ||
5 | stack![0, m]; | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use nalgebra_macros::{matrix, stack}; | ||
|
||
fn main() { | ||
let m = matrix![1, 2; 3, 4]; | ||
stack![0; m]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error: At least one element in each row must be an expression of type `Matrix` | ||
--> tests/trybuild/stack_empty_row.rs:5:5 | ||
| | ||
5 | stack![0; m]; | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would it be a good idea to add to this file tests to ensure that the macro doesn't explode if it's passed a matrix with zero rows or zero columns, e.g.
Should yield a result equal to
a
ifb
is a dynamic matrix with 0 rows and 0 columns.Actually, that's something that might be worth considering -- what should the behaviour of this macro be if passed a
DMatrix
with zero in one dimension and nonzero in another dimension, and then asked to use0
? E.g., the above, but the matrixb
has 2 rows and 0 columns. Ifa
were[1, 2; 3, 4]
then I think the most reasonable result would beas that's the most predictable result of having that row and column count specified.
This also raises a question of whether a dynamic matrix with 3 rows and 0 columns should be considered "compatible" with a stack row that contains matrices with 5 rows. In theory it could be, although again raising an error might be the most predictable behaviour, as it lets us "take the dynamic matrix at its word" that it contains precisely 3 rows, even if it's got no entries.