Announcement

Collapse
No announcement yet.

Solver, Inverting, FFT ect...

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

  • Solver, Inverting, FFT ect...

    Has anybody seen PowerBasic-algoritms for:

    1) solving non-linear systems
    2) solving (large) linear systems
    3) FFT

    Regards
    Peter

  • #2
    Peter,
    Go to http://www.ulib.org/webRoot/Books/Numerical_Recipes/

    There You'll find Fortran or C++ code. It's easy to translate to Basic. They used to have Neumerical Recipes for Basic, but I'm not sure if it still in stock.
    Anyway, Numerical REcipes is a need to have book if You do a lot of math programming.

    Best regards

    Eigil

    Comment


    • #3
      Here's FFT source code:

      Code:
      DECLARE FUNCTION bitRev&(j&,nu&)
      
      FUNCTION bitRev&(j&,nu&)
          j1&=j&
          k&=0
          FOR i&=1 TO nu&
              j2&=j1&\2
              k&=k&*2+j1&-2*j2&
              j1&=j2&
          NEXT i&
          FUNCTION=k&
      END FUNCTION
      
      SUB newFFT(ftr AS DOUBLE PTR, fti AS DOUBLE PTR, jmax&,nu&)
          n2&=jmax&\2
          nu1&=nu&-1
          k&=0
          dw#=2*pi#/jmax&
          FOR l&=1 TO nu&
              pt&=1
              SHIFT LEFT pt&,nu1&
              DO WHILE k&<jmax&
                  FOR i&=1 TO n2&
                      p#=bitRev(k&\pt&,nu&)
                      arg#=p#*dw#
                      c#=COS(arg#)
                      s#=SIN(arg#)
                      trl#[email protected][k&+n2&]*c#[email protected][k&+n2&]*s#
                      tim#[email protected][k&+n2&]*c#[email protected][k&+n2&]*s#
                      @ftr[k&+n2&][email protected][k&]-trl#
                      @fti[k&+n2&][email protected][k&]-tim#
                      @ftr[k&][email protected][k&]+trl#
                      @fti[k&][email protected][k&]+tim#
                      INCR k&
                  NEXT i&
                  k&=k&+n2&
              LOOP
              k&=0
              nu1&=nu1&-1
              n2&=n2&\2
          NEXT l&
          k&=0
          DO WHILE k&<jmax&
              i&=bitRev&(k&,nu&)
              IF i&>k& THEN
                  trl#[email protected][k&]
                  tim#[email protected][k&]
                  @ftr[k&][email protected][i&]
                  @fti[k&][email protected][i&]
                  @ftr[i&]=trl#
                  @fti[i&]=tim#
              END IF
              INCR k&
          LOOP
      END SUB
      The code executes in realtime in PBCC10 (SB Input, double-buffered)
      Converted from Pascal (original program / source PSK31 by Peter Martinez, I think)




      -------------
      Daniel
      [email protected]

      Comment

      Working...
      X