@@ -130,12 +130,12 @@ impl<'a, T, D> GridCubicSmoothingSpline<'a, T, D>
130130 D : Dimension
131131{
132132 /// Creates `NdGridCubicSmoothingSpline` struct from the given `X` data sites and `Y` data values
133- pub fn new < X , Y > ( x : & ' a [ X ] , y : Y ) -> Self
134- where X : AsArray < ' a , T > + AsRef < [ T ] > ,
135- Y : AsArray < ' a , T , D >
133+ pub fn new < Y > ( x : & [ ArrayView1 < ' a , T > ] , y : Y ) -> Self
134+ where
135+ Y : AsArray < ' a , T , D >
136136 {
137137 GridCubicSmoothingSpline {
138- x : x. iter ( ) . map_into ( ) . collect ( ) ,
138+ x : x. to_vec ( ) ,
139139 y : y. into ( ) ,
140140 weights : None ,
141141 smooth : None ,
@@ -147,18 +147,9 @@ impl<'a, T, D> GridCubicSmoothingSpline<'a, T, D>
147147 ///
148148 /// `weights.len()` must be equal to `x.len()`
149149 ///
150- pub fn with_weights < W > ( mut self , weights : & ' a [ Option < W > ] ) -> Self
151- where W : AsArray < ' a , T > + AsRef < [ T ] >
152- {
153- let weights = weights. iter ( ) . map ( |w| {
154- match w {
155- Some ( w) => Some ( w. into ( ) ) ,
156- None => None ,
157- }
158- } ) . collect ( ) ;
159-
150+ pub fn with_weights ( mut self , weights : & [ Option < ArrayView1 < ' a , T > > ] ) -> Self {
160151 self . invalidate ( ) ;
161- self . weights = Some ( weights) ;
152+ self . weights = Some ( weights. to_vec ( ) ) ;
162153 self
163154 }
164155
@@ -199,13 +190,21 @@ impl<'a, T, D> GridCubicSmoothingSpline<'a, T, D>
199190 /// - If the `xi` data is invalid
200191 /// - If the spline yet has not been computed
201192 ///
202- pub fn evaluate < X > ( & self , xi : & ' a [ X ] ) -> Result < Array < T , D > >
203- where X : AsArray < ' a , T > + AsRef < [ T ] >
204- {
205- let xi: Vec < ArrayView1 < ' a , T > > = xi. iter ( ) . map_into ( ) . collect ( ) ;
193+ pub fn evaluate ( & self , xi : & [ ArrayView1 < ' a , T > ] ) -> Result < Array < T , D > > {
194+ let xi = xi. to_vec ( ) ;
206195 self . evaluate_spline ( & xi)
207196 }
208197
198+ /// Returns the ref to smoothing parameters vector or None
199+ pub fn smooth ( & self ) -> Option < & Vec < Option < T > > > {
200+ self . smooth . as_ref ( )
201+ }
202+
203+ /// Returns ref to `NdGridSpline` struct with data of computed spline or None
204+ pub fn spline ( & self ) -> Option < & NdGridSpline < ' a , T , D > > {
205+ self . spline . as_ref ( )
206+ }
207+
209208 /// Invalidate computed spline
210209 fn invalidate ( & mut self ) {
211210 self . spline = None ;
0 commit comments