Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
56 changes: 34 additions & 22 deletions control/mateqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#
# Author: Bjorn Olofsson

# Python 3 compatibility (needs to go here)
from __future__ import print_function

# Copyright (c) 2011, All rights reserved.

# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -44,6 +41,34 @@
from .exception import ControlSlycot, ControlArgument
from .statesp import _ssmatrix

# Make sure we have access to the right slycot routines
try:
from slycot import sb03md57
# wrap without the deprecation warning
def sb03md(n, C, A, U, dico, job='X',fact='N',trana='N',ldwork=None):
ret = sb03md57(A, U, C, dico, job, fact, trana, ldwork)
return ret[2:]
except ImportError:
try:
from slycot import sb03md
except ImportError:
sb03md = None

try:
from slycot import sb04md
except ImportError:
sb04md = None

try:
from slycot import sb04qd
except ImportError:
sb0qmd = None

try:
from slycot import sg03ad
except ImportError:
sb04ad = None

__all__ = ['lyap', 'dlyap', 'dare', 'care']

#
Expand Down Expand Up @@ -93,17 +118,12 @@ def lyap(A, Q, C=None, E=None):
state space operations. See :func:`~control.use_numpy_matrix`.
"""

# Make sure we have access to the right slycot routines
try:
from slycot import sb03md
except ImportError:
if sb03md is None:
raise ControlSlycot("can't find slycot module 'sb03md'")

try:
from slycot import sb04md
except ImportError:
if sb04md is None:
raise ControlSlycot("can't find slycot module 'sb04md'")


# Reshape 1-d arrays
if len(shape(A)) == 1:
A = A.reshape(1, A.size)
Expand Down Expand Up @@ -279,19 +299,11 @@ def dlyap(A, Q, C=None, E=None):
of the same dimension. """

# Make sure we have access to the right slycot routines
try:
from slycot import sb03md
except ImportError:
if sb03md is None:
raise ControlSlycot("can't find slycot module 'sb03md'")

try:
from slycot import sb04qd
except ImportError:
if sb04qd is None:
raise ControlSlycot("can't find slycot module 'sb04qd'")

try:
from slycot import sg03ad
except ImportError:
if sg03ad is None:
raise ControlSlycot("can't find slycot module 'sg03ad'")

# Reshape 1-d arrays
Expand Down
29 changes: 22 additions & 7 deletions control/statefbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@
from .statesp import _ssmatrix
from .exception import ControlSlycot, ControlArgument, ControlDimension

# Make sure we have access to the right slycot routines
try:
from slycot import sb03md57
# wrap without the deprecation warning
def sb03md(n, C, A, U, dico, job='X',fact='N',trana='N',ldwork=None):
ret = sb03md57(A, U, C, dico, job, fact, trana, ldwork)
return ret[2:]
except ImportError:
try:
from slycot import sb03md
except ImportError:
sb03md = None

try:
from slycot import sb03od
except ImportError:
sb03od = None


__all__ = ['ctrb', 'obsv', 'gram', 'place', 'place_varga', 'lqr', 'lqe',
'acker']

Expand Down Expand Up @@ -574,7 +593,7 @@ def gram(sys, type):
* if `type` is not 'c', 'o', 'cf' or 'of'
* if system is unstable (sys.A has eigenvalues not in left half plane)

ImportError
ControlSlycot
if slycot routine sb03md cannot be found
if slycot routine sb03od cannot be found

Expand Down Expand Up @@ -614,9 +633,7 @@ def gram(sys, type):
if type == 'c' or type == 'o':
# Compute Gramian by the Slycot routine sb03md
# make sure Slycot is installed
try:
from slycot import sb03md
except ImportError:
if sb03md is None:
raise ControlSlycot("can't find slycot module 'sb03md'")
if type == 'c':
tra = 'T'
Expand All @@ -634,9 +651,7 @@ def gram(sys, type):

elif type == 'cf' or type == 'of':
# Compute cholesky factored gramian from slycot routine sb03od
try:
from slycot import sb03od
except ImportError:
if sb03od is None:
raise ControlSlycot("can't find slycot module 'sb03od'")
tra = 'N'
n = sys.nstates
Expand Down