|
49 | 49 |
|
50 | 50 | import math |
51 | 51 | import numpy as np |
52 | | -from numpy import any, array, asarray, concatenate, cos, delete, \ |
53 | | - dot, empty, exp, eye, isinf, ones, pad, sin, zeros, squeeze, pi |
| 52 | +from numpy import any, asarray, concatenate, cos, delete, \ |
| 53 | + empty, exp, eye, isinf, ones, pad, sin, zeros, squeeze |
54 | 54 | from numpy.random import rand, randn |
55 | 55 | from numpy.linalg import solve, eigvals, matrix_rank |
56 | 56 | from numpy.linalg.linalg import LinAlgError |
@@ -1126,23 +1126,23 @@ def lft(self, other, nu=-1, ny=-1): |
1126 | 1126 | H22 = TH[ny:, self.nstates + other.nstates + self.ninputs - nu:] |
1127 | 1127 |
|
1128 | 1128 | Ares = np.block([ |
1129 | | - [A + B2.dot(T21), B2.dot(T22)], |
1130 | | - [Bbar1.dot(T11), Abar + Bbar1.dot(T12)] |
| 1129 | + [A + B2 @ T21, B2 @ T22], |
| 1130 | + [Bbar1 @ T11, Abar + Bbar1 @ T12] |
1131 | 1131 | ]) |
1132 | 1132 |
|
1133 | 1133 | Bres = np.block([ |
1134 | | - [B1 + B2.dot(H21), B2.dot(H22)], |
1135 | | - [Bbar1.dot(H11), Bbar2 + Bbar1.dot(H12)] |
| 1134 | + [B1 + B2 @ H21, B2 @ H22], |
| 1135 | + [Bbar1 @ H11, Bbar2 + Bbar1 @ H12] |
1136 | 1136 | ]) |
1137 | 1137 |
|
1138 | 1138 | Cres = np.block([ |
1139 | | - [C1 + D12.dot(T21), D12.dot(T22)], |
1140 | | - [Dbar21.dot(T11), Cbar2 + Dbar21.dot(T12)] |
| 1139 | + [C1 + D12 @ T21, D12 @ T22], |
| 1140 | + [Dbar21 @ T11, Cbar2 + Dbar21 @ T12] |
1141 | 1141 | ]) |
1142 | 1142 |
|
1143 | 1143 | Dres = np.block([ |
1144 | | - [D11 + D12.dot(H21), D12.dot(H22)], |
1145 | | - [Dbar21.dot(H11), Dbar22 + Dbar21.dot(H12)] |
| 1144 | + [D11 + D12 @ H21, D12 @ H22], |
| 1145 | + [Dbar21 @ H11, Dbar22 + Dbar21 @ H12] |
1146 | 1146 | ]) |
1147 | 1147 | return StateSpace(Ares, Bres, Cres, Dres, dt) |
1148 | 1148 |
|
@@ -1381,13 +1381,13 @@ def dynamics(self, t, x, u=None): |
1381 | 1381 | if np.size(x) != self.nstates: |
1382 | 1382 | raise ValueError("len(x) must be equal to number of states") |
1383 | 1383 | if u is None: |
1384 | | - return self.A.dot(x).reshape((-1,)) # return as row vector |
| 1384 | + return (self.A @ x).reshape((-1,)) # return as row vector |
1385 | 1385 | else: # received t, x, and u, ignore t |
1386 | 1386 | u = np.reshape(u, (-1, 1)) # force to column in case matrix |
1387 | 1387 | if np.size(u) != self.ninputs: |
1388 | 1388 | raise ValueError("len(u) must be equal to number of inputs") |
1389 | | - return self.A.dot(x).reshape((-1,)) \ |
1390 | | - + self.B.dot(u).reshape((-1,)) # return as row vector |
| 1389 | + return (self.A @ x).reshape((-1,)) \ |
| 1390 | + + (self.B @ u).reshape((-1,)) # return as row vector |
1391 | 1391 |
|
1392 | 1392 | def output(self, t, x, u=None): |
1393 | 1393 | """Compute the output of the system |
@@ -1424,13 +1424,13 @@ def output(self, t, x, u=None): |
1424 | 1424 | raise ValueError("len(x) must be equal to number of states") |
1425 | 1425 |
|
1426 | 1426 | if u is None: |
1427 | | - return self.C.dot(x).reshape((-1,)) # return as row vector |
| 1427 | + return (self.C @ x).reshape((-1,)) # return as row vector |
1428 | 1428 | else: # received t, x, and u, ignore t |
1429 | 1429 | u = np.reshape(u, (-1, 1)) # force to a column in case matrix |
1430 | 1430 | if np.size(u) != self.ninputs: |
1431 | 1431 | raise ValueError("len(u) must be equal to number of inputs") |
1432 | | - return self.C.dot(x).reshape((-1,)) \ |
1433 | | - + self.D.dot(u).reshape((-1,)) # return as row vector |
| 1432 | + return (self.C @ x).reshape((-1,)) \ |
| 1433 | + + (self.D @ u).reshape((-1,)) # return as row vector |
1434 | 1434 |
|
1435 | 1435 | def _isstatic(self): |
1436 | 1436 | """True if and only if the system has no dynamics, that is, |
@@ -1623,7 +1623,7 @@ def _rss_generate(states, inputs, outputs, cdtype, strictly_proper=False): |
1623 | 1623 | while True: |
1624 | 1624 | T = randn(states, states) |
1625 | 1625 | try: |
1626 | | - A = dot(solve(T, A), T) # A = T \ A * T |
| 1626 | + A = solve(T, A) @ T # A = T \ A @ T |
1627 | 1627 | break |
1628 | 1628 | except LinAlgError: |
1629 | 1629 | # In the unlikely event that T is rank-deficient, iterate again. |
|
0 commit comments