Skip to content

Commit e13570a

Browse files
committed
order: Convenience methods for Order
1 parent c33e556 commit e13570a

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
@@ -15,4 +15,25 @@ impl Order {
1515

1616
/// "F" (for Fortran) is an alias for column major ordering
1717
pub const F: Order = Order::ColumnMajor;
18+
19+
/// Return Order::RowMajor if the input is true, Order::ColumnMajor otherwise
20+
#[inline]
21+
pub fn use_c(use_c: bool) -> Order {
22+
if use_c { Order::C } else { Order::F }
23+
}
24+
25+
/// Return Order::ColumnMajor if the input is true, Order::RowMajor otherwise
26+
#[inline]
27+
pub fn use_f(use_f: bool) -> Order {
28+
Self::use_c(!use_f)
29+
}
30+
31+
/// Return the transpose: row major becomes column major and vice versa.
32+
#[inline]
33+
pub fn transpose(self) -> Order {
34+
match self {
35+
Order::RowMajor => Order::ColumnMajor,
36+
Order::ColumnMajor => Order::RowMajor,
37+
}
38+
}
1839
}

0 commit comments

Comments
 (0)