3939 finfo , inexact , atleast_2d
4040from scipy .linalg import (eigvals , solve_continuous_are , solve_discrete_are ,
4141 solve )
42- from .exception import ControlSlycot , ControlArgument
42+ from .exception import ControlSlycot , ControlArgument , ControlDimension
4343from .statesp import _ssmatrix
4444
4545# Make sure we have access to the right slycot routines
@@ -153,17 +153,17 @@ def lyap(A, Q, C=None, E=None):
153153 if C is None and E is None :
154154 # Check input data for consistency
155155 if shape (A ) != shape (Q ):
156- raise ControlArgument ("A and Q must be matrices of identical \
156+ raise ControlDimension ("A and Q must be matrices of identical \
157157 sizes." )
158158
159159 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
160- raise ControlArgument ("A must be a quadratic matrix." )
160+ raise ControlDimension ("A must be a square matrix." )
161161
162162 if size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]:
163- raise ControlArgument ("Q must be a quadratic matrix." )
163+ raise ControlDimension ("Q must be a square matrix." )
164164
165165 if not _is_symmetric (Q ):
166- raise ControlArgument ("Q must be a symmetric matrix." )
166+ raise ControlDimension ("Q must be a symmetric matrix." )
167167
168168 # Solve the Lyapunov equation by calling Slycot function sb03md
169169 try :
@@ -187,16 +187,16 @@ def lyap(A, Q, C=None, E=None):
187187 elif C is not None and E is None :
188188 # Check input data for consistency
189189 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
190- raise ControlArgument ("A must be a quadratic matrix." )
190+ raise ControlDimension ("A must be a square matrix." )
191191
192192 if size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]:
193- raise ControlArgument ("Q must be a quadratic matrix." )
193+ raise ControlDimension ("Q must be a square matrix." )
194194
195195 if (size (C ) > 1 and shape (C )[0 ] != n ) or \
196196 (size (C ) > 1 and shape (C )[1 ] != m ) or \
197197 (size (C ) == 1 and size (A ) != 1 ) or \
198198 (size (C ) == 1 and size (Q ) != 1 ):
199- raise ControlArgument ("C matrix has incompatible dimensions." )
199+ raise ControlDimension ("C matrix has incompatible dimensions." )
200200
201201 # Solve the Sylvester equation by calling the Slycot function sb04md
202202 try :
@@ -221,17 +221,17 @@ def lyap(A, Q, C=None, E=None):
221221 if (size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]) or \
222222 (size (Q ) > 1 and shape (Q )[0 ] != n ) or \
223223 (size (Q ) == 1 and n > 1 ):
224- raise ControlArgument ("Q must be a square matrix with the same \
224+ raise ControlDimension ("Q must be a square matrix with the same \
225225 dimension as A." )
226226
227227 if (size (E ) > 1 and shape (E )[0 ] != shape (E )[1 ]) or \
228228 (size (E ) > 1 and shape (E )[0 ] != n ) or \
229229 (size (E ) == 1 and n > 1 ):
230- raise ControlArgument ("E must be a square matrix with the same \
230+ raise ControlDimension ("E must be a square matrix with the same \
231231 dimension as A." )
232232
233233 if not _is_symmetric (Q ):
234- raise ControlArgument ("Q must be a symmetric matrix." )
234+ raise ControlDimension ("Q must be a symmetric matrix." )
235235
236236 # Make sure we have access to the write slicot routine
237237 try :
@@ -335,17 +335,17 @@ def dlyap(A, Q, C=None, E=None):
335335 if C is None and E is None :
336336 # Check input data for consistency
337337 if shape (A ) != shape (Q ):
338- raise ControlArgument ("A and Q must be matrices of identical \
338+ raise ControlDimension ("A and Q must be matrices of identical \
339339 sizes." )
340340
341341 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
342- raise ControlArgument ("A must be a quadratic matrix." )
342+ raise ControlDimension ("A must be a square matrix." )
343343
344344 if size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]:
345- raise ControlArgument ("Q must be a quadratic matrix." )
345+ raise ControlDimension ("Q must be a square matrix." )
346346
347347 if not _is_symmetric (Q ):
348- raise ControlArgument ("Q must be a symmetric matrix." )
348+ raise ControlDimension ("Q must be a symmetric matrix." )
349349
350350 # Solve the Lyapunov equation by calling the Slycot function sb03md
351351 try :
@@ -365,15 +365,15 @@ def dlyap(A, Q, C=None, E=None):
365365 elif C is not None and E is None :
366366 # Check input data for consistency
367367 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
368- raise ControlArgument ("A must be a quadratic matrix" )
368+ raise ControlDimension ("A must be a square matrix" )
369369
370370 if size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]:
371- raise ControlArgument ("Q must be a quadratic matrix" )
371+ raise ControlDimension ("Q must be a square matrix" )
372372
373373 if (size (C ) > 1 and shape (C )[0 ] != n ) or \
374374 (size (C ) > 1 and shape (C )[1 ] != m ) or \
375375 (size (C ) == 1 and size (A ) != 1 ) or (size (C ) == 1 and size (Q ) != 1 ):
376- raise ControlArgument ("C matrix has incompatible dimensions" )
376+ raise ControlDimension ("C matrix has incompatible dimensions" )
377377
378378 # Solve the Sylvester equation by calling Slycot function sb04qd
379379 try :
@@ -398,17 +398,17 @@ def dlyap(A, Q, C=None, E=None):
398398 if (size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]) or \
399399 (size (Q ) > 1 and shape (Q )[0 ] != n ) or \
400400 (size (Q ) == 1 and n > 1 ):
401- raise ControlArgument ("Q must be a square matrix with the same \
401+ raise ControlDimension ("Q must be a square matrix with the same \
402402 dimension as A." )
403403
404404 if (size (E ) > 1 and shape (E )[0 ] != shape (E )[1 ]) or \
405405 (size (E ) > 1 and shape (E )[0 ] != n ) or \
406406 (size (E ) == 1 and n > 1 ):
407- raise ControlArgument ("E must be a square matrix with the same \
407+ raise ControlDimension ("E must be a square matrix with the same \
408408 dimension as A." )
409409
410410 if not _is_symmetric (Q ):
411- raise ControlArgument ("Q must be a symmetric matrix." )
411+ raise ControlDimension ("Q must be a symmetric matrix." )
412412
413413 # Solve the generalized Lyapunov equation by calling Slycot
414414 # function sg03ad
@@ -572,23 +572,23 @@ def care_slycot(A, B, Q, R=None, S=None, E=None, stabilizing=True):
572572 if S is None and E is None :
573573 # Check input data for consistency
574574 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
575- raise ControlArgument ("A must be a square matrix." )
575+ raise ControlDimension ("A must be a square matrix." )
576576
577577 if (size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]) or \
578578 (size (Q ) > 1 and shape (Q )[0 ] != n ) or \
579579 size (Q ) == 1 and n > 1 :
580- raise ControlArgument ("Q must be a square matrix of the same \
580+ raise ControlDimension ("Q must be a square matrix of the same \
581581 dimension as A." )
582582
583583 if (size (B ) > 1 and shape (B )[0 ] != n ) or \
584584 size (B ) == 1 and n > 1 :
585- raise ControlArgument ("Incompatible dimensions of B matrix." )
585+ raise ControlDimension ("Incompatible dimensions of B matrix." )
586586
587587 if not _is_symmetric (Q ):
588- raise ControlArgument ("Q must be a symmetric matrix." )
588+ raise ControlDimension ("Q must be a symmetric matrix." )
589589
590590 if not _is_symmetric (R ):
591- raise ControlArgument ("R must be a symmetric matrix." )
591+ raise ControlDimension ("R must be a symmetric matrix." )
592592
593593 # Create back-up of arrays needed for later computations
594594 R_ba = copy (R )
@@ -657,41 +657,41 @@ def care_slycot(A, B, Q, R=None, S=None, E=None, stabilizing=True):
657657 elif S is not None and E is not None :
658658 # Check input data for consistency
659659 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
660- raise ControlArgument ("A must be a quadratic matrix." )
660+ raise ControlDimension ("A must be a square matrix." )
661661
662662 if (size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]) or \
663663 (size (Q ) > 1 and shape (Q )[0 ] != n ) or \
664664 size (Q ) == 1 and n > 1 :
665- raise ControlArgument ("Q must be a quadratic matrix of the same \
665+ raise ControlDimension ("Q must be a square matrix of the same \
666666 dimension as A." )
667667
668668 if (size (B ) > 1 and shape (B )[0 ] != n ) or \
669669 size (B ) == 1 and n > 1 :
670- raise ControlArgument ("Incompatible dimensions of B matrix." )
670+ raise ControlDimension ("Incompatible dimensions of B matrix." )
671671
672672 if (size (E ) > 1 and shape (E )[0 ] != shape (E )[1 ]) or \
673673 (size (E ) > 1 and shape (E )[0 ] != n ) or \
674674 size (E ) == 1 and n > 1 :
675- raise ControlArgument ("E must be a quadratic matrix of the same \
675+ raise ControlDimension ("E must be a square matrix of the same \
676676 dimension as A." )
677677
678678 if (size (R ) > 1 and shape (R )[0 ] != shape (R )[1 ]) or \
679679 (size (R ) > 1 and shape (R )[0 ] != m ) or \
680680 size (R ) == 1 and m > 1 :
681- raise ControlArgument ("R must be a quadratic matrix of the same \
681+ raise ControlDimension ("R must be a square matrix of the same \
682682 dimension as the number of columns in the B matrix." )
683683
684684 if (size (S ) > 1 and shape (S )[0 ] != n ) or \
685685 (size (S ) > 1 and shape (S )[1 ] != m ) or \
686686 size (S ) == 1 and n > 1 or \
687687 size (S ) == 1 and m > 1 :
688- raise ControlArgument ("Incompatible dimensions of S matrix." )
688+ raise ControlDimension ("Incompatible dimensions of S matrix." )
689689
690690 if not _is_symmetric (Q ):
691- raise ControlArgument ("Q must be a symmetric matrix." )
691+ raise ControlDimension ("Q must be a symmetric matrix." )
692692
693693 if not _is_symmetric (R ):
694- raise ControlArgument ("R must be a symmetric matrix." )
694+ raise ControlDimension ("R must be a symmetric matrix." )
695695
696696 # Create back-up of arrays needed for later computations
697697 R_b = copy (R )
@@ -884,23 +884,23 @@ def dare_slycot(A, B, Q, R, S=None, E=None, stabilizing=True):
884884 if S is None and E is None :
885885 # Check input data for consistency
886886 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
887- raise ControlArgument ("A must be a quadratic matrix." )
887+ raise ControlDimension ("A must be a square matrix." )
888888
889889 if (size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]) or \
890890 (size (Q ) > 1 and shape (Q )[0 ] != n ) or \
891891 size (Q ) == 1 and n > 1 :
892- raise ControlArgument ("Q must be a quadratic matrix of the same \
892+ raise ControlDimension ("Q must be a square matrix of the same \
893893 dimension as A." )
894894
895895 if (size (B ) > 1 and shape (B )[0 ] != n ) or \
896896 size (B ) == 1 and n > 1 :
897- raise ControlArgument ("Incompatible dimensions of B matrix." )
897+ raise ControlDimension ("Incompatible dimensions of B matrix." )
898898
899899 if not _is_symmetric (Q ):
900- raise ControlArgument ("Q must be a symmetric matrix." )
900+ raise ControlDimension ("Q must be a symmetric matrix." )
901901
902902 if not _is_symmetric (R ):
903- raise ControlArgument ("R must be a symmetric matrix." )
903+ raise ControlDimension ("R must be a symmetric matrix." )
904904
905905 # Create back-up of arrays needed for later computations
906906 A_ba = copy (A )
@@ -973,41 +973,41 @@ def dare_slycot(A, B, Q, R, S=None, E=None, stabilizing=True):
973973 elif S is not None and E is not None :
974974 # Check input data for consistency
975975 if size (A ) > 1 and shape (A )[0 ] != shape (A )[1 ]:
976- raise ControlArgument ("A must be a quadratic matrix." )
976+ raise ControlDimension ("A must be a square matrix." )
977977
978978 if (size (Q ) > 1 and shape (Q )[0 ] != shape (Q )[1 ]) or \
979979 (size (Q ) > 1 and shape (Q )[0 ] != n ) or \
980980 size (Q ) == 1 and n > 1 :
981- raise ControlArgument ("Q must be a quadratic matrix of the same \
981+ raise ControlDimension ("Q must be a square matrix of the same \
982982 dimension as A." )
983983
984984 if (size (B ) > 1 and shape (B )[0 ] != n ) or \
985985 size (B ) == 1 and n > 1 :
986- raise ControlArgument ("Incompatible dimensions of B matrix." )
986+ raise ControlDimension ("Incompatible dimensions of B matrix." )
987987
988988 if (size (E ) > 1 and shape (E )[0 ] != shape (E )[1 ]) or \
989989 (size (E ) > 1 and shape (E )[0 ] != n ) or \
990990 size (E ) == 1 and n > 1 :
991- raise ControlArgument ("E must be a quadratic matrix of the same \
991+ raise ControlDimension ("E must be a square matrix of the same \
992992 dimension as A." )
993993
994994 if (size (R ) > 1 and shape (R )[0 ] != shape (R )[1 ]) or \
995995 (size (R ) > 1 and shape (R )[0 ] != m ) or \
996996 size (R ) == 1 and m > 1 :
997- raise ControlArgument ("R must be a quadratic matrix of the same \
997+ raise ControlDimension ("R must be a square matrix of the same \
998998 dimension as the number of columns in the B matrix." )
999999
10001000 if (size (S ) > 1 and shape (S )[0 ] != n ) or \
10011001 (size (S ) > 1 and shape (S )[1 ] != m ) or \
10021002 size (S ) == 1 and n > 1 or \
10031003 size (S ) == 1 and m > 1 :
1004- raise ControlArgument ("Incompatible dimensions of S matrix." )
1004+ raise ControlDimension ("Incompatible dimensions of S matrix." )
10051005
10061006 if not _is_symmetric (Q ):
1007- raise ControlArgument ("Q must be a symmetric matrix." )
1007+ raise ControlDimension ("Q must be a symmetric matrix." )
10081008
10091009 if not _is_symmetric (R ):
1010- raise ControlArgument ("R must be a symmetric matrix." )
1010+ raise ControlDimension ("R must be a symmetric matrix." )
10111011
10121012 # Create back-up of arrays needed for later computations
10131013 A_b = copy (A )
0 commit comments