@@ -8,32 +8,37 @@ pub trait Cholesky_: Sized {
8
8
/// Cholesky: wrapper of `*potrf`
9
9
///
10
10
/// **Warning: Only the portion of `a` corresponding to `UPLO` is written.**
11
- unsafe fn cholesky ( l : MatrixLayout , uplo : UPLO , a : & mut [ Self ] ) -> Result < ( ) > ;
11
+ fn cholesky ( l : MatrixLayout , uplo : UPLO , a : & mut [ Self ] ) -> Result < ( ) > ;
12
+
12
13
/// Wrapper of `*potri`
13
14
///
14
15
/// **Warning: Only the portion of `a` corresponding to `UPLO` is written.**
15
- unsafe fn inv_cholesky ( l : MatrixLayout , uplo : UPLO , a : & mut [ Self ] ) -> Result < ( ) > ;
16
+ fn inv_cholesky ( l : MatrixLayout , uplo : UPLO , a : & mut [ Self ] ) -> Result < ( ) > ;
17
+
16
18
/// Wrapper of `*potrs`
17
- unsafe fn solve_cholesky ( l : MatrixLayout , uplo : UPLO , a : & [ Self ] , b : & mut [ Self ] )
18
- -> Result < ( ) > ;
19
+ fn solve_cholesky ( l : MatrixLayout , uplo : UPLO , a : & [ Self ] , b : & mut [ Self ] ) -> Result < ( ) > ;
19
20
}
20
21
21
22
macro_rules! impl_cholesky {
22
23
( $scalar: ty, $trf: path, $tri: path, $trs: path) => {
23
24
impl Cholesky_ for $scalar {
24
- unsafe fn cholesky( l: MatrixLayout , uplo: UPLO , a: & mut [ Self ] ) -> Result <( ) > {
25
+ fn cholesky( l: MatrixLayout , uplo: UPLO , a: & mut [ Self ] ) -> Result <( ) > {
25
26
let ( n, _) = l. size( ) ;
26
- $trf( l. lapacke_layout( ) , uplo as u8 , n, a, n) . as_lapack_result( ) ?;
27
+ unsafe {
28
+ $trf( l. lapacke_layout( ) , uplo as u8 , n, a, n) . as_lapack_result( ) ?;
29
+ }
27
30
Ok ( ( ) )
28
31
}
29
32
30
- unsafe fn inv_cholesky( l: MatrixLayout , uplo: UPLO , a: & mut [ Self ] ) -> Result <( ) > {
33
+ fn inv_cholesky( l: MatrixLayout , uplo: UPLO , a: & mut [ Self ] ) -> Result <( ) > {
31
34
let ( n, _) = l. size( ) ;
32
- $tri( l. lapacke_layout( ) , uplo as u8 , n, a, l. lda( ) ) . as_lapack_result( ) ?;
35
+ unsafe {
36
+ $tri( l. lapacke_layout( ) , uplo as u8 , n, a, l. lda( ) ) . as_lapack_result( ) ?;
37
+ }
33
38
Ok ( ( ) )
34
39
}
35
40
36
- unsafe fn solve_cholesky(
41
+ fn solve_cholesky(
37
42
l: MatrixLayout ,
38
43
uplo: UPLO ,
39
44
a: & [ Self ] ,
@@ -42,8 +47,10 @@ macro_rules! impl_cholesky {
42
47
let ( n, _) = l. size( ) ;
43
48
let nrhs = 1 ;
44
49
let ldb = 1 ;
45
- $trs( l. lapacke_layout( ) , uplo as u8 , n, nrhs, a, l. lda( ) , b, ldb)
46
- . as_lapack_result( ) ?;
50
+ unsafe {
51
+ $trs( l. lapacke_layout( ) , uplo as u8 , n, nrhs, a, l. lda( ) , b, ldb)
52
+ . as_lapack_result( ) ?;
53
+ }
47
54
Ok ( ( ) )
48
55
}
49
56
}
0 commit comments