def mul(lin_op, val_dict, is_abs=False):
 if (lin_op.type is lo.VARIABLE):
  if (lin_op.data in val_dict):
   if is_abs:
    return np.abs(val_dict[lin_op.data])
   else:
    return val_dict[lin_op.data]
  else:
   return np.mat(np.zeros(lin_op.size))
 elif (lin_op.type is lo.NO_OP):
  return np.mat(np.zeros(lin_op.size))
 else:
  eval_args = []
  for arg in lin_op.args:
   eval_args.append(mul(arg, val_dict, is_abs))
  if is_abs:
   return op_abs_mul(lin_op, eval_args)
  else:
   return op_mul(lin_op, eval_args)

def mul ( lin_op , val_dict , is_abs = False ) : if ( lin_op . type is lo . VARIABLE ) : if ( lin_op . data in val_dict ) : if is_abs : return np . abs ( val_dict [ lin_op . data ] ) else : return val_dict [ lin_op . data ] else : return np . mat ( np . zeros ( lin_op . size ) ) elif ( lin_op . type is lo . NO_OP ) : return np . mat ( np . zeros ( lin_op . size ) ) else : eval_args = [ ] for arg in lin_op . args : eval_args . append ( mul ( arg , val_dict , is_abs ) ) if is_abs : return op_abs_mul ( lin_op , eval_args ) else : return op_mul ( lin_op , eval_args )
element-wise multiplication .