?
Solved

Help Debugging- Really StucK!!

Posted on 2009-07-11
11
Medium Priority
?
267 Views
Last Modified: 2012-05-07
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

0
Comment
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
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 
LVL 4

Expert Comment

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

Author Comment

by:jmckennon
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

by:jmckennon
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

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

Author Comment

by:jmckennon
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

by:Infinity08
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

by:jmckennon
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;

Open in new window

0
 

Author Comment

by:jmckennon
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

by:
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 ?

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
 

Author Comment

by:jmckennon
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

by:Infinity08
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 ...

Anyway, I'm glad your problem is solved !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
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.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question