## [REBOL] Re: GPS: minimizing sum of squares algorithm

### From: jan:skibinski:sympatico:ca at: 10-Nov-2002 15:14

Jose and all,> Many thanks for your help. Can you pls send me your > functions so that I can test your gps functions > > I find that there are very few math related scripts > available in rebol, so your scripts are most valuable! >Jose, I just sent you the script you requested. Here are just few general comments about linear algebra scripts. I am sure several people here developed their own Linear Algebra packages in Rebol. Tom Conlin for one. I bet Joel Neely has one too. I have developed several Haskell modules that deal with some aspects of Linear Algebra, and go way beyond the basic stuff, such as LU decomposition and a solver of systems of linear equations. I needed support for nonsymmetric complex matrices, eigenvalues, eigenvectors, and all that stuff. I have also developed a Quantum Vector module which supports the <bra| |ket> Dirac's notation, and several application modules from Quantum Mechanics, one of which is a prototype of "Haskell Simulator of Quantum Computer". I did no plan however to port this stuff to Rebol, knowing well that this is not in a general interest of Rebolites. But your GPS problem forced me to port some of the stuff to Rebol. Here are few of my observations about my yesterday's porting process: ------------------------------------------------------ The process was rather easy, because of the clarity of the Haskell syntax. I did not spend much time on optimization and I used the same concepts in Rebol as in Haskell. So, with few exceptions, the recursive stuff in Haskell, remains recursive in Rebol. The original functions were by defnition "indexless" - they came from my web article "Indexless Linear Algebra Algorithms." The resulting translation is almost indexless too. The list comprehension notation , such as: p = [bra_ket u ak | ak <- a] were easy to translate to p: copy [] foreach ak a [insert tail result (bra-ket u :ak)] However, since Haskell is lazy the expressions are not evaluated until they are needed. So if during recursion, some items such as 'u cannot be evaluated because say u: first a but 'a is already empty, nothing wrong happens in Haskell because of its laziness. Not so in Rebol. The solution is to use functions, even if they represent constants. So the above 'p would be wrapped inside a function instead. p: func [ /local result ][ result: copy [] foreach ak a [insert tail result (bra-ket u :ak)] result ] Haskell has several standard words that are identical as in rebol but with completely different semantics: 'head means 'first, 'tail means 'next, etc. But one can easily get used to such things. Few things have bitten me though. I am still not used to certain "in-place" behaviour of certain functions, such as 'replace, or worst of all 'reverse, which returns empty block. This bites badly in pipelines of expressions. Regards, Jan