BUG: signal: lsim
returns incorrect results when the state space matrix A
has integer type
#18982
Labels
defect
A clear bug or issue that prevents SciPy from being installed or used as expected
scipy.signal
Describe your issue.
This problem showed up in a stackoverflow question. The output of
lsim
did not match the output produced by another library, and in fact the result was radically different and obviously not correct.Here is a simple example. The components of the solution should exhibit exponential decay, but instead they immediately jump to zero. And note that solution is an integer array:
If
A
is converted tofloat64
, the result are as expected:The source of the problem is here:
scipy/scipy/signal/_ltisys.py
Line 2094 in 9e3f5fd
The type of the
xout
array should not be copied directly from the type ofA
. WhenA
is an integer type,out
should befloat64
.Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: