Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Fix: a and c matrices must have at least one column in td04ad_r
This allows conversion of static gain (i.e., constant) transfer
functions.

SLICOT and Fortran can possibly handle the 0 case, but f2py seems to not
like dimensions of length 0.

td04ad_c needs a similar fix, but I couldn't get it to work; I suspect
this is due to a bug in SLICOT.
  • Loading branch information
roryyorke committed Jan 11, 2017
commit 9a098d124cb31c083d26feae746a1f98e26d1a90
7 changes: 5 additions & 2 deletions slycot/src/transform.pyf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
! -*- f90 -*-
! Note: the context of this file is case sensitive.

subroutine tb01id(job,n,m,p,maxred,a,lda,b,ldb,c,ldc,scale,info) ! in TB01ID.f
character intent(in) :: job = 'A'
integer required,check(n>0) :: n
Expand Down Expand Up @@ -227,11 +230,11 @@ subroutine td04ad_r(rowcol,m,p,index_bn,dcoeff,lddcoe,ucoeff,lduco1,lduco2,nr,a,
integer intent(hide),depend(ucoeff) :: lduco1=shape(ucoeff,0)
integer intent(hide),depend(ucoeff) :: lduco2=shape(ucoeff,1)
integer intent(in,out) :: nr !=sum(index_bn)
double precision intent(out),dimension(max(1,nr),nr),depend(nr) :: a
double precision intent(out),dimension(max(1,nr),max(1,nr)),depend(nr) :: a
integer intent(hide),depend(a) :: lda = shape(a,0)
double precision intent(out),dimension(max(1,nr),max(m,p)),depend(nr,m,p) :: b
integer intent(hide),depend(b) :: ldb = shape(b,0)
double precision intent(out),dimension(max(1,max(m,p)),nr),depend(nr,m,p) :: c
double precision intent(out),dimension(max(1,max(m,p)),max(1,nr)),depend(nr,m,p) :: c
integer intent(hide),depend(c) :: ldc = shape(c,0)
double precision intent(out),dimension(max(1,p),m),depend(p,m) :: d
integer intent(hide),depend(d) :: ldd = shape(d,0)
Expand Down
28 changes: 25 additions & 3 deletions slycot/tests/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from .. import synthesis
from .. import math

from slycot import synthesis
from slycot import math
from slycot import transform

class Test(unittest.TestCase):

Expand Down Expand Up @@ -48,3 +48,25 @@ def test_sb02ad(self):
self.assertAlmostEqual(Ac[0][1], -1)
self.assertAlmostEqual(Ac[1][0], 1)
self.assertAlmostEqual(Ac[1][1], -3)

def test_td04ad_static(self):
"""Regression: td04ad (TFM -> SS transformation) for static TFM"""
import numpy as np
from itertools import product
# 'C' fails on static TFs
for nout,nin,rc in product(range(1,6),range(1,6),['R']):
num = np.reshape(np.arange(nout*nin),(nout,nin,1))
if rc == 'R':
den = np.reshape(np.arange(1,1+nout),(nout,1))
else:
den = np.reshape(np.arange(1,1+nin),(nin,1))
index = np.tile([0],den.shape[0])
nr,a,b,c,d = transform.td04ad(rc,nin,nout,index,den,num)


def suite():
return unittest.TestLoader().loadTestsFromTestCase(TestConvert)


if __name__ == "__main__":
unittest.main()