diff liboctave/fCNDArray.cc @ 9546:1beb23d2b892

optimize op= in common cases
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 19 Aug 2009 13:47:59 +0200
parents 0ce82753dd72
children 3d6a9aea2aea
line wrap: on
line diff
--- a/liboctave/fCNDArray.cc	Mon Aug 17 14:46:18 2009 +0200
+++ b/liboctave/fCNDArray.cc	Wed Aug 19 13:47:59 2009 +0200
@@ -36,6 +36,7 @@
 #include "functor.h"
 #include "lo-ieee.h"
 #include "lo-mappers.h"
+#include "MArray-defs.h"
 #include "mx-base.h"
 #include "mx-op-defs.h"
 #include "oct-fftw.h"
@@ -1078,6 +1079,22 @@
 NDND_CMP_OPS(FloatComplexNDArray, std::real, FloatComplexNDArray, std::real)
 NDND_BOOL_OPS(FloatComplexNDArray, FloatComplexNDArray, static_cast<float> (0.0))
 
+FloatComplexNDArray& operator *= (FloatComplexNDArray& a, float s)
+{
+  if (a.is_shared ())
+    return a = a * s;
+  DO_VS_OP2 (FloatComplex, a, *=, s)
+  return a;
+}
+
+FloatComplexNDArray& operator /= (FloatComplexNDArray& a, float s)
+{
+  if (a.is_shared ())
+    return a = a / s;
+  DO_VS_OP2 (FloatComplex, a, /=, s)
+  return a;
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***