Announcement

Collapse
No announcement yet.

scientific conversion from FORTRAN 90

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • scientific conversion from FORTRAN 90

    PB Math-fans, Please have a look at the following formula derived from FORTRAN 90:

    v = sqrt ( ( ( u - 1.0E+00 ) * x1 - u * x2 + x3 )**2 + ( ( u - 1.0E+00 ) * y1 - u * y2 + y3 )**2 ) / unit


    I have simply a syntax question only to the expression: (u - 1.0E+00)
    How is this simple Fortran syntax to be converted to PB?

    I did it this way and hope it is correct:

    v = Sqr(((u - 1.0E+00) * dp1.x - u * dp2.x + dpOn.x)^2 + ((u - 1.0E+00) * dp1.y - u * dp2.y + dpOn.y)^2 ) / unit
    Norbert Doerre

  • #2
    Norbert,
    1.0E+00 is just a floating point value of 1. In PB it doesn't really matter how you write it as the compiler will convert it to FP as required.

    So, for (u - 1.0E+00) could just write (u-1) but leaving it as you have written it will do the same job.

    Paul.
    Last edited by Paul Dixon; 1 Feb 2008, 09:49 AM.

    Comment


    • #3
      What you can also do is directly use a type-specifier character:
      ! for single precision,
      # for double precision,
      ## for extended precision.

      That way, you can make your literal number match the data type of the variables you use it with.
      This avoids another data type conversion 'under the hood'.
      if u in (u - 1.0E+00) is a double precision variable, you could use:
      (u - 1#)
      if u is an extended precision variable, you can use:
      (u - 1##)


      Kind regards
      Eddy

      Comment


      • #4
        Accuracy is fine!

        Paul and Eddy,

        thank You for Your kind answer.
        Then I did it right, at least with my programming syntax.
        But I don't usually trust debugger values when I have to deals with very small tolerances, for instance when I have to find out a number very near to another one. (10E-12 or even smaller). I do not exactly know what PB might give back. Sometimes the relation of numbers is just like with the construction of the facette of the eye of a fly in unit [mm] on the moon drawn 1:1.
        As far as I could find out in the mean time, accuracy is in fact at least 10E-14. That's quite enough in this case.
        Norbert Doerre

        Comment


        • #5
          Hallo Norbert,
          kann mich dunkel erinnern, dass ich FORTRAN 1979 im Studium mal hatte. Wusste gar nicht, dass das immer noch im Einsatz ist. Wo verwendet man das eigentlich noch?

          liebe GrüßeKarl-Heinz
          greets KHV

          Comment

          Working...
          X