Skip to content

Commit 9ccb6af

Browse files
committed
Revise deth
1 parent ea91231 commit 9ccb6af

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ndarray-linalg/src/solveh.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ where
314314
S: Data<Elem = A>,
315315
A: Scalar + Lapack,
316316
{
317+
let layout = a.layout().unwrap();
317318
let mut sign = A::Real::one();
318319
let mut ln_det = A::Real::zero();
319320
let mut ipiv_enum = ipiv_iter.enumerate();
@@ -337,9 +338,15 @@ where
337338
debug_assert_eq!(lower_diag.im(), Zero::zero());
338339

339340
// Off-diagonal elements, can be complex.
340-
let off_diag = match uplo {
341-
UPLO::Upper => unsafe { a.uget((k, k + 1)) },
342-
UPLO::Lower => unsafe { a.uget((k + 1, k)) },
341+
let off_diag = match layout {
342+
MatrixLayout::C { .. } => match uplo {
343+
UPLO::Upper => unsafe { a.uget((k + 1, k)) },
344+
UPLO::Lower => unsafe { a.uget((k, k + 1)) },
345+
},
346+
MatrixLayout::F { .. } => match uplo {
347+
UPLO::Upper => unsafe { a.uget((k, k + 1)) },
348+
UPLO::Lower => unsafe { a.uget((k + 1, k)) },
349+
},
343350
};
344351

345352
// Determinant of 2x2 block.

0 commit comments

Comments
 (0)