dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: C++ to VB translation

Threaded View

  1. #1
    Join Date
    May 2009
    Posts
    29

    C++ to VB translation

    Good afternoon,

    I'm having some troubles (in the results) to translate the following routine in C++ to VB. It's a routine which messes with complex numbers... So here it is (and how the call is made:

    Code:
    function Solve(const double al, const complex<double> &z, 
                         const double u, complex<double> &zto, double &r)
    {
        const double ex = abs(z);
        const double ex2 = ex*ex;
        const double ex3 = ex2*ex;
    
        double e = (al + (ex - ex3/8)*sin(al) + 0.5 * ex2 * sin(2*al) 
                    + 0.375 * ex3 * sin(3*al));
    
        complex<double> z1 = conj(z);
    
        for (int k = 0; k < 10; k++)
        {
            const complex<double> z2(0, e);
            const complex<double> zteta = exp(z2);
    
            const complex<double> z3 = z1*zteta;
    
            const double dl = al - e + z3.imag();
            r = 1 - z3.real();
            if (fabs(dl) < 1e-12)
            {
                z1 = u * z * z3.imag();
                const complex<double> z2(z1.imag(), -z1.real());
                zto = (-z + zteta + z2)/r;
                return;
            }
            e += dl/r;
        }
        xpWarn("Can't converge\n", __FILE__, __LINE__);
    }
    And it's called like this:

    Code:
        complex<double> z(xk, xh);
        complex<double> zto;
        double r;
    
         Solve(xl, z, u, zto, r);
    Can someone give me an hand please?...

    Kind regards

    JKepler
    Last edited by 2kaud; October 6th, 2018 at 11:21 AM. Reason: Added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)