@@ -12,34 +12,34 @@ pub type Pivot = Vec<i32>;
1212
1313/// Wraps `*getrf`, `*getri`, and `*getrs`
1414pub trait Solve_ : Sized {
15- fn lu ( MatrixLayout , a : & mut [ Self ] ) -> Result < Pivot > ;
16- fn inv ( MatrixLayout , a : & mut [ Self ] , & Pivot ) -> Result < ( ) > ;
17- fn solve ( MatrixLayout , Transpose , a : & [ Self ] , & Pivot , b : & mut [ Self ] ) -> Result < ( ) > ;
15+ unsafe fn lu ( MatrixLayout , a : & mut [ Self ] ) -> Result < Pivot > ;
16+ unsafe fn inv ( MatrixLayout , a : & mut [ Self ] , & Pivot ) -> Result < ( ) > ;
17+ unsafe fn solve ( MatrixLayout , Transpose , a : & [ Self ] , & Pivot , b : & mut [ Self ] ) -> Result < ( ) > ;
1818}
1919
2020macro_rules! impl_solve {
2121 ( $scalar: ty, $getrf: path, $getri: path, $getrs: path) => {
2222
2323impl Solve_ for $scalar {
24- fn lu( l: MatrixLayout , a: & mut [ Self ] ) -> Result <Pivot > {
24+ unsafe fn lu( l: MatrixLayout , a: & mut [ Self ] ) -> Result <Pivot > {
2525 let ( row, col) = l. size( ) ;
2626 let k = :: std:: cmp:: min( row, col) ;
2727 let mut ipiv = vec![ 0 ; k as usize ] ;
28- let info = unsafe { $getrf( l. lapacke_layout( ) , row, col, a, l. lda( ) , & mut ipiv) } ;
28+ let info = $getrf( l. lapacke_layout( ) , row, col, a, l. lda( ) , & mut ipiv) ;
2929 into_result( info, ipiv)
3030 }
3131
32- fn inv( l: MatrixLayout , a: & mut [ Self ] , ipiv: & Pivot ) -> Result <( ) > {
32+ unsafe fn inv( l: MatrixLayout , a: & mut [ Self ] , ipiv: & Pivot ) -> Result <( ) > {
3333 let ( n, _) = l. size( ) ;
34- let info = unsafe { $getri( l. lapacke_layout( ) , n, a, l. lda( ) , ipiv) } ;
34+ let info = $getri( l. lapacke_layout( ) , n, a, l. lda( ) , ipiv) ;
3535 into_result( info, ( ) )
3636 }
3737
38- fn solve( l: MatrixLayout , t: Transpose , a: & [ Self ] , ipiv: & Pivot , b: & mut [ Self ] ) -> Result <( ) > {
38+ unsafe fn solve( l: MatrixLayout , t: Transpose , a: & [ Self ] , ipiv: & Pivot , b: & mut [ Self ] ) -> Result <( ) > {
3939 let ( n, _) = l. size( ) ;
4040 let nrhs = 1 ;
4141 let ldb = 1 ;
42- let info = unsafe { $getrs( l. lapacke_layout( ) , t as u8 , n, nrhs, a, l. lda( ) , ipiv, b, ldb) } ;
42+ let info = $getrs( l. lapacke_layout( ) , t as u8 , n, nrhs, a, l. lda( ) , ipiv, b, ldb) ;
4343 into_result( info, ( ) )
4444 }
4545}
0 commit comments