transpose too easy
This commit is contained in:
parent
8e1807b4b7
commit
f103c247b8
@ -73,6 +73,26 @@ macro_rules! impl_matrix {
|
||||
), +
|
||||
}
|
||||
}
|
||||
|
||||
/// Consumes the matrix and returns a new matrix with the given function applied on each field.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use fixed_wide_vectors::Vector2;
|
||||
///
|
||||
/// let mat2 = Vector2::new(
|
||||
/// Vector2::new(1, 2),
|
||||
/// Vector2::new(3, 4)
|
||||
/// )
|
||||
/// .transpose();
|
||||
///
|
||||
/// assert_eq!(mat2, Vector2::new(Vector2::new(1, 3), Vector2::new(2, 4)));
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn transpose(self) -> $struct_inner<$struct_outer<T>>{
|
||||
$crate::matrix_transpose_outer!{self,$fields_inner,($struct_outer { $($field_outer), + })}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy> $struct_outer<$struct_inner<T>> {
|
||||
@ -114,6 +134,32 @@ macro_rules! matrix_map2d_inner {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! matrix_transpose_outer {
|
||||
(
|
||||
$value:ident,
|
||||
($struct_outer: ident { $($field_outer: ident), + }),
|
||||
$fields_inner:tt
|
||||
) => {
|
||||
$struct_outer {
|
||||
$(
|
||||
$field_outer: $crate::matrix_transpose_inner!{$value,$field_outer,$fields_inner}
|
||||
), +
|
||||
}
|
||||
}
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! matrix_transpose_inner {
|
||||
( $value:ident, $field_outer:ident, ($struct_inner: ident { $($field_inner: ident), + }) ) => {
|
||||
$struct_inner {
|
||||
$(
|
||||
$field_inner: $value.$field_inner.$field_outer
|
||||
), +
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
macro_rules! nested {
|
||||
|
Loading…
Reference in New Issue
Block a user