#NEWLINE# def lti_disc( self , F , L , Qc , dt ) : #NEWLINE# #INDENT# n = F . shape [ 0 ] #NEWLINE# index = 0 #NEWLINE# if ( dt . flatten ( ) . shape [ 0 ] == 1 ) : #NEWLINE# #INDENT# Phi = np . zeros ( ( ( 2 * n ) , ( 2 * n ) ) ) #NEWLINE# Phi [ : n , : n ] = F #NEWLINE# Phi [ : n , n : ] = L . dot ( Qc ) . dot ( L . T ) #NEWLINE# Phi [ n : , n : ] = ( - F . T ) #NEWLINE# AB = linalg . expm ( ( Phi * dt ) ) . dot ( np . vstack ( ( np . zeros ( ( n , n ) ) , np . eye ( n ) ) ) ) #NEWLINE# Q = linalg . solve ( AB [ n : , : ] . T , AB [ : n , : ] . T ) #NEWLINE# A = linalg . expm ( ( F * dt ) ) #NEWLINE# return ( A , Q ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( dt , _ , index ) = np . unique ( np . round ( dt , 14 ) , True , True ) #NEWLINE# A = np . empty ( ( n , n , dt . shape [ 0 ] ) ) #NEWLINE# Q = np . empty ( ( n , n , dt . shape [ 0 ] ) ) #NEWLINE# for j in range ( 0 , dt . shape [ 0 ] ) : #NEWLINE# #INDENT# ( A [ : , : , j ] , Q [ : , : , j ] ) = self . lti_disc ( F , L , Qc , dt [ j ] ) #NEWLINE# #UNINDENT# return ( A , Q , index )