File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,17 +12,9 @@ pub enum LinalgError {
1212 #[ error( "Not square: rows({}) != cols({})" , rows, cols) ]
1313 NotSquare { rows : i32 , cols : i32 } ,
1414
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 ) ,
2618
2719 /// Strides of the array is not supported
2820 #[ error( "invalid stride: s0={}, s1={}" , s0, s1) ]
Original file line number Diff line number Diff line change @@ -337,7 +337,9 @@ pub fn lobpcg<
337337 // if this fails (or the algorithm was restarted), then just use span{R, X}
338338 let result = p_ap
339339 . as_ref ( )
340- . ok_or ( LinalgError :: LapackComputationalFailure { return_code : 1 } )
340+ . ok_or ( LinalgError :: Lapack (
341+ lapack:: error:: Error :: LapackComputationalFailure { return_code : 1 } ,
342+ ) )
341343 . and_then ( |( active_p, active_ap) | {
342344 let xap = x. t ( ) . dot ( active_ap) ;
343345 let rap = r. t ( ) . dot ( active_ap) ;
Original file line number Diff line number Diff line change @@ -476,7 +476,8 @@ where
476476 self . ensure_square ( ) ?;
477477 match self . factorize ( ) {
478478 Ok ( fac) => fac. sln_det ( ) ,
479- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
479+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { ..} ) =>
480+ {
480481 // The determinant is zero.
481482 Ok ( ( A :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
482483 }
@@ -494,7 +495,8 @@ where
494495 self . ensure_square ( ) ?;
495496 match self . factorize_into ( ) {
496497 Ok ( fac) => fac. sln_det_into ( ) ,
497- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
498+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { .. } ) =>
499+ {
498500 // The determinant is zero.
499501 Ok ( ( A :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
500502 }
@@ -538,11 +540,11 @@ where
538540{
539541 fn rcond ( & self ) -> Result < A :: Real > {
540542 unsafe {
541- A :: rcond (
543+ Ok ( A :: rcond (
542544 self . a . layout ( ) ?,
543545 self . a . as_allocated ( ) ?,
544546 self . a . opnorm_one ( ) ?,
545- )
547+ ) ? )
546548 }
547549 }
548550}
Original file line number Diff line number Diff line change @@ -423,7 +423,8 @@ where
423423 fn sln_deth ( & self ) -> Result < ( A :: Real , A :: Real ) > {
424424 match self . factorizeh ( ) {
425425 Ok ( fac) => Ok ( fac. sln_deth ( ) ) ,
426- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
426+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { ..} ) =>
427+ {
427428 // Determinant is zero.
428429 Ok ( ( A :: Real :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
429430 }
@@ -447,7 +448,8 @@ where
447448 fn sln_deth_into ( self ) -> Result < ( A :: Real , A :: Real ) > {
448449 match self . factorizeh_into ( ) {
449450 Ok ( fac) => Ok ( fac. sln_deth_into ( ) ) ,
450- Err ( LinalgError :: LapackComputationalFailure { .. } ) => {
451+ Err ( LinalgError :: Lapack ( e) ) if matches ! ( e, lapack:: error:: Error :: LapackComputationalFailure { ..} ) =>
452+ {
451453 // Determinant is zero.
452454 Ok ( ( A :: Real :: zero ( ) , A :: Real :: neg_infinity ( ) ) )
453455 }
You can’t perform that action at this time.
0 commit comments