@@ -346,40 +346,6 @@ def get_residual_matrix(self, components=None, weights=None, stretch=None):
346
346
347
347
return residuals
348
348
349
- def old_get_residual_matrix (self , components = None , weights = None , stretch = None ):
350
- # Initialize residual matrix as negative of source_matrix
351
- if components is None :
352
- components = self .components
353
- if weights is None :
354
- weights = self .weights
355
- if stretch is None :
356
- stretch = self .stretch
357
- residuals = - self .source_matrix .copy ()
358
-
359
- # Discrete sample positions along the component axis
360
- sample_indices = np .arange (components .shape [0 ]) # (N,)
361
-
362
- for comp in range (components .shape [1 ]): # loop over components
363
- component_profile = components [:, comp ] # (N,)
364
- stretch_factors = stretch [comp , :] # (M,)
365
-
366
- # Compute scaled/fractional positions along component_profile
367
- fractional_positions = sample_indices [:, None ] / stretch_factors [None , :]
368
-
369
- # Interpolate component_profile at fractional positions, clamp to ends
370
- interpolated_component = np .interp (
371
- fractional_positions ,
372
- sample_indices ,
373
- component_profile ,
374
- left = component_profile [0 ],
375
- right = component_profile [- 1 ],
376
- )
377
-
378
- # Accumulate weighted contribution into residuals
379
- residuals += interpolated_component * weights [comp , None , :] # (M,) broadcast
380
-
381
- return residuals
382
-
383
349
def get_objective_function (self , residuals = None , stretch = None ):
384
350
if residuals is None :
385
351
residuals = self .residuals
@@ -751,7 +717,6 @@ def cubic_largest_real_root(p, q):
751
717
def apply_interpolation (a , x ):
752
718
"""
753
719
Applies an interpolation-based transformation to `x` based on scaling `a`.
754
- Also computes first (`d_intr_x`) and second (`dd_intr_x`) derivatives.
755
720
"""
756
721
x_len = len (x )
757
722
@@ -780,16 +745,4 @@ def apply_interpolation(a, x):
780
745
intr_x_tail = np .full ((x_len - len (idx_int ), interpolated_x .shape [1 ]), interpolated_x [- 1 , :])
781
746
interpolated_x = np .vstack ([interpolated_x , intr_x_tail ])
782
747
783
- """
784
- # Compute first derivative (d_intr_x)
785
- di = -idx_frac / a
786
- d_intr_x = x[idx_int] * (-di) + x[np.minimum(idx_int + 1, x_len - 1)] * di
787
- d_intr_x = np.vstack([d_intr_x, np.zeros((x_len - len(idx_int), d_intr_x.shape[1]))])
788
-
789
- # Compute second derivative (dd_intr_x)
790
- ddi = -di / a + idx_frac * a**-2
791
- dd_intr_x = x[idx_int] * (-ddi) + x[np.minimum(idx_int + 1, x_len - 1)] * ddi
792
- dd_intr_x = np.vstack([dd_intr_x, np.zeros((x_len - len(idx_int), dd_intr_x.shape[1]))])
793
- """
794
-
795
- return interpolated_x # , d_intr_x, dd_intr_x
748
+ return interpolated_x
0 commit comments