Skip to content

Commit f6a9c2a

Browse files
committed
Fix memory layout for overdetermined case
1 parent b60cfc8 commit f6a9c2a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ndarray-linalg/src/least_squares.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
//! // `a` and `b` have been moved, no longer valid
6161
//! ```
6262
63-
use ndarray::{s, Array, Array1, Array2, ArrayBase, Axis, Data, DataMut, Dimension, Ix0, Ix1, Ix2};
63+
use ndarray::*;
6464

6565
use crate::error::*;
6666
use crate::lapack::least_squares::*;
@@ -352,7 +352,10 @@ where
352352
// we need a new rhs b/c it will be overwritten with the solution
353353
// for which we need `n` entries
354354
let k = rhs.shape()[1];
355-
let mut new_rhs = Array2::<E>::zeros((n, k));
355+
let mut new_rhs = match self.layout()? {
356+
MatrixLayout::C { .. } => Array2::<E>::zeros((n, k)),
357+
MatrixLayout::F { .. } => Array2::<E>::zeros((n, k).f()),
358+
};
356359
new_rhs.slice_mut(s![0..m, ..]).assign(rhs);
357360
compute_least_squares_nrhs(self, &mut new_rhs)
358361
} else {

0 commit comments

Comments
 (0)