Blitz logo

Blitz Support :

From: Julian C. Cummings (cummings_at_[hidden])
Date: 2004-05-03 13:22:57


Hello Matthias,

The user-defined function support was extended recently using code and
suggestions from Derrick Bass (derrick_at_[hidden]). Have a look at the
comments at the top of the header file <blitz/array/functorExpr.h>. What
you're looking for here is probably the macro BZ_DECLARE_MEMBER_FUNCTION2.

Regards, Julian C.

Dr. Julian C. Cummings
Staff Scientist, CACR/Caltech
(626) 395-2543
cummings_at_[hidden]
 

> -----Original Message-----
> From: blitz-support-bounces_at_[hidden]
> [mailto:blitz-support-bounces_at_[hidden]] On Behalf Of
> Mathias Wagner
> Sent: Monday, May 03, 2004 1:45 AM
> To: blitz-support_at_[hidden]
> Subject: [Blitz-support] user defined functions
>
>
> Hi,
>
> I have some problems using user defined functions.
> I did some testing with a very simple cpp file.
>
>
>
> double f(double x){
> return x*x;
> }
>
> BZ_DECLARE_FUNCTION(f);
>
> int main(){
>
> blitz::Array<double,1> b(3);
> blitz::Array<double,2> A(3,3);
>
> ...
>
> A = b(tensor::i) + 10*f(b(tensor::j));
>
> ...
> }
>
> Everything worked fine.
>
> I now wanted to use a class method as user defined function.
>
> Say class Aclass has a function
> double f(double x, double y)
>
> In a other class (say B) I would like to write
>
> Aclass A(...);
> blitz::Array<double,1> x;
> blitz::Array<double,2> H;
>
> H=A.f(x(tensor::i),x(tensor::j));
>
>
> Has anyone an idea how to to this in an elegant way?
>
> I tried to introduce a helper function in class B like
>
> (in file b.h)
> private:
>
> double blitzhelp_f(double x,double y){
> return A.f(x,y);
> }
>
> but this doesn't work.
>
> Mathias
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>