Skip to content

Call by reference in ab13bd #199

Description

@KybernetikJo

State space matrices A,B,C,D are changed after call.

    out = _wrapper.ab13bd(dico, jobn, n, m, p, A, B, C, D, tol)

Fix, shallow copy

    a = A.copy()
    b = B.copy()
    c = C.copy()
    d = D.copy()

    out = _wrapper.ab13bd(dico, jobn, n, m, p, a, b, c, d, tol)

Activity

  1. KybernetikJo commented on Jul 19, 2023

    @KybernetikJo
    ContributorAuthor
    def h2norm_slycot_c(A,B,C,D):
        dico = 'C'
        jobn = 'H'
    
        n, m = B.shape
        p, _ = C.shape
    
        #a = A.copy()
        #b = B.copy()
        #c = C.copy()
        #d = D.copy()
    
        a = A
        b = B
        c = C
        d = D
    
        h2norm = 0
        h2norm = slycot.ab13bd(dico, jobn, n, m, p, a, b, c, d)
        return h2norm
    
    A1 = np.array([[0.0, 1.0],[-0.5, -0.1]])
    B1 = np.array([[0.],[1.]])
    C1 = np.eye(2)
    D1 = np.zeros((2,1))
    
    print(h2norm_slycot_c(A1,B1,C1,D1))
    print(h2norm_slycot_c(A1,B1,C1,D1))
    print(h2norm_slycot_c(A1,B1,C1,D1))
    
    # 3.872983346207419
    # 3.838232974288851
    # 3.7856002470901817

    Fix, shallow copy

    def h2norm_slycot_c(A,B,C,D):
        dico = 'C'
        jobn = 'H'
    
        n, m = B.shape
        p, _ = C.shape
    
        a = A.copy()
        b = B.copy()
        c = C.copy()
        d = D.copy()
    
        #a = A
        #b = B
        #c = C
        #d = D
    
        h2norm = 0
        h2norm = slycot.ab13bd(dico, jobn, n, m, p, a, b, c, d)
        return h2norm
    
    A1 = np.array([[0.0, 1.0],[-0.5, -0.1]])
    B1 = np.array([[0.],[1.]])
    C1 = np.eye(2)
    D1 = np.zeros((2,1))
    
    print(h2norm_slycot_c(A1,B1,C1,D1))
    print(h2norm_slycot_c(A1,B1,C1,D1))
    print(h2norm_slycot_c(A1,B1,C1,D1))
    
    # 3.872983346207419
    # 3.872983346207419
    # 3.872983346207419
  2. roryyorke commented on Jul 22, 2023

    @roryyorke
    Collaborator

    For future readers: see #200 for further discussion.

  3. added a commit that references this issue on Jul 22, 2023
  4. bnavigator commented on Aug 26, 2023

    @bnavigator
    Collaborator

    Closed by #200, the general issue is still open.

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