Loading ...
Sorry, an error occurred while loading the content.
 

Re: [libertybasic] Complex Math; Complex Calculator

Expand Messages
  • W. D. Allen
    Hello Sam, I am studying Kalman filters and would like to code a multidimensional version in Liberty Basic. Does your complex math include matrix functions? If
    Message 1 of 3 , Jan 31, 2009
      Hello Sam,

      I am studying Kalman filters and would like to code a multidimensional
      version in Liberty Basic. Does your complex math include matrix
      functions? If not, do you know of anyone else who might have matrix
      functions written in Liberty Basic?

      My alternative is to learn a new programming language like Python or
      Scilab, which would set me back significantly in time.

      Thanks for your consideration.

      Bill Allen
      ballensr@...

      end



      Sam Wetterlin wrote:
      >
      > I have been working on routines for doing complex math. This is how I
      > discovered that you can't represent them as a struct (because
      > assigning an integral value to a struct causes a crash) or as a
      > 2-element array (because you can't pass arrays as arguments). So I
      > ended up creating a permanent "stack" consisting of two arrays, one to
      > hold the real part and one the imaginary part. You push operands onto
      > the stack, call operations, and pop the answer off the stack. It
      > functions exactly as an RPN calculator does. It works nicely, and the
      > code utilizing it is fairly simple to follow. It covers the range from
      > basic arithmetic to hyperbolic trig functions.
      >
      > I have posted the code in a folder called Complex Math, for anyone who
      > may want to use it. To test it, I created a complex math calculator,
      > so I could run calculations and compare them to HP's AppCad
      > Engineering Calculator. I have posted an executable form of my
      > calculator in the same folder. It includes documentation on how to use it.
      >
      > Fortunately, when I created the calculator application, I did not end
      > up with the mysterious error message about "resetProcessDialog not
      > understood", which plagues several other applications I created.
      >
      > Sam W.
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - www.avg.com
      > Version: 8.0.233 / Virus Database: 270.10.16/1926 - Release Date: 01/30/09 07:37:00
      >
      >
    • Sam Wetterlin
      Bill, My routines do not do matrix math directly. However, matrix math boils down to repeated arithmetic operations on matrix elements, and my routines would
      Message 2 of 3 , Feb 1, 2009
        Bill,
        My routines do not do matrix math directly. However, matrix math boils
        down to repeated arithmetic operations on matrix elements, and my
        routines would do that part. For example, if you had two matrices of
        complex numbers (say, in the form dim M(100,1), where the second
        dimension index is 0 for the real part and 1 for the imaginary part),
        you could iterate through them and multiply corresponding elements.
        The iteration would be up to you, but the actual complex math could be
        done by my routines.

        But this may be the killer: you cannot pass arrays as arguments. So if
        you write a function or subroutine to perform an operation on two
        matrices, it will work only on the two specific matrices for which it
        is written. If you want to do the same thing on two other matrices,
        you have to either (1) write a new routine for them (basically a copy
        and paste job) or (2)copy their data into into the two original
        matrices, do the operation, and then retrieve the data. Depending how
        many matrices you use, this may or may not be feasible.

        I have used my routines to perform operations on data maintained in
        arrays, iterating through them and performing multi-step complex
        operations on each data point. With several arrays of 400 data points,
        the whole process took less than a second. That was fast enough for my
        purposes. Much faster than learning Python.

        Sam W.


        --- In libertybasic@yahoogroups.com, "W. D. Allen" <ballensr@...> wrote:
        >
        > Hello Sam,
        >
        > I am studying Kalman filters and would like to code a multidimensional
        > version in Liberty Basic. Does your complex math include matrix
        > functions? If not, do you know of anyone else who might have matrix
        > functions written in Liberty Basic?
        >
        > My alternative is to learn a new programming language like Python or
        > Scilab, which would set me back significantly in time.
        >
        > Thanks for your consideration.
        >
        > Bill Allen
        > ballensr@...
        >
        > end
        >
        >
        >
        > Sam Wetterlin wrote:
        > >
        > > I have been working on routines for doing complex math. This is how I
        > > discovered that you can't represent them as a struct (because
        > > assigning an integral value to a struct causes a crash) or as a
        > > 2-element array (because you can't pass arrays as arguments). So I
        > > ended up creating a permanent "stack" consisting of two arrays, one to
        > > hold the real part and one the imaginary part. You push operands onto
        > > the stack, call operations, and pop the answer off the stack. It
        > > functions exactly as an RPN calculator does. It works nicely, and the
        > > code utilizing it is fairly simple to follow. It covers the range from
        > > basic arithmetic to hyperbolic trig functions.
        > >
        > > I have posted the code in a folder called Complex Math, for anyone who
        > > may want to use it. To test it, I created a complex math calculator,
        > > so I could run calculations and compare them to HP's AppCad
        > > Engineering Calculator. I have posted an executable form of my
        > > calculator in the same folder. It includes documentation on how to
        use it.
        > >
        > > Fortunately, when I created the calculator application, I did not end
        > > up with the mysterious error message about "resetProcessDialog not
        > > understood", which plagues several other applications I created.
        > >
        > > Sam W.
        > >
        > >
        > >
        ------------------------------------------------------------------------
        > >
        > >
        > > No virus found in this incoming message.
        > > Checked by AVG - www.avg.com
        > > Version: 8.0.233 / Virus Database: 270.10.16/1926 - Release Date:
        01/30/09 07:37:00
        > >
        > >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.