@@ -46,31 +46,19 @@ where
4646 }
4747}
4848
49- fn uninitialized < A , S > ( l : MatrixLayout ) -> ArrayBase < S , Ix2 >
50- where
51- A : Copy ,
52- S : DataOwned < Elem = A > ,
53- {
54- match l {
55- MatrixLayout :: C { row, lda } => unsafe {
56- ArrayBase :: uninitialized ( ( row as usize , lda as usize ) )
57- } ,
58- MatrixLayout :: F { col, lda } => unsafe {
59- ArrayBase :: uninitialized ( ( lda as usize , col as usize ) . f ( ) )
60- } ,
61- }
62- }
63-
6449pub fn replicate < A , Sv , So , D > ( a : & ArrayBase < Sv , D > ) -> ArrayBase < So , D >
6550where
6651 A : Copy ,
6752 Sv : Data < Elem = A > ,
6853 So : DataOwned < Elem = A > + DataMut ,
6954 D : Dimension ,
7055{
71- let mut b = unsafe { ArrayBase :: uninitialized ( a. dim ( ) ) } ;
72- b. assign ( a) ;
73- b
56+ unsafe {
57+ let ret = ArrayBase :: < So , D > :: build_uninit ( a. dim ( ) , |view| {
58+ a. assign_to ( view) ;
59+ } ) ;
60+ ret. assume_init ( )
61+ }
7462}
7563
7664fn clone_with_layout < A , Si , So > ( l : MatrixLayout , a : & ArrayBase < Si , Ix2 > ) -> ArrayBase < So , Ix2 >
7967 Si : Data < Elem = A > ,
8068 So : DataOwned < Elem = A > + DataMut ,
8169{
82- let mut b = uninitialized ( l) ;
83- b. assign ( a) ;
84- b
70+ let shape_builder = match l {
71+ MatrixLayout :: C { row, lda } => ( row as usize , lda as usize ) . set_f ( false ) ,
72+ MatrixLayout :: F { col, lda } => ( lda as usize , col as usize ) . set_f ( true ) ,
73+ } ;
74+ unsafe {
75+ let ret = ArrayBase :: < So , _ > :: build_uninit ( shape_builder, |view| {
76+ a. assign_to ( view) ;
77+ } ) ;
78+ ret. assume_init ( )
79+ }
8580}
8681
8782pub fn transpose_data < A , S > ( a : & mut ArrayBase < S , Ix2 > ) -> Result < & mut ArrayBase < S , Ix2 > >
0 commit comments