From: "hans friedrich steffani" <GM08@DKAUNI2.BITNET>
Subject: more details: problem with sin on MSC7.0
Organization: University of Karlsruhe, Germany
Date: Thu, 15 Oct 1992 09:42:12 GMT



> Im Artikel <1992Oct14.084222.14873@rz.uni-karlsruhe.de> schreibt hans friedric
h
> steffani (GM08@DKAUNI2.BITNET):
> > i have this funktion to build a sin-tabular. normallay
> > it should be a part of an other module with some other
> > funktions but this doesnt work. tsin will get silly
> > values. when i extract the init_entkop() and putting
> > it as a several module (changing tsin from static to
> > extern wich isnt fine too) it work but is ugly.
>
> Es ist ein bisschen schwer,             It is a bit difficult to
> Ihre Frage zu antworten, aus            answer your question, for two
> zwei Grunde: erstens, Sie               reasons: firstly, you haven't
> haben uns seine #include files          shown us your #include files,
> nicht gegeben; unt zwieitens,           and secondly, your code is in
I think math.h and stdio.h (wich isnt necessary here) are
well known portab.h contains some things like #define WORD int.
and c_entk.h contains
#define L_4_SIN_TAB 400
#define L_SIN_TAB (L_4_SIN_TAB)

> sein Code ist auf Deutsch!              German!  (Is there a de.lang.c
> (Gibt es ein Newsgroup                  newsgroup, in which C can be
> de.lang.c, in das C auf                 discussed in German?)
> Deutsch diskussiert kann?)
there is but i prefer the english group.
>
> > extern FLT tsin[L_SIN_TAB+L_4_SIN_TAB+1]; /* SINUS-TABELLE zum schnellen Zug
ri
> ff */
>
> Wenn man <<extern>> benutzt,            When you declare something
> muss es meistens irgendwo ein           "extern," there must usually
> Definition geben.  Weil das             be a proper definition
> tsin[] Array hier                       somewhere else.  Since the
> initialisiert ist, soll es              tsin[] array is initialized in
> wahrscheinlich auch hier                this file, you might as well
> definisiert [?] sind.                   define it here, too.  You
> Man soll hier wahrscheinlich            probably shouldn't use
> kein <<extern>> benutzen; ob            "extern" here; if the lookup
> das tsin-lookup-routine auch            routine for the tsin[] array
> hier ist, darf man das                  is also in the same file, you
> <<static> storage-class                 may want to declare it "static."
> benutzen.
Thats one of the changes I made. In the original module
the funktion init_entkop() was in the same module as
the funktions that need the tsin array. So I declared it
as static.
This did not work so I left the static. Did not work too.
So I put init_entkop() in a several file/module where I
defined tsin as extern as it was already defined in the
original module with the other functions in.
>
> >     WORD i;                     /* Laufvariable        */
> >     DBL        argument;        /* Argument    */
>
> Man braucht gewohnlich nicht            You don't usually need these
> solche ein-wort Kommente; sie           little one-word comments; they
> sagen nichts Neues.  (Ich muss          don't say anything new.
> aber sagen, dass ich habe hier          (I must admit, though, that I
> ein paar neue Worte gelernt! :-) )      learned a few new German
>                                         words! :-) )
Sorry, this comment are a idiosyncrasy (sounds good, found
in my dictionary) of my chief and it is too much work to
delete them. So dont worry about.
>
> Ich muss auch fragen, warum             I should also ask why you've
> Sie diese WORD und DBL und FLT          used these WORD and DBL and
> typedefs benutzen haben.  Sind          FLT typedefs.  Are they
> sie auf "PORTAB.H" #definisiert?        #defined in "PORTAB.H"?
Yes they are.
> Wie macht es Sein Code mehr             How does their use make the
> portable, diese typedefs zu             code more portable?
> benutzen?
I don not no. This is part of a older project where many
students especiallay mechanical engeneers workes with.
I never thought about but i had some problems to include
foreign functions which don t use portab.h .
But thats a different problem.
>
> >     for (i = 0; i < L_SIN_TAB + L_4_SIN_TAB; i++)
> >     { /* Berechnung sin Tabelle */
> >
> >       argument = (FLT)2.0 * (FLT)PI / (FLT)L_SIN_TAB
> >                * (FLT)i;
> >
> >        tsin[i]         =  (FLT) sin( argument );
> >     } /* Berechnung sin Tabelle */
>
> Ich glaube, dass <<i>> auf              I suspect that "i" is in
> Degrees ist.  (Wenn Sie es ein          degrees.  (A better name, or a
> bessere Name gibt, oder ein             more descriptive comment,
> besseres Komment, ist es                would have made this easier to
> leichter zu verstehen.)                 understand.)
No it is not degrees. But argument is in degree.
>
> Dieses Loop werde tas tsin[]            This loop will initialize the
> Array gut initialisieren, aber          tsin[] array correctly,
> ich verstehe nicht, warum es            although I don't understand
> L_4_SIN_TAB mehr Punkte hat.            why it has L_4_SIN_TAB extra
>                                         elements.
I need the cosine. I do cos_value = tsin(index+L_4_SIN_TAB)
                                        ^sqare bracket    ^
with index = ( phi / ( 2 PI ) ) * L_SIN_TAB.
>
> > perhaps there a some square-brackets lost; tsin
> > is a array of L_SIN_TAB elements.
>
> Nein, es hat die wichtige []'s.         No, the []'s are correctly
> Das Problem ist wahrscheinlich          placed.  The problem is
> das storage-class.  (Es                 probably with the storage
> braucht aber noch ein '}'.              class. (The code as posted
Sorry I missed the last line.
>                 Stefan Gipfel                           Steve Summit
>                 scs@adam.mit.edu                        scs@adam.mit.edu

Steve many thanks for your work especially for your
German translation.
To make things clear: after ending the loop but inside the
function I always get wrong tsins when this funktion is in
a module together with the other funktions. If I put it in
a special module everything is ok

hans friedrich steffani
gm08@dkauni2.bitnet
steffani@imbaibrs1.bau-verm.uni-karlsruhe.de