#NEWLINE# def _representing_matrices( basis , G , ring ) : #NEWLINE# #INDENT# '\n    Compute the matrices corresponding to the linear maps `m \\mapsto\n    x_i m` for all variables `x_i`.\n    ' #NEWLINE# domain = ring . domain #NEWLINE# u = ( ring . ngens - 1 ) #NEWLINE# def var( i ) : #NEWLINE# #INDENT# return tuple ( ( ( ( [ 0 ] * i ) + [ 1 ] ) + ( [ 0 ] * ( u - i ) ) ) ) #NEWLINE# #UNINDENT# def representing_matrix( m ) : #NEWLINE# #INDENT# M = [ ( [ domain . zero ] * len ( basis ) ) for _ in range ( len ( basis ) ) ] #NEWLINE# for ( i , v ) in enumerate ( basis ) : #NEWLINE# #INDENT# r = ring . term_new ( monomial_mul ( m , v ) , domain . one ) . rem ( G ) #NEWLINE# for ( monom , coeff ) in r . terms ( ) : #NEWLINE# #INDENT# j = basis . index ( monom ) #NEWLINE# M [ j ] [ i ] = coeff #NEWLINE# #UNINDENT# #UNINDENT# return M #NEWLINE# #UNINDENT# return [ representing_matrix ( var ( i ) ) for i in range ( ( u + 1 ) ) ]