Blitz logo

Blitz Support :

From: Breeveld, Eddie \(Reigate\) (Eddie.Breeveld_at_[hidden])
Date: 2005-04-04 03:29:22


Thanks Patrick, but unfortunately I get the same error (Microsoft VS.NET
7.1)

Pass by value gives the error:

Example_1.cpp(744) : error C2784: 'T RTSumAll(const
blitz::Array<T,N_rank>)' : could not deduce template argument for 'const
blitz::Array<P_numtype,N_rank>' from
'blitz::BzBinaryExprResult<OP,O1,O2>::T_result'
        with
        [
            OP=blitz::Multiply,
            O1=blitz::Array<double,1>,
            O2=double
        ]
        RTArraySum.h(17) : see declaration of 'RTSumAll'

Pass by reference gives the error:

Example_1.cpp(744) : error C2784: 'T RTSumAll(const
blitz::Array<T,N_rank> &)' : could not deduce template argument for
'const blitz::Array<P_numtype,N_rank> &' from
'blitz::BzBinaryExprResult<OP,O1,O2>::T_result'
        with
        [
            OP=blitz::Multiply,
            O1=blitz::Array<double,1>,
            O2=double
        ]
        RTArraySum.h(17) : see declaration of 'RTSumAll'

The simplified test function I'm calling (this is the 'by value'
version):

        template<typename T, int N> inline
        T RTSumAll(const Array<T,N> A)
        {
           return sum(A);
        };

And the line calling it is:

        rate = RTSumAll(fund * 6.0);

Any other suggestions?

All the best,
Eddie
____________________
Edward Breeveld
eSolutions
Watson Wyatt LLP
Watson House, London Road,
Reigate, Surrey, RH2 9PQ, UK
Tel. +44 (0)1737 274151
Fax. +44 (0)1737 241496
www.watsonwyatt.com

-----Original Message-----
From: blitz-support-bounces_at_[hidden]
[mailto:blitz-support-bounces_at_[hidden]] On Behalf Of Patrick Guio
Sent: 01 April 2005 17:58
To: Support list for Blitz++
Subject: Re: [Blitz-support] Functions that take array expressions

On Fri, 1 Apr 2005, Breeveld, Eddie (Reigate) wrote:

> Dear Blitz++ Support,
>
> We use a lot of functions that take Blitz++ arrays, and these work
> fine provided we do not supply an array expression as an argument. For

> instance, if we have a function "Afun", and a Blitz++ array
> "arrayArg", our functions work well with
>
> result = Afun (arrayArg);
>
> Here "Afun" is defined as a templated function to take Blitz arrays of

> any rank and shape:
>
> template<typename T, int N> inline
> T Afun (const Array<T,N> &arrayArg)
> {
> // some function that returns (in this case) a scalar of type T
> ...
> };
>
> Unfortunately this does not work with expressions as arguments. How do

> I define a function that will work with both arrays directly (as
> above) and expressions such as
>
> result = Afun (arrayArg + 6);
> result = Afun (arrayArg1 * arrayArg2);
> result = Afun (arrayArg1 * Bfun(arrayArg2 * arrayArg3) + 11.56);
>
> I can set up temporary arrays to hold the intermediate results, but
> this is very awkward in our code, as some of it is automatically
> generated. I can also cast the result of the expression back into an
> array, but again this works but is awkward. I would much rather have
> one or more templated functions that can take arrays directly, as well

> as expressions involving arrays.
>

Hi Eddie,

I think you should pass the argument by value instead of by reference.

> template<typename T, int N> inline
> T Afun (const Array<T,N> arrayArg)

instead of

> template<typename T, int N> inline
> T Afun (const Array<T,N> &arrayArg)

Sincerely,

Patrick

_______________________________________________
Blitz-support mailing list
Blitz-support_at_[hidden]
http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support

_________________________________________________________________

Notice of Confidentiality

This transmission contains information that may be confidential and that may also be privileged. Unless you are the intended recipient of the message (or authorised to receive it for the intended recipient) you may not copy, forward, or otherwise use it, or disclose it or its contents to anyone else. If you have received this transmission in error please notify us immediately and delete it from your system. Please contact the sender if you have any problems with this email.

In the UK, Watson Wyatt LLP is authorised and regulated by the Financial Services Authority and is a member of the General Insurance Standards Council. The services of Watson Wyatt in Ireland are provided by Watson Wyatt LLP, a limited liability partnership incorporated under English Law, with the exception of services which are provided as a Multi-Agency Intermediary, which for regulatory purposes, are provided by Watson Wyatt Partners, which is regulated by the Irish Financial Services Regulatory Authority, on behalf of Watson Wyatt LLP.

_________________________________________________________________