@@ -63,7 +63,7 @@ def __init__(self, support, data={}, c=None, up_to_date=False):
6363 logger .info ("Creating discrete interpolator with {} degrees of freedom" .format (self .dof ))
6464 self .type = InterpolatorType .BASE_DISCRETE
6565 self .apply_scaling_matrix = True
66- self .add_ridge_regulatisation = True
66+ self .add_ridge_regularisation = True
6767 self .ridge_factor = 1e-8
6868 def set_nelements (self , nelements : int ) -> int :
6969 return self .support .set_nelements (nelements )
@@ -588,7 +588,7 @@ def solve_system(
588588 self ,
589589 solver : Optional [Union [Callable [[sparse .csr_matrix , np .ndarray ], np .ndarray ], str ]] = None ,
590590 tol : Optional [float ] = None ,
591- solver_kwargs : dict = {} ,
591+ solver_kwargs : dict = None ,
592592 ) -> bool :
593593 """
594594 Main entry point to run the solver and update the node value
@@ -608,15 +608,18 @@ def solve_system(
608608 True if the interpolation is run
609609
610610 """
611+ if solver_kwargs is None :
612+ solver_kwargs = {}
611613 if not self ._pre_solve ():
612614 raise ValueError ("Pre solve failed" )
613615
616+ S = None # Initialize scaling matrix
614617 A , b = self .build_matrix ()
615- if self .add_ridge_regulatisation :
618+ if self .add_ridge_regularisation :
616619 ridge = sparse .eye (A .shape [1 ]) * self .ridge_factor
617620 A = sparse .vstack ([A , ridge ])
618621 b = np .hstack ([b , np .zeros (A .shape [1 ])])
619- logger .info ("Adding ridge regularisation to interpolation matrix" )
622+ logger .info ("Adding ridge regularization to interpolation matrix" )
620623 if self .apply_scaling_matrix :
621624 S = self .compute_column_scaling_matrix (A )
622625 A = A @ S
@@ -650,9 +653,6 @@ def solve_system(
650653
651654 elif solver == 'lsmr' :
652655 logger .info ("Solving using lsmr" )
653- # if 'atol' not in solver_kwargs:
654- # if tol is not None:
655- # solver_kwargs['atol'] = tol
656656 if 'btol' not in solver_kwargs :
657657 if tol is not None :
658658 solver_kwargs ['btol' ] = tol
@@ -718,7 +718,11 @@ def solve_system(
718718 # self._post_solve()
719719 # apply scaling matrix to solution
720720 if self .apply_scaling_matrix :
721- self .c = S @ self .c
721+ if S is None :
722+ logger .error ("Scaling matrix S is not defined; skipping scaling of solution." )
723+ self .up_to_date = False
724+ else :
725+ self .c = S @ self .c
722726 return self .up_to_date
723727
724728 def update (self ) -> bool :
0 commit comments