Announcement

Collapse
No announcement yet.

complex numbers in PBWin ?

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

  • #21
    Originally posted by José Roca View Post
    sin_ and cos_ can be replaced with PB's SIN and COS, and sinh_ and cosh_ with:

    The Hyperbolic Sine (SINH) of a value can also be calculated:

    SinH = (EXP(Value) - EXP(-Value)) / 2

    The Hyperbolic Cosine (COSH) of a value can also be calculated:

    CosH = (EXP(Value) + EXP(-Value)) / 2

    Although the PB functions are slower than the C ones.
    I've not yet used the Cos and Sin in the code José , but I ask myself ,if I need them ,the code won't be confused if I code for y = Cos (..) which is a regular PB function and is also a method ?

    Comment


    • #22
      No, because to call the Cos method from outside the class you need to use something like pcn.Cos, and to call it from inside the class you have to use ME.Cos.
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


      • #23
        Originally posted by José Roca View Post
        No, because to call the Cos method from outside the class you need to use something like pcn.Cos, and to call it from inside the class you have to use ME.Cos.
        Of course José , I see. Thx

        Comment


        • #24
          My apologies if this has been addressed elsewhere but I've just read through dozens of threads and could not find an answer. I'm looking for ideas on how to accelerate multiplication of two very large one-dimensional complex number arrays. I'm also summing the real and imaginary results and then finding the average. The arrays have identical length and may hold millions of elements. Below is simplified code to illustrate:

          Code:
          TYPE Complex
            r AS SINGLE
            i AS SINGLE
          END TYPE
          
          SUB CMultiply (BYVAL n, C1() AS Complex, C2() AS Complex, BYREF CAvg as Complex)
          REGISTER x AS LONG, SumR AS EXT, SumI AS EXT
            SumR = 0
            SumI = 0
            FOR x = 1 TO n
              SumR = SumR + C1(x).r * C2(x).r - C1(x).i * C2(x).i
              SumI = SumI + C1(x).r * C2(x).i + C1(x).i * C2(x).r
            NEXT x
            CAvg.r = SumR / n
            CAvg.i = SumI / n
          END SUB
          Perhaps an ASM implementation would be much faster but I haven't touched Assembly in about 40 years and the above code is at least very readable. Any suggestions that might make a significant dent in processing time would be appreciated!

          Comment

          Working...
          X