File tree Expand file tree Collapse file tree 1 file changed +2
-59
lines changed
Expand file tree Collapse file tree 1 file changed +2
-59
lines changed Original file line number Diff line number Diff line change @@ -36,65 +36,8 @@ macro_rules! impl_least_squares_real {
3636 a: & mut [ Self ] ,
3737 b: & mut [ Self ] ,
3838 ) -> Result <LeastSquaresOutput <Self >> {
39- let m = l. lda( ) ;
40- let n = l. len( ) ;
41- let k = m. min( n) ;
42- if ( m as usize ) > b. len( ) || ( n as usize ) > b. len( ) {
43- return Err ( Error :: InvalidShape ) ;
44- }
45- let rcond: Self :: Real = -1. ;
46- let mut singular_values: Vec <Self :: Real > = vec![ Self :: Real :: zero( ) ; k as usize ] ;
47- let mut rank: i32 = 0 ;
48-
49- // eval work size
50- let mut info = 0 ;
51- let mut work_size = [ Self :: zero( ) ] ;
52- let mut iwork_size = [ 0 ] ;
53- $gelsd(
54- m,
55- n,
56- 1 , // nrhs
57- a,
58- m,
59- b,
60- b. len( ) as i32 ,
61- & mut singular_values,
62- rcond,
63- & mut rank,
64- & mut work_size,
65- -1 ,
66- & mut iwork_size,
67- & mut info,
68- ) ;
69- info. as_lapack_result( ) ?;
70-
71- // calc
72- let lwork = work_size[ 0 ] . to_usize( ) . unwrap( ) ;
73- let mut work = vec![ Self :: zero( ) ; lwork] ;
74- let liwork = iwork_size[ 0 ] . to_usize( ) . unwrap( ) ;
75- let mut iwork = vec![ 0 ; liwork] ;
76- $gelsd(
77- m,
78- n,
79- 1 , // nrhs
80- a,
81- m,
82- b,
83- b. len( ) as i32 ,
84- & mut singular_values,
85- rcond,
86- & mut rank,
87- & mut work,
88- lwork as i32 ,
89- & mut iwork,
90- & mut info,
91- ) ;
92- info. as_lapack_result( ) ?;
93-
94- Ok ( LeastSquaresOutput {
95- singular_values,
96- rank,
97- } )
39+ let b_layout = l. resized( b. len( ) as i32 , 1 ) ;
40+ Self :: least_squares_nrhs( l, a, b_layout, b)
9841 }
9942
10043 unsafe fn least_squares_nrhs(
You can’t perform that action at this time.
0 commit comments