def multMatVect(v, A, m1, B, m2):
 if (multMatVect.dot_modulo is None):
  A_sym = tensor.lmatrix('A')
  s_sym = tensor.ivector('s')
  m_sym = tensor.iscalar('m')
  A2_sym = tensor.lmatrix('A2')
  s2_sym = tensor.ivector('s2')
  m2_sym = tensor.iscalar('m2')
  o = DotModulo()(A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym)
  multMatVect.dot_modulo = function([A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym], o, profile=False)
 f = multMatVect.dot_modulo
 f.input_storage[0].storage[0] = A
 f.input_storage[1].storage[0] = v[:3]
 f.input_storage[2].storage[0] = m1
 f.input_storage[3].storage[0] = B
 f.input_storage[4].storage[0] = v[3:]
 f.input_storage[5].storage[0] = m2
 f.fn()
 r = f.output_storage[0].storage[0]
 return r

def multMatVect ( v , A , m1 , B , m2 ) : if ( multMatVect . dot_modulo is None ) : A_sym = tensor . lmatrix ( 'A' ) s_sym = tensor . ivector ( 's' ) m_sym = tensor . iscalar ( 'm' ) A2_sym = tensor . lmatrix ( 'A2' ) s2_sym = tensor . ivector ( 's2' ) m2_sym = tensor . iscalar ( 'm2' ) o = DotModulo ( ) ( A_sym , s_sym , m_sym , A2_sym , s2_sym , m2_sym ) multMatVect . dot_modulo = function ( [ A_sym , s_sym , m_sym , A2_sym , s2_sym , m2_sym ] , o , profile = False ) f = multMatVect . dot_modulo f . input_storage [ 0 ] . storage [ 0 ] = A f . input_storage [ 1 ] . storage [ 0 ] = v [ : 3 ] f . input_storage [ 2 ] . storage [ 0 ] = m1 f . input_storage [ 3 ] . storage [ 0 ] = B f . input_storage [ 4 ] . storage [ 0 ] = v [ 3 : ] f . input_storage [ 5 ] . storage [ 0 ] = m2 f . fn ( ) r = f . output_storage [ 0 ] . storage [ 0 ] return r
multiply the first half of v by a with a modulo of m1 and the second half by b with a modulo of m2 .