Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Help Debugging- Really StucK!!

Posted on 2009-07-11
Medium Priority
270 Views
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;
``````
0
Question by:jmckennon
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 6
• 3
• 2

LVL 4

Expert Comment

ID: 24832916
How about some help on what the errors are, and what lines?
0

Author Comment

ID: 24832924
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

Author Comment

ID: 24832926
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

LVL 4

Expert Comment

ID: 24832934
I'm not familiar with that at all, so I'm afraid I can't help - sorry
0

Author Comment

ID: 24832942
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

LVL 53

Expert Comment

ID: 24832949
>> 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

Author Comment

ID: 24832988
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;
``````
0

Author Comment

ID: 24833012
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

LVL 53

Accepted Solution

Infinity08 earned 2000 total points
ID: 24833017
>> 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 ?

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

Author Comment

ID: 24833027
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

LVL 53

Expert Comment

ID: 24833033
>> 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 ...

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: Iâ€™ve never triâ€¦
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to useâ€¦
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
###### Suggested Courses
Course of the Month8 days, left to enroll