GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Complex numbers in state space matrices get cast to real in `control.StateSpace(...)` constructor - a bug? · Issue #1058 · python-control/python-control

Complex numbers in state space matrices get cast to real in control.StateSpace(...) constructor - a bug? #1058

New issue
Copy link
New issue
Copy link
Open
Open
Complex numbers in state space matrices get cast to real in control.StateSpace(...) constructor - a bug?#1058
Copy link

Description

@artem-basalaev
artem-basalaev
opened on Nov 13, 2024
Issue body actions

I noticed that if I have complex numbers in my A,B,C,D state space matrices, there's casting complex numbers to real in control.StateSpace(A,B,C,D) which does not appear to be right (?) if there's imaginary part. Is it intentional? Is there a way around it?

Specifically, I think this line is responsible: https://github.com/python-control/python-control/blob/main/control/statesp.py#L2170. Note dtype=float. I have matrices with dtype=complex128. Minimally reproducible example (matrices are completely made up here, of course the real state space I'm working with is more realistic but also much bigger):

from control import StateSpace
import numpy as np
A = np.array([[1+1j,1+1j],[1+1j,1+1j]])
B = np.array([[1+1j,1+1j],[1+1j,1+1j]])
C = np.array([[1+1j,1+1j],[1+1j,1+1j]])
D = np.array([[1+1j,1+1j],[1+1j,1+1j]])
ss = StateSpace(A,B,C,D)

results in
statesp.py:2170: ComplexWarning: Casting complex values to real discards the imaginary part arr = np.array(data, dtype=float)

Activity

  1. murrayrm commented on Nov 13, 2024

    @murrayrm
    murrayrm
    on Nov 13, 2024
    Member
    More actions

    Allowing complex state space matrices would require quiet a few changes in various routines. You can find a discussion (and preliminary PR) in #484 (as well as issues referenced therein).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.