Skip to content

Commit 6be0ad1

Browse files
committed
Use lapack_sys in least_squares.rs
1 parent 4bf4414 commit 6be0ad1

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

lax/src/least_squares.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,50 +97,50 @@ macro_rules! impl_least_squares {
9797
)*
9898
unsafe {
9999
$gelsd(
100-
m,
101-
n,
102-
nrhs,
103-
a_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(a),
104-
a_layout.lda(),
105-
b_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(b),
106-
b_layout.lda(),
107-
&mut singular_values,
108-
rcond,
100+
&m,
101+
&n,
102+
&nrhs,
103+
AsPtr::as_mut_ptr(a_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(a)),
104+
&a_layout.lda(),
105+
AsPtr::as_mut_ptr(b_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(b)),
106+
&b_layout.lda(),
107+
AsPtr::as_mut_ptr(&mut singular_values),
108+
&rcond,
109109
&mut rank,
110-
&mut work_size,
111-
-1,
112-
$(&mut $rwork,)*
113-
&mut iwork_size,
110+
AsPtr::as_mut_ptr(&mut work_size),
111+
&(-1),
112+
$(AsPtr::as_mut_ptr(&mut $rwork),)*
113+
iwork_size.as_mut_ptr(),
114114
&mut info,
115115
)
116116
};
117117
info.as_lapack_result()?;
118118

119119
// calc
120120
let lwork = work_size[0].to_usize().unwrap();
121-
let mut work = unsafe { vec_uninit( lwork) };
121+
let mut work: Vec<Self> = unsafe { vec_uninit(lwork) };
122122
let liwork = iwork_size[0].to_usize().unwrap();
123-
let mut iwork = unsafe { vec_uninit( liwork) };
123+
let mut iwork = unsafe { vec_uninit(liwork) };
124124
$(
125125
let lrwork = $rwork[0].to_usize().unwrap();
126-
let mut $rwork = unsafe { vec_uninit( lrwork) };
126+
let mut $rwork: Vec<Self::Real> = unsafe { vec_uninit(lrwork) };
127127
)*
128128
unsafe {
129129
$gelsd(
130-
m,
131-
n,
132-
nrhs,
133-
a_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(a),
134-
a_layout.lda(),
135-
b_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(b),
136-
b_layout.lda(),
137-
&mut singular_values,
138-
rcond,
130+
&m,
131+
&n,
132+
&nrhs,
133+
AsPtr::as_mut_ptr(a_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(a)),
134+
&a_layout.lda(),
135+
AsPtr::as_mut_ptr(b_t.as_mut().map(|v| v.as_mut_slice()).unwrap_or(b)),
136+
&b_layout.lda(),
137+
AsPtr::as_mut_ptr(&mut singular_values),
138+
&rcond,
139139
&mut rank,
140-
&mut work,
141-
lwork as i32,
142-
$(&mut $rwork,)*
143-
&mut iwork,
140+
AsPtr::as_mut_ptr(&mut work),
141+
&(lwork as i32),
142+
$(AsPtr::as_mut_ptr(&mut $rwork),)*
143+
iwork.as_mut_ptr(),
144144
&mut info,
145145
);
146146
}
@@ -161,7 +161,7 @@ macro_rules! impl_least_squares {
161161
};
162162
}
163163

164-
impl_least_squares!(@real, f64, lapack::dgelsd);
165-
impl_least_squares!(@real, f32, lapack::sgelsd);
166-
impl_least_squares!(@complex, c64, lapack::zgelsd);
167-
impl_least_squares!(@complex, c32, lapack::cgelsd);
164+
impl_least_squares!(@real, f64, lapack_sys::dgelsd_);
165+
impl_least_squares!(@real, f32, lapack_sys::sgelsd_);
166+
impl_least_squares!(@complex, c64, lapack_sys::zgelsd_);
167+
impl_least_squares!(@complex, c32, lapack_sys::cgelsd_);

0 commit comments

Comments
 (0)