#NEWLINE# def test_State_algebra( ) : #NEWLINE# #INDENT# static_siso_state = State ( 5 ) #NEWLINE# static_mimo_state = State ( ( 2.0 * np . eye ( 3 ) ) ) #NEWLINE# dynamic_siso_state = State ( haroldcompanion ( [ 1 , 3 , 3 , 1 ] ) , eyecolumn ( 3 , ( - 1 ) ) , eyecolumn ( 3 , 1 ) . T , 0 ) #NEWLINE# dynamic_mimo_state = State ( haroldcompanion ( [ 1 , 3 , 3 , 1 ] ) , eyecolumn ( 3 , [ 1 , 2 ] ) , np . eye ( 3 ) , np . zeros ( ( 3 , 2 ) ) ) #NEWLINE# dynamic_square_state = State ( haroldcompanion ( [ 1 , 3 , 3 , 1 ] ) , np . eye ( 3 ) , np . eye ( 3 ) , np . zeros ( ( 3 , 3 ) ) ) #NEWLINE# assert_raises ( IndexError , dynamic_siso_state . __mul__ , static_mimo_state ) #NEWLINE# assert_raises ( IndexError , dynamic_siso_state . __add__ , static_mimo_state ) #NEWLINE# assert_raises ( IndexError , static_mimo_state . __add__ , dynamic_mimo_state ) #NEWLINE# F = ( static_mimo_state * dynamic_siso_state ) #NEWLINE# npt . assert_almost_equal ( F . c , ( np . eye ( 3 ) * 2.0 ) ) #NEWLINE# npt . assert_almost_equal ( ( dynamic_square_state + static_mimo_state ) . d , ( 2 * np . eye ( 3 ) ) )