Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: correct mb03rd for default X=None argument #139

Merged
merged 2 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions slycot/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def mb03rd(n, A, X=None, jobx='U', sort='N', pmax=1.0, tol=0.0):
The matrix `A` to be block-diagonalized, in real Schur form.
X : (n, n) array_like, optional
A given matrix `X`, for accumulation of transformations (only if
`jobx`='U')
`jobx`='U'). Default value is identity matrix of order `n`.
bnavigator marked this conversation as resolved.
Show resolved Hide resolved
jobx : {'N', 'U'}, optional
Specifies whether or not the transformations are
accumulated, as follows:
Expand Down Expand Up @@ -230,7 +230,7 @@ def mb03rd(n, A, X=None, jobx='U', sort='N', pmax=1.0, tol=0.0):
'dwork' + hidden, 'info']

if X is None:
X = np.zeros((1, n))
X = np.eye(n)

Ar, Xr, nblcks, blsize, wr, wi, info = _wrapper.mb03rd(
jobx, sort, n, pmax, A, X, tol)
Expand Down
21 changes: 21 additions & 0 deletions slycot/tests/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@ def test_mb03rd(self):
test1_n, A, X, 'N', sort, test1_pmax, test1_tol)
assert Xr is None


bnavigator marked this conversation as resolved.
Show resolved Hide resolved
def test_mb03rd_default(self):
# regression: mb03rd was failing with no third arg (X) supplied
A = np.array([[ 6, -1, -7, -2, 2],
[-3, 4, 2, -7, 6],
[-6, -9, -3, -1, 10],
[-2, -4, 1, 5, 7],
[-7, -5, -6, 6, 7]])

Aschur, Tschur = schur(A)

X = Tschur.copy()

Ar, Xr, blsize, W = mb03rd(Aschur.shape[0], Aschur, X, 'U', 'N', pmax=1.0, tol=0.0)

Ar2, Xr2, blsize2, W2 = mb03rd(Aschur.shape[0], Aschur)

assert_allclose(Ar, Ar2)
assert_allclose(Xr, Tschur.dot(Xr2))

bnavigator marked this conversation as resolved.
Show resolved Hide resolved

def test_mb03vd_mb03vy_ex(self):
"""Test MB03VD and MB03VY
with the example given in the MB03VD SLICOT documentation"""
Expand Down