![]() |
Blitz Support : |
From: Navneet Dalal (Navneet.Dalal_at_[hidden])
Date: 2003-12-11 04:54:17
On Wed, 10 Dec 2003 11:41:46 -0800, Julian Cummings
<cummings_at_[hidden]> wrote:
> Hello Navneet,
>
> Navneet Dalal wrote:
>
>>
>> Coming to your problerm (if I understood it right) you want to define,
>> let us say, two functions:
>>
>> double gauss(double val, double mean, double var);
>> float gauss(float val, float mean, float var);
>>
>> And then you would like to evaluate gauss on a Array<double,1> or on a
>> Array<float,1>.
>> For this, you just use BZ_DECLARE_FUNCTION3 as:
>>
>> BZ_DECLARE_FUNCTION3(gauss);
>>
>> int main() {
>> Array<double,1> a(10);
>> Array<float ,1> b(10);
>>
>> // initialize arrays
>> Array<double,1> resA(10);
>> resA = gauss(a, 0, 10); // 0 mean and 10 var
>>
>> Array<float ,1> resB(10);
>> resB = gauss(b, 2, 5); // 2 mean and 5 var
>> }
>
> Just an aside: this example is not a proper trinary function. A trinary
> function would act on three arrays of data. What you have here is a
> function that acts on a single array of data and requires two additional
> scalar input parameters. Such a function would best be captured in
> blitz by implementing it as a functor object that is initialized with
> values for the two scalar parameters. The functor would store these
> parameters as member data and operate on an array by providing an
> operator() method. See <blitz/array/functorExpr.h> for details.
>
> -- Julian C.
One question here: the way trinary functions are defined in blitz, blitz
creates a constant Array Expression for above examples.
I agree that it is an unnecessary overhead for compiler, but does it has
performance penalty also?
- navneet