• C

Help Debugging- Really StucK!!

Somewhere in this chunk of code sits 11 errors. I've been sitting here for about 3 hours now trying to find them and not having any luck. Can someone please help me?
DelR =
           __fdividef( 1.0 , sqrt (2.0 * pie)) *__fdividef( exp(__fdividef(__fdividef(-(r - rp)^2 , 2.0) , wr^2)) , wr);
          DelR1 =__fdividef( -(r - rp) , wr^2) * DelR;
          DelR2 =
            (__fdividef(__fdividef(-1.0, wr^2) + (r - rp)^2 , wr^4)) * DelR;
 
 
              stheta =__sinf(th);
              ctheta =__cosf(th);
 
              DelTH =
                __fdividef(1.0 , sqrt (2.0 * pie)) *__fdividef( exp(__fdividef(-(th - tp)^2,2.0) wt^2) , wt);
              DelTH1 = __fdividef(__fdividef(-(th - tp) , wt) , wt) * DelTH;
              DelTH2 =__fdividef(-1.0 , wt^2) +
                 __fdividef((th - tp)^2 , wt^4) * DelTH;

Open in new window

jmckennonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

khyer123Commented:
How about some help on what the errors are, and what lines?
0
jmckennonAuthor Commented:
Everything worked perfectly until substituted all the division with __fdividef() in an effort to speed up the running of my program. I'm using CUDA in linux so debugging is pretty tough. The original equations were written as:

    DelTH = 1.0/sqrt(2.0*pie)*exp(-(th-tp)^2/2.0/wt^2)/wt
      DelTH1 = -(th-tp)/wt^2*DelTH
      DelTH2 = (-1.0/wt^2+(th-tp)^2/wt^4)*DelTH

      DelR = 1.0/sqrt(2.0*pie)*exp(-(r-rp)^2/2.0/wr^2)/wr
      DelR1 = -(r-rp)/wr^2*DelR
      DelR2 = (-1.0/wr^2+(r-rp)^2/wr^4)*DelR




0
jmckennonAuthor Commented:
khyer123, i'm using the nvcc compiler in Linux, so it doesn't explicitly tell me which lines the errors are on, only that there are some in the file. The only changes that were made were with the __fdividef() function
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

khyer123Commented:
I'm not familiar with that at all, so I'm afraid I can't help - sorry
0
jmckennonAuthor Commented:
It has nothing to do with the errors though. The program is written in C. The __fdividef() function takes in two arguments, the divisor and dividend. It's a pretty simple set up, I just can't figure out where the errors are =(!!
0
Infinity08Commented:
>> i'm using the nvcc compiler in Linux, so it doesn't explicitly tell me which lines the errors are on, only that there are some in the file.

That's not very helpful. Can you copy paste the exact output the compiler gives ?

Can you tell us how __fdividef is defined ?

I see that you are using the ^ operator in there. Are you aware that that is the binary XOR operator, and does not take the power of two numbers ?

What was the original code that worked ?
0
jmckennonAuthor Commented:
I wasnt aware of the ^ being the XOR operator. That cleared up alot of the errors, but there's still two more left.

__fdividef(x,y) is simply a faster division function for any x/y type equation. It's arguments are passed in as (x,y).

The errors are probably something like an extra parenthesis some where but I can't seem to find it.

Below is the code as I have it now, with only two errors left.
 DelR =__fdividef( 1.0,(sqrt(2.0*pie)))*__fdividef(exp(__fdividef(__fdividef(-((r-rp)*(r-rp)),2.0),(wr*wr))),wr);
 
          DelR1 =__fdividef( -(r - rp) ,( wr*wr)) * DelR;
          DelR2 =
            __fdividef(-1.0,( wr*wr)) + __fdivdef(((r - rp)(r-rp)) ,( wr*wr*wr*wr)) * DelR;
 
 
              stheta =__sinf(th);
              ctheta =__cosf(th);
 
              DelTH =
                __fdividef(1.0 , sqrt (2.0 * pie)) *__fdividef( exp(__fdividef(__fdividef(-((th - tp)*(th-tp)),2.0),( wt*wt))) , wt);
              DelTH1 = __fdividef(-(th - tp) ,(wt* wt)) * DelTH;
              DelTH2 =__fdividef(-1.0 ,( wt*wt)) +
                 __fdividef(((th - tp)*(th-tp)) ,( wt*wt*wt*wr)) * DelTH;

Open in new window

0
jmckennonAuthor Commented:
Okay, I've narrowed it down to one line, with both errors ( I commented out the line and the program did a successful build)

 /*DelR2 =
            __fdividef(-1.0,( wr*wr)) + __fdivdef(((r - rp)(r-rp)) ,( wr*wr*wr*wr)) * DelR;*/
They're some where in here, but I just don't see them! =(
0
Infinity08Commented:
>> but there's still two more left.

Well, what does the compiler say ? Literally.


>> Can you tell us how __fdividef is defined ?

When I asked that, I meant to show me the code, or at least the declaration of __fdividef


>> What was the original code that worked ?

How about that ?


A few more things I spotted :

(a) You have this in there line 5 :

        (r - rp)(r-rp)

    Did you forget the * operator ?

(b) At that same line, you are using __fdivdef instead of __fdividef



This would be a whole lot easier (and faster) if you would just post the exact compiler output, and the other data I asked for.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmckennonAuthor Commented:
I don't think you need it, you spotted the errors in the line without it!!

your (a) and (b) turned out to be them! Thanks!!
0
Infinity08Commented:
>> I don't think you need it, you spotted the errors in the line without it!!

Heh :) Well that's good then ...

But what I meant is that I would have been able to spot the problems faster if the information I asked for was available ... ;) Maybe just seeing that information together would have made the problems obvious to you without help ...

Anyway, I'm glad your problem is solved !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.