freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pooma-dev] UserFunction yet...


From: Jeffrey Oldham
Subject: Re: [pooma-dev] UserFunction yet...
Date: Tue, 3 Sep 2002 13:31:49 -0700
User-agent: Mutt/1.2.5.1i

On Tue, Sep 03, 2002 at 04:45:23PM -0300, Renato Fernandes Cantão wrote:
> 
> struct BigOperation
> {
>    // here I want to be able to address each Vector<2> using
>    // the above SmallOperation
> 
>    inline Array< 2, Vector< 2 > >   // no reference here yet...
>    operator()( const Array< 2, Vector< 2 > >& in ) const
>    {
>       return UserFunction< SmallOperation >()( in );
>    }
> };
> 
> 
> In the MAIN program...
> 
>    UserFunction< BigOperation > F;
> 
>    Array< 1, Array< 2, Vector< 2 > > > V( 10 );
> 
>    for( int ii = 0; ii < 10; ii++ )
>    {
>       V( ii ).initialize( 3, 3 );
> 
>       V( ii ) = Vector< 2 >( 1.0, 2.0 );  // stupid initial value
>    }
> 
>    cout << V      << endl;
>    cout << F( V ) << endl;
> 
> 
> What I expected to happen is: F will be applied to each V element
> (Array<2,...>), calling BigOperation::operator( ... ), that calls
> SmallOperation::operator( ... ).
> 
> But, it simply does not compile, complaining it's impossible to convert
> 
> Array<2, Vector<2>, UserFunctionEngine<...> >
> 
> to
> 
> Array<2, Vector<2>, Brick>
> 
> Strangely, if I change BigOperation::operator( ... ) to
> 
>    inline Array< 2, Vector< 2 > >
>    operator()( const Array< 2, Vector< 2 > >& in ) const
>    {
>       Array< 2, Vector< 2 > > out( in.domain() );
> 
>       out = F( in );
> 
>       return out;
>    }
> 
> everything works fine, BUT, I still have to make a copy...
> 
> The question is:
> 
> 1. Some constructor is missing?
> 2. There is some obscure traits class that fix it all?
> 3. It's really impossible inside Pooma's expression engine?

Because of default template parameters, the return type of
BigOperation::operator() is listed as

    Array< 2, Vector< 2 > >

which is equivalent to

    Array< 2, Vector< 2 >, Brick>.

A UserFunction returns a UserFunction engine, not a Brick engine, so
the compiler complains.  One solution is to make
BigOperation::operator()'s engine type explicit: Copy the engine type
from the error message:

    Array< 2, Vector< 2 >, UserFunction< ... > >

Perhaps others know better solutions?

Thanks,
Jeffrey D. Oldham
address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]