Skip to content

Commit

Permalink
orthogonalization: Always call orthogonalize() from orthonormalize().
Browse files Browse the repository at this point in the history
  • Loading branch information
Sbte committed Nov 12, 2023
1 parent 084190c commit c6643b0
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions jadapy/orthogonalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ def DGKS(V, w, W=None, M=None, MV=None, MW=None, normalized=False, interface=Non
normalize(w, nrm, M, interface=interface)
prev_nrm = 1

if normalized:
return 1

return nrm

def modified_gs(V, w, W=None, M=None, MV=None, MW=None, normalized=False, interface=None):
if V is not None:
if len(V.shape) > 1:
Expand All @@ -80,9 +75,6 @@ def modified_gs(V, w, W=None, M=None, MV=None, MW=None, normalized=False, interf

if normalized:
normalize(w, M=M, interface=interface)
return 1

return None

def repeated_mgs(V, w, W=None, M=None, MV=None, MW=None, normalized=False, interface=None):
prev_nrm = None
Expand All @@ -101,11 +93,6 @@ def repeated_mgs(V, w, W=None, M=None, MV=None, MW=None, normalized=False, inter
normalize(w, nrm, M, interface=interface)
prev_nrm = 1

if normalized:
return 1

return nrm

def orthogonalize(V, w, W=None, M=None, MV=None, MW=None, method='Repeated MGS', normalized=False, interface=None):
if M is not None and V is not None and MV is None:
MV = M @ V
Expand All @@ -127,7 +114,7 @@ def orthogonalize(V, w, W=None, M=None, MV=None, MW=None, method='Repeated MGS',

return DGKS(V, w, W, M, MV, MW, normalized, interface)

def orthonormalize(V, w=None, W=None, M=None, MV=None, MW=None, method='Repeated MGS', interface=None):
def orthonormalize(V, w=None, M=None, MV=None, method='Repeated MGS', interface=None):
if w is None:
w = V
V = None
Expand All @@ -136,14 +123,10 @@ def orthonormalize(V, w=None, W=None, M=None, MV=None, MW=None, method='Repeated
if M is not None and V is not None and MV is None:
MV = M @ V

if M is not None and W is not None and MW is None:
MW = M @ W

# Orthonormalize with respect to the basis and itself
if len(w.shape) > 1 and w.shape[1] > 1:
for i in range(w.shape[1]):
orthonormalize(V, w[:, i], w[:, 0:i], M, MV, MW, method, interface)
orthogonalize(V, w[:, i], w[:, 0:i], M, MV, None, method, True, interface)
return

nrm = orthogonalize(V, w, W, M, MV, MW, method, True, interface)
normalize(w, nrm, M, interface=interface)
orthogonalize(V, w, None, M, MV, None, method, True, interface)

0 comments on commit c6643b0

Please sign in to comment.