Update nalgebra-macros to nalgebra 0.26 and const generics
This commit is contained in:
parent
1dccdb1f20
commit
e60136fbb1
@ -16,4 +16,4 @@ quote = "1.0"
|
||||
proc-macro2 = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
nalgebra = { version = "0.25.4", path = ".." }
|
||||
nalgebra = { version = "0.26.1", path = ".." }
|
||||
|
@ -77,15 +77,14 @@ impl Parse for Matrix {
|
||||
pub fn matrix(stream: TokenStream) -> TokenStream {
|
||||
let matrix = parse_macro_input!(stream as Matrix);
|
||||
|
||||
let dim_ident = |dim| format_ident!("U{}", dim);
|
||||
let row_dim = dim_ident(matrix.nrows());
|
||||
let col_dim = dim_ident(matrix.ncols());
|
||||
let row_dim = matrix.nrows();
|
||||
let col_dim = matrix.ncols();
|
||||
let entries_col_major = matrix.to_col_major_repr();
|
||||
|
||||
// TODO: Use quote_spanned instead??
|
||||
// TODO: Construct directly from array?
|
||||
let output = quote! {
|
||||
nalgebra::MatrixMN::<_, nalgebra::#row_dim, nalgebra::dimension::#col_dim>
|
||||
nalgebra::SMatrix::<_, #row_dim, #col_dim>
|
||||
::from_column_slice(&[#(#entries_col_major),*])
|
||||
};
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
use nalgebra_macros::matrix;
|
||||
use nalgebra::{MatrixMN, Matrix3x2, U0, U1, Matrix1x2, Matrix1x3, Matrix1x4, Matrix2x1, Matrix2, Matrix2x3, Matrix2x4, Matrix3x1, Matrix3, Matrix3x4, Matrix4x1, Matrix4x2, Matrix4x3, Matrix4};
|
||||
use nalgebra::{SMatrix, Matrix3x2, U0, U1, Matrix1x2, Matrix1x3, Matrix1x4, Matrix2x1, Matrix2, Matrix2x3, Matrix2x4, Matrix3x1, Matrix3, Matrix3x4, Matrix4x1, Matrix4x2, Matrix4x3, Matrix4};
|
||||
|
||||
#[test]
|
||||
fn matrix_small_dims_exhaustive() {
|
||||
// 0x0
|
||||
assert_eq!(matrix![], MatrixMN::<i32, U0, U0>::zeros());
|
||||
assert_eq!(matrix![], SMatrix::<i32, 0, 0>::zeros());
|
||||
|
||||
// 1xN
|
||||
assert_eq!(matrix![1], MatrixMN::<i32, U1, U1>::new(1));
|
||||
assert_eq!(matrix![1], SMatrix::<i32, 1, 1>::new(1));
|
||||
assert_eq!(matrix![1, 2], Matrix1x2::new(1, 2));
|
||||
assert_eq!(matrix![1, 2, 3], Matrix1x3::new(1, 2, 3));
|
||||
assert_eq!(matrix![1, 2, 3, 4], Matrix1x4::new(1, 2, 3, 4));
|
||||
|
Loading…
Reference in New Issue
Block a user