[omniORB] Complex numbers

Marc Eberhard m.a.eberhard at aston.ac.uk
Fri Oct 10 13:19:59 BST 2003


On Thu, Oct 09, 2003 at 08:55:04AM -0500, scott.rediger at teradyne.com wrote:
> When I say xlate() function, I mean a simple field-by-field translation:
> 
>       void xlate_complex( complex& out, const IDLMODULE::Complex& in );
> 
> This function simply copies (field-by-field) values from the in parameter
> to the out parameter.

What about helper classes instead?

     class myComplex;  
     
     class mycmplx : public cmplx
     {
     
             public:
     
                     mycmplx(const Complex& c) : cmplx(c.re, c.im) {};
       
     };
     
     class myComplex : public Complex
     {
     
             public:
     
                     myComplex(const cmplx& c) {this->re = c.real(); this->im = c.imag(); };  
     
     };
  
As far as I can see, this does the trick quite nicely. Looks like I need to
add a few more constructors and operators, but apart from that it seems to
work.

The cast 

        const cmplx c = sqrt(G);
        s->multiply(CAST_TO_COMPLEX(c));

is then replaced with

        const mycmplx x = sqrt(G);
        s->multiply(myComplex(x));

a constructor invocation. I tend to say, this should be equivalent to your
xlate_function. True?

Thanks,
Marc
_______________________________________________________________________________

email: marc at greenie.net, marc.eberhard at alumni.tum.de, marc at affs.org.uk
email: m.a.eberhard at aston.ac.uk, web: http://www.aston.ac.uk/~eberhama/



More information about the omniORB-list mailing list