changeset 19690:bf88eab464b8

Detect binary operations with a transposed matrix and forward to BLAS (bug #42716). * pt-cbinop.cc (tree_compound_binary_expression::rvalue, tree_compound_binary_expression::rvalue1): New functions. ::rvalue validates input and calls ::rvalue1. rvalue1 calls do_binary_op with the correct transpose flag. * pt-cbinop.h: Add new functions to header file.
author David Bateman <dbateman@free.fr>
date Tue, 03 Feb 2015 12:27:58 -0800
parents af4ad21a82fc
children 0cdda69dc2b4
files libinterp/parse-tree/pt-cbinop.cc libinterp/parse-tree/pt-cbinop.h
diffstat 2 files changed, 49 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-cbinop.cc	Tue Feb 03 16:22:43 2015 +0100
+++ b/libinterp/parse-tree/pt-cbinop.cc	Tue Feb 03 12:27:58 2015 -0800
@@ -32,6 +32,49 @@
 #include "pt-unop.h"
 #include "pt-walk.h"
 
+octave_value_list
+tree_compound_binary_expression::rvalue (int nargout)
+{
+  octave_value_list retval;
+
+  if (nargout > 1)
+    error ("binary operator '%s': invalid number of output arguments",
+           oper () . c_str ());
+  else
+    retval = rvalue1 (nargout);
+
+  return retval;
+}
+
+octave_value
+tree_compound_binary_expression::rvalue1 (int)
+{
+  octave_value retval;
+
+  if (error_state)
+    return retval;
+
+  if (op_lhs)
+    {
+      octave_value a = op_lhs->rvalue1 ();
+
+      if (! error_state && a.is_defined () && op_rhs)
+        {
+          octave_value b = op_rhs->rvalue1 ();
+
+          if (! error_state && b.is_defined ())
+            {
+              retval = ::do_binary_op (etype, a, b);
+
+              if (error_state)
+                retval = octave_value ();
+            }
+        }
+    }
+
+  return retval;
+}
+
 // If a tree expression is a transpose or hermitian transpose, return
 // the argument and corresponding operator.
 
--- a/libinterp/parse-tree/pt-cbinop.h	Tue Feb 03 16:22:43 2015 +0100
+++ b/libinterp/parse-tree/pt-cbinop.h	Tue Feb 03 12:27:58 2015 -0800
@@ -52,6 +52,12 @@
 
   octave_value::compound_binary_op cop_type (void) const { return etype; }
 
+  bool rvalue_ok (void) const { return true; }
+
+  octave_value rvalue1 (int nargout = 1);
+
+  octave_value_list rvalue (int nargout);
+
 private:
 
   tree_expression *op_lhs;