Skip to content

Commit c04752f

Browse files
committed
order: Convenience methods for Order
1 parent 1ff2e45 commit c04752f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/order.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,25 @@ impl Order {
4444

4545
/// "F" (for Fortran) is an alias for column major ordering
4646
pub const F: Order = Order::ColumnMajor;
47+
48+
/// Return Order::RowMajor if the input is true, Order::ColumnMajor otherwise
49+
#[inline]
50+
pub fn use_c(use_c: bool) -> Order {
51+
if use_c { Order::C } else { Order::F }
52+
}
53+
54+
/// Return Order::ColumnMajor if the input is true, Order::RowMajor otherwise
55+
#[inline]
56+
pub fn use_f(use_f: bool) -> Order {
57+
Self::use_c(!use_f)
58+
}
59+
60+
/// Return the transpose: row major becomes column major and vice versa.
61+
#[inline]
62+
pub fn transpose(self) -> Order {
63+
match self {
64+
Order::RowMajor => Order::ColumnMajor,
65+
Order::ColumnMajor => Order::RowMajor,
66+
}
67+
}
4768
}

0 commit comments

Comments
 (0)