def tmul(lin_op, value, is_abs=False):
 if (lin_op.type is lo.VARIABLE):
  return {lin_op.data: value}
 elif (lin_op.type is lo.NO_OP):
  return {}
 else:
  if is_abs:
   result = op_abs_tmul(lin_op, value)
  else:
   result = op_tmul(lin_op, value)
  result_dicts = []
  for arg in lin_op.args:
   result_dicts.append(tmul(arg, result, is_abs))
  return sum_dicts(result_dicts)

def tmul ( lin_op , value , is_abs = False ) : if ( lin_op . type is lo . VARIABLE ) : return { lin_op . data : value } elif ( lin_op . type is lo . NO_OP ) : return { } else : if is_abs : result = op_abs_tmul ( lin_op , value ) else : result = op_tmul ( lin_op , value ) result_dicts = [ ] for arg in lin_op . args : result_dicts . append ( tmul ( arg , result , is_abs ) ) return sum_dicts ( result_dicts )
multiply the transpose of the expression tree by a vector .