Skip to content

Commit e18e580

Browse files
committed
Replace ndarray_linalg::MatrixLayout by lax:: one
1 parent 9ba6738 commit e18e580

File tree

1 file changed

+2
-73
lines changed

1 file changed

+2
-73
lines changed

ndarray-linalg/src/layout.rs

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,9 @@
11
//! Memory layout of matrices
22
3-
use ndarray::*;
4-
53
use super::error::*;
4+
use ndarray::*;
65

7-
pub type LDA = i32;
8-
pub type LEN = i32;
9-
pub type Col = i32;
10-
pub type Row = i32;
11-
12-
#[derive(Debug, Clone, Copy, PartialEq)]
13-
pub enum MatrixLayout {
14-
C((Row, LDA)),
15-
F((Col, LDA)),
16-
}
17-
18-
impl MatrixLayout {
19-
pub fn size(&self) -> (Row, Col) {
20-
match *self {
21-
MatrixLayout::C((row, lda)) => (row, lda),
22-
MatrixLayout::F((col, lda)) => (lda, col),
23-
}
24-
}
25-
26-
pub fn resized(&self, row: Row, col: Col) -> MatrixLayout {
27-
match *self {
28-
MatrixLayout::C(_) => MatrixLayout::C((row, col)),
29-
MatrixLayout::F(_) => MatrixLayout::F((col, row)),
30-
}
31-
}
32-
33-
pub fn lda(&self) -> LDA {
34-
std::cmp::max(
35-
1,
36-
match *self {
37-
MatrixLayout::C((_, lda)) | MatrixLayout::F((_, lda)) => lda,
38-
},
39-
)
40-
}
41-
42-
pub fn len(&self) -> LEN {
43-
match *self {
44-
MatrixLayout::C((row, _)) => row,
45-
MatrixLayout::F((col, _)) => col,
46-
}
47-
}
48-
49-
pub fn is_empty(&self) -> bool {
50-
self.len() == 0
51-
}
52-
53-
pub fn lapacke_layout(&self) -> lapacke::Layout {
54-
match *self {
55-
MatrixLayout::C(_) => lapacke::Layout::RowMajor,
56-
MatrixLayout::F(_) => lapacke::Layout::ColumnMajor,
57-
}
58-
}
59-
60-
pub fn same_order(&self, other: &MatrixLayout) -> bool {
61-
self.lapacke_layout() == other.lapacke_layout()
62-
}
63-
64-
pub fn as_shape(&self) -> Shape<Ix2> {
65-
match *self {
66-
MatrixLayout::C((row, col)) => (row as usize, col as usize).into_shape(),
67-
MatrixLayout::F((col, row)) => (row as usize, col as usize).f().into_shape(),
68-
}
69-
}
70-
71-
pub fn toggle_order(&self) -> Self {
72-
match *self {
73-
MatrixLayout::C((row, col)) => MatrixLayout::F((col, row)),
74-
MatrixLayout::F((col, row)) => MatrixLayout::C((row, col)),
75-
}
76-
}
77-
}
6+
pub use lapack::layout::MatrixLayout;
787

798
pub trait AllocatedArray {
809
type Elem;

0 commit comments

Comments
 (0)