Re: multiplication yield strange results



Gilles Rosselet wrote:

I call the following bit of code repeatedly during the execution of my program:

Bx:= self.n[0].A*self.alpha[0].c + self.n[1].A*self.alpha[1].c + self.n[2].A*self.alpha[2].c;
By:= -self.n[0].A*self.alpha[0].b - self.n[1].A*self.alpha[1].b - self.n[2].A*self.alpha[2].b;
Bsqr:= Bx*Bx + By*By;

At first all goes well but suddenly Bx and By get extremly large (around 1E205) which turn Bsqr to INF.

Well I am completely lost any help apreciated.

I suspect that you have uninitialized values somewhere, maybe pointers, local variables, function results, or incompletely initialized arrays.

Perhaps it helps to initialize all array members in the above formulas to NaN, prior to filling in the actual values (i.e. after allocation of dynamic memory...). Then you'll get an exception whenever an element was not properly initialized. An according check should be placed after every function/method call, which should fill in all or an specific part of the data structure. I also would check for compiler warnings "possibly undefined...".

DoDi
.



Relevant Pages

  • Re: IVF 10: IO speed slower with full optimizations than with a debug build
    ... slowdown (I suspect due to having to initialize line(l+1:1836) ... you are right regarding my suggested change. ...
    (comp.lang.fortran)
  • Re: What is happening here
    ... Spoiler Warning! ... > use strict; ... I suspect you meant to initialize more than just the first one here: ... I also suspect this will silence the error. ...
    (perl.beginners)
  • Merge replication Option
    ... I am looking for a way to avoid the option of 'Yes initialize the Schema and ... the data' (which I suspect is the source of some problems) when I create a ...
    (microsoft.public.sqlserver.replication)