@@ -84,6 +84,7 @@ pub mod error;
84
84
pub mod flags;
85
85
pub mod layout;
86
86
87
+ mod alloc;
87
88
mod cholesky;
88
89
mod eig;
89
90
mod eigh;
@@ -113,6 +114,7 @@ pub use self::svddc::*;
113
114
pub use self :: triangular:: * ;
114
115
pub use self :: tridiagonal:: * ;
115
116
117
+ use self :: alloc:: * ;
116
118
use cauchy:: * ;
117
119
use std:: mem:: MaybeUninit ;
118
120
@@ -140,61 +142,3 @@ impl Lapack for f32 {}
140
142
impl Lapack for f64 { }
141
143
impl Lapack for c32 { }
142
144
impl Lapack for c64 { }
143
-
144
- /// Helper for getting pointer of slice
145
- pub ( crate ) trait AsPtr : Sized {
146
- type Elem ;
147
- fn as_ptr ( vec : & [ Self ] ) -> * const Self :: Elem ;
148
- fn as_mut_ptr ( vec : & mut [ Self ] ) -> * mut Self :: Elem ;
149
- }
150
-
151
- macro_rules! impl_as_ptr {
152
- ( $target: ty, $elem: ty) => {
153
- impl AsPtr for $target {
154
- type Elem = $elem;
155
- fn as_ptr( vec: & [ Self ] ) -> * const Self :: Elem {
156
- vec. as_ptr( ) as * const _
157
- }
158
- fn as_mut_ptr( vec: & mut [ Self ] ) -> * mut Self :: Elem {
159
- vec. as_mut_ptr( ) as * mut _
160
- }
161
- }
162
- } ;
163
- }
164
- impl_as_ptr ! ( i32 , i32 ) ;
165
- impl_as_ptr ! ( f32 , f32 ) ;
166
- impl_as_ptr ! ( f64 , f64 ) ;
167
- impl_as_ptr ! ( c32, lapack_sys:: __BindgenComplex<f32 >) ;
168
- impl_as_ptr ! ( c64, lapack_sys:: __BindgenComplex<f64 >) ;
169
- impl_as_ptr ! ( MaybeUninit <i32 >, i32 ) ;
170
- impl_as_ptr ! ( MaybeUninit <f32 >, f32 ) ;
171
- impl_as_ptr ! ( MaybeUninit <f64 >, f64 ) ;
172
- impl_as_ptr ! ( MaybeUninit <c32>, lapack_sys:: __BindgenComplex<f32 >) ;
173
- impl_as_ptr ! ( MaybeUninit <c64>, lapack_sys:: __BindgenComplex<f64 >) ;
174
-
175
- pub ( crate ) trait VecAssumeInit {
176
- type Target ;
177
- unsafe fn assume_init ( self ) -> Self :: Target ;
178
- }
179
-
180
- impl < T > VecAssumeInit for Vec < MaybeUninit < T > > {
181
- type Target = Vec < T > ;
182
- unsafe fn assume_init ( self ) -> Self :: Target {
183
- // FIXME use Vec::into_raw_parts instead after stablized
184
- // https://doc.rust-lang.org/std/vec/struct.Vec.html#method.into_raw_parts
185
- let mut me = std:: mem:: ManuallyDrop :: new ( self ) ;
186
- Vec :: from_raw_parts ( me. as_mut_ptr ( ) as * mut T , me. len ( ) , me. capacity ( ) )
187
- }
188
- }
189
-
190
- /// Create a vector without initialization
191
- ///
192
- /// Safety
193
- /// ------
194
- /// - Memory is not initialized. Do not read the memory before write.
195
- ///
196
- unsafe fn vec_uninit < T : Sized > ( n : usize ) -> Vec < MaybeUninit < T > > {
197
- let mut v = Vec :: with_capacity ( n) ;
198
- v. set_len ( n) ;
199
- v
200
- }
0 commit comments