Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

allow complex statespace matrices#484

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
bnavigator wants to merge1 commit intopython-control:main
base:main
Choose a base branch
Loading
frombnavigator:complex-statespace
Draft
Changes fromall 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
31 changes: 20 additions & 11 deletionscontrol/statesp.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,38 +93,47 @@ def _ssmatrix(data, axis=1):

Returns
-------
arr : 2D array, with shape (0, 0) if a is empty
arr :real or complex2D array, with shape (0, 0) if a is empty

"""
# Convert the data into an array or matrix, as configured

# If data is passed as a string, use (deprecated?) matrix constructor
if isinstance(data, str):
arr = np.asarray(np.matrix(data))
else:
# TODO: Is it okay to use a view here (asarray or copy=False)?
arr = np.array(data)

# find out if we need to cast to float or complex
arr_ndtype = np.result_type(np.float64, arr)

# Get a view of the data as 2D array or matrix, as configured
if config.defaults['statesp.use_numpy_matrix']:
arr = np.matrix(data, dtype=float)
elif isinstance(data, str):
arr = np.array(np.matrix(data, dtype=float))
arr = np.asmatrix(arr, dtype=arr_ndtype)
else:
arr = np.array(data, dtype=float)
arr = np.asarray(arr, dtype=arr_ndtype)

ndim = arr.ndim
shape = arr.shape

# Change the shape of the array into a 2D array
if (ndim > 2):
raise ValueError("state-space matrix must be 2-dimensional")

elif (ndim == 2 and shape ==(1, 0)) or \
(ndim == 1 and shape ==(0, )):
# Passed an empty matrixorempty vector; change shape to (0, 0)
# note: default empty matrix is(1,0)
if shape in [(1, 0),(0, )]:
# Passed an empty matrix, listorarray vector; change shape to (0, 0)
shape = (0, 0)

elif ndim == 1:
# Passed a row or column vector
# Passed anon-emptyrow or column vector
shape = (1, shape[0]) if axis == 1 else (shape[0], 1)

elif ndim == 0:
# Passed a constant; turn into a matrix
shape = (1, 1)

# Createtheactual object used to storetheresult
#createthecorrect view ofthedata
return arr.reshape(shape)


Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp