diff src/pt-cbinop.cc @ 9661:afcf852256d2

optimize / and '\ for triangular matrices
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 23 Sep 2009 10:00:16 +0200
parents dc6bda6f9994
children 9ecd35a606e3
line wrap: on
line diff
--- a/src/pt-cbinop.cc
+++ b/src/pt-cbinop.cc
@@ -106,6 +106,24 @@
   return retop;
 }
 
+// Possibly convert left division to trans_ldiv or herm_ldiv.
+
+static octave_value::compound_binary_op
+simplify_ldiv_op (tree_expression *&a, tree_expression *&b)
+{
+  octave_value::compound_binary_op retop;
+  octave_value::unary_op opa = strip_trans_herm (a);
+
+  if (opa == octave_value::op_hermitian)
+    retop = octave_value::op_herm_ldiv;
+  else if (opa == octave_value::op_transpose)
+    retop = octave_value::op_trans_ldiv;
+  else
+    retop = octave_value::unknown_compound_binary_op;
+
+  return retop;
+}
+
 // Possibly contract and/or with negation.
 
 static octave_value::compound_binary_op
@@ -152,6 +170,10 @@
       ct = simplify_mul_op (ca, cb);
       break;
 
+    case octave_value::op_ldiv:
+      ct = simplify_ldiv_op (ca, cb);
+      break;
+
     case octave_value::op_el_and:
     case octave_value::op_el_or:
       ct = simplify_and_or_op (ca, cb, t);