File tree Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,9 @@ pub enum LinalgError {
12
12
#[ error( "Not square: rows({}) != cols({})" , rows, cols) ]
13
13
NotSquare { rows : i32 , cols : i32 } ,
14
14
15
- #[ error(
16
- "Invalid value for LAPACK subroutine {}-th argument" ,
17
- -return_code
18
- ) ]
19
- LapackInvalidValue { return_code : i32 } ,
20
-
21
- #[ error(
22
- "Comutational failure in LAPACK subroutine: return_code = {}" ,
23
- return_code
24
- ) ]
25
- LapackComputationalFailure { return_code : i32 } ,
15
+ /// LAPACK subroutine returns non-zero code
16
+ #[ error( transparent) ]
17
+ Lapack ( #[ from] lapack:: error:: Error ) ,
26
18
27
19
/// Strides of the array is not supported
28
20
#[ error( "invalid stride: s0={}, s1={}" , s0, s1) ]
Original file line number Diff line number Diff line change @@ -337,7 +337,9 @@ pub fn lobpcg<
337
337
// if this fails (or the algorithm was restarted), then just use span{R, X}
338
338
let result = p_ap
339
339
. as_ref ( )
340
- . ok_or ( LinalgError :: LapackComputationalFailure { return_code : 1 } )
340
+ . ok_or ( LinalgError :: Lapack (
341
+ lapack:: error:: Error :: LapackComputationalFailure { return_code : 1 } ,
342
+ ) )
341
343
. and_then ( |( active_p, active_ap) | {
342
344
let xap = x. t ( ) . dot ( active_ap) ;
343
345
let rap = r. t ( ) . dot ( active_ap) ;
Original file line number Diff line number Diff line change @@ -476,7 +476,8 @@ where
476
476
self . ensure_square ( ) ?;
477
477
match self . factorize ( ) {
478
478
Ok ( fac) => fac. sln_det ( ) ,
479
- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
479
+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { ..} ) =>
480
+ {
480
481
// The determinant is zero.
481
482
Ok ( ( A :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
482
483
}
@@ -494,7 +495,8 @@ where
494
495
self . ensure_square ( ) ?;
495
496
match self . factorize_into ( ) {
496
497
Ok ( fac) => fac. sln_det_into ( ) ,
497
- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
498
+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { .. } ) =>
499
+ {
498
500
// The determinant is zero.
499
501
Ok ( ( A :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
500
502
}
@@ -538,11 +540,11 @@ where
538
540
{
539
541
fn rcond ( & self ) -> Result < A :: Real > {
540
542
unsafe {
541
- A :: rcond (
543
+ Ok ( A :: rcond (
542
544
self . a . layout ( ) ?,
543
545
self . a . as_allocated ( ) ?,
544
546
self . a . opnorm_one ( ) ?,
545
- )
547
+ ) ? )
546
548
}
547
549
}
548
550
}
Original file line number Diff line number Diff line change @@ -423,7 +423,8 @@ where
423
423
fn sln_deth ( & self ) -> Result < ( A :: Real , A :: Real ) > {
424
424
match self . factorizeh ( ) {
425
425
Ok ( fac) => Ok ( fac. sln_deth ( ) ) ,
426
- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
426
+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { ..} ) =>
427
+ {
427
428
// Determinant is zero.
428
429
Ok ( ( A :: Real :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
429
430
}
@@ -447,7 +448,8 @@ where
447
448
fn sln_deth_into ( self ) -> Result < ( A :: Real , A :: Real ) > {
448
449
match self . factorizeh_into ( ) {
449
450
Ok ( fac) => Ok ( fac. sln_deth_into ( ) ) ,
450
- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
451
+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { ..} ) =>
452
+ {
451
453
// Determinant is zero.
452
454
Ok ( ( A :: Real :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
453
455
}
You can’t perform that action at this time.
0 commit comments