Skip to content

Commit 68eb5c5

Browse files
committed
order: Convenience methods for Order
1 parent 4e4d674 commit 68eb5c5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/order.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,27 @@ impl Order {
2020

2121
/// "A" is an alias for automatic ordering
2222
pub const A: Order = Order::Automatic;
23+
24+
/// Return Order::RowMajor if the input is true, Order::ColumnMajor otherwise
25+
#[inline]
26+
pub fn use_c(use_c: bool) -> Order {
27+
if use_c { Order::C } else { Order::F }
28+
}
29+
30+
/// Return Order::ColumnMajor if the input is true, Order::RowMajor otherwise
31+
#[inline]
32+
pub fn use_f(use_f: bool) -> Order {
33+
Self::use_c(!use_f)
34+
}
35+
36+
/// Return the transpose: row major becomes column major and vice versa.
37+
/// Note that automatic stays automatic.
38+
#[inline]
39+
pub fn transpose(self) -> Order {
40+
match self {
41+
Order::RowMajor => Order::ColumnMajor,
42+
Order::ColumnMajor => Order::RowMajor,
43+
Order::Automatic => Order::Automatic,
44+
}
45+
}
2346
}

0 commit comments

Comments
 (0)