[PATCH] where() strikes again...

Jeffrey D. Oldham oldham at codesourcery.com
Wed Dec 31 17:21:36 UTC 2003


Richard Guenther wrote:
> Hi!
> 
> The nightly tester catched a regression with the WhereProxy again.  This
> time I broke the previously working where(true, x) while fixing where(a,
> 1.0) for dimensions of a greater than one...
> 
> So this time a more elaborated fix and a single point of failure for the
> still unhandled case of where(const, const).
> 
> Tested on the existing where tests on serial ia32 linux, ok to apply?

Thanks for the quick fix.  Yes, please commit it.

> Richard.
> 
> 
> 2003Dec31  Richard Guenther <richard.guenther at uni-tuebingen.de>
> 
> 	* src/Evaluator/WhereProxy.h: introduce traits class to find
> 	dimensionality and type of the where expression.
> 
> Index: Evaluator/WhereProxy.h
> ===================================================================
> RCS file: /home/pooma/Repository/r2/src/Evaluator/WhereProxy.h,v
> retrieving revision 1.7
> diff -u -u -r1.7 WhereProxy.h
> --- Evaluator/WhereProxy.h	30 Dec 2003 16:24:05 -0000	1.7
> +++ Evaluator/WhereProxy.h	31 Dec 2003 15:59:29 -0000
> @@ -76,6 +76,29 @@
>  template<class F, class B>
>  struct WhereProxy
>  {
> +  template <class Cond, class Val, class F1, class B1>
> +  struct WhereProxyTraits {
> +    enum { dimensions = F1::dimensions };
> +    typedef typename ForEach<Val, EvalLeaf<dimensions>, OpCombine>::Type_t Element_t;
> +  };
> +  template <class Cond, class T, class F1, class B1>
> +  struct WhereProxyTraits<Cond, Scalar<T>, F1, B1> {
> +    enum { dimensions = F1::dimensions };
> +    typedef T Element_t;
> +  };
> +  template <class Val, class T, class F1, class B1>
> +  struct WhereProxyTraits<Scalar<T>, Val, F1, B1> {
> +    enum { dimensions = B1::dimensions };
> +    typedef typename ForEach<Val, EvalLeaf<dimensions>, OpCombine>::Type_t Element_t;
> +  };
> +  template <class T1, class T2, class F1, class B1>
> +  struct WhereProxyTraits<Scalar<T1>, Scalar<T2>, F1, B1> {
> +    // We open a can of worms, if we try to support this strange case.
> +    // Just use the simpler
> +    // if (cond)
> +    //   lhs = val;
> +  };
> +
>    WhereProxy(const F& f, const B& b) : f_m(f), b_m(b) { }
> 
>    typedef BinaryNode<WhereMask,
> @@ -85,8 +108,8 @@
>    typedef typename ExpressionTraits<Tree_t>::Type_t           ETrait_t;
>    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<F::dimensions>, OpCombine>::Type_t Element_t;
> +  typedef typename WhereProxyTraits<typename CreateLeaf<F>::Leaf_t,
> +	typename CreateLeaf<B>::Leaf_t, F, B>::Element_t      Element_t;
> 
>    inline WhereMask_t
>    whereMask() const


-- 
Jeffrey D. Oldham
oldham at codesourcery.com




More information about the pooma-dev mailing list