Skip to content

Commit c18d868

Browse files
author
John Halloran
committed
chore: remove old residual matrix and reference to derivatives
1 parent da3a938 commit c18d868

File tree

1 file changed

+1
-48
lines changed

1 file changed

+1
-48
lines changed

src/diffpy/snmf/snmf_class.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -346,40 +346,6 @@ def get_residual_matrix(self, components=None, weights=None, stretch=None):
346346

347347
return residuals
348348

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-
383349
def get_objective_function(self, residuals=None, stretch=None):
384350
if residuals is None:
385351
residuals = self.residuals
@@ -751,7 +717,6 @@ def cubic_largest_real_root(p, q):
751717
def apply_interpolation(a, x):
752718
"""
753719
Applies an interpolation-based transformation to `x` based on scaling `a`.
754-
Also computes first (`d_intr_x`) and second (`dd_intr_x`) derivatives.
755720
"""
756721
x_len = len(x)
757722

@@ -780,16 +745,4 @@ def apply_interpolation(a, x):
780745
intr_x_tail = np.full((x_len - len(idx_int), interpolated_x.shape[1]), interpolated_x[-1, :])
781746
interpolated_x = np.vstack([interpolated_x, intr_x_tail])
782747

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

Comments
 (0)