[PATCH] Fix where breakage

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Thu Dec 25 22:13:44 UTC 2003


Hi!

With my recent where improvements I did some breakage which is obviously
fixed by the following patch.  I also extended array_test12 to contain
some >1 dim tests.

Regtested on the few where tests we have using serial ppc-linux.

Ok to apply?

Thanks,

Richard.


2003Dec25  Richard Guenther <richard.guenther at uni-tuebingen.de>

	* Array/tests/array_test12.cpp: check systematically for
	d-dimensional array/scalar rhs in where.
	Evaluator/WhereProxy.h: use EvalLeaf of the dimensionality
	of the first where argument.

Index: Array/tests/array_test12.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/src/Array/tests/array_test12.cpp,v
retrieving revision 1.14
diff -u -u -r1.14 array_test12.cpp
--- Array/tests/array_test12.cpp	21 Nov 2003 21:30:37 -0000	1.14
+++ Array/tests/array_test12.cpp	25 Dec 2003 22:07:47 -0000
@@ -39,6 +39,34 @@

 #include <math.h>

+template <int Dim>
+void check(Pooma::Tester& tester)
+{
+  tester.out() << Dim << "-dimensional tests:\n";
+  Interval<Dim> I;
+  for (int i=0; i<Dim; ++i)
+    I[i] = Interval<1>(10);
+  Array<Dim> a(I), b(I);
+  a = 1.0;
+  b = 0.0;
+  b = where(a == 1.0, a);
+  tester.check("2-arg where with array rhs", all(b == 1.0));
+  b = 0.0;
+  b = where(a == 1.0, 5.0);
+  tester.check("2-arg where with scalar rhs", all(b == 5.0));
+  b = 0.0;
+  b = where(a == 1.0, a, a);
+  tester.check("3-arg where with array/array rhs", all(b == 1.0));
+  b = 0.0;
+  b = where(a == 1.0, a, 3.0);
+  tester.check("3-arg where with array/scalar rhs", all(b == 1.0));
+  b = 0.0;
+  b = where(a == 1.0, 3.0, a);
+  tester.check("3-arg where with scalar/array rhs", all(b == 3.0));
+  b = 0.0;
+  b = where(a == 1.0, 1.0, 3.0);
+  tester.check("3-arg where with scalar/scalar rhs", all(b == 1.0));
+}

 int main(int argc, char* argv[])
 {
@@ -114,6 +142,12 @@

   tester.check("where reduction", prod(where(d == 0.0, d)) == 0.0);

+  // generic 2/3-arg where with array/scalar rhs
+
+  check<1>(tester);
+  check<2>(tester);
+  check<3>(tester);
+
   int ret = tester.results("array_test12");
   Pooma::finalize();
   return ret;
Index: Evaluator/WhereProxy.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Evaluator/WhereProxy.h,v
retrieving revision 1.6
diff -u -u -r1.6 WhereProxy.h
--- Evaluator/WhereProxy.h	21 Nov 2003 21:30:38 -0000	1.6
+++ Evaluator/WhereProxy.h	25 Dec 2003 22:07:47 -0000
@@ -86,7 +86,7 @@
   typedef typename ConvertWhereProxy<ETrait_t,Tree_t>::Make_t MakeFromTree_t;
   typedef typename MakeFromTree_t::Expression_t               WhereMask_t;
   typedef typename ForEach<typename CreateLeaf<B>::Leaf_t,
-			   EvalLeaf<1>, OpCombine>::Type_t    Element_t;
+			   EvalLeaf<F::dimensions>, OpCombine>::Type_t Element_t;

   inline WhereMask_t
   whereMask() const



More information about the pooma-dev mailing list