This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Octave and Guile?


"John W. Eaton" <jwe@bevo.che.wisc.edu> writes:

> Is anyone here interested in such a project?

I'm very interested.  I think it's an excellent idea.  And the Guile
object system, GOOPS, with its multimethod dispatch mechanism seems
very suitable for representing Octave operators.

(BTW, with GOOPS, it is possible to let the ordinary numerical
operators + - * / work on vectors and matrices too without loosing any
performance in operations on numbers.)

Anders Sandberg and I have written a matrix library for Guile + GOOPS
which provides Matlab-like functionality:

  http://www.nada.kth.se/~mdj/guile/matrix-1.0.1.tar.gz

This is very experimental and was only meant as a prototype.  Since I
use it in my daily computations, I've incrementally added kludges
which I've needed.

I think I have learnt from this and have some ideas about what should
be improved when making a new matrix library.

Examples:

guile> (use-modules (math matrix))                  
guile> (define a #M((1 2) (3 4)))                   
guile> a
#M((1.0 2.0)
   (3.0 4.0))
guile> (* a a)
#M(( 7.0 10.0)
   (15.0 22.0))
guile> (+ a (ident 2))
#M((2.0 2.0)
   (3.0 5.0))
guile> (define r (.. 1 4))
guile> r
#R(1 2 .. 4)
guile> (* 5 r)
#R(5 10 .. 20)
guile> (define m (* r (transpose r)))
guile> m
#M((1.0  2.0  3.0  4.0)
   (2.0  4.0  6.0  8.0)
   (3.0  6.0  9.0 12.0)
   (4.0  8.0 12.0 16.0))
guile> (a 1 1)
4.0
guile> (set! (a 1 1) 5)
guile> (a 1 1)
5.0
guile> (m 1 (.. 1 2))
#M((4.0 6.0))
guile> (m 2 (..))
#M((3.0  6.0  9.0 12.0))
guile> (set! (m (.. 0 1) (.. 0 1)) a)
guile> m
#M((1.0  2.0  3.0  4.0)
   (3.0  5.0  6.0  8.0)
   (3.0  6.0  9.0 12.0)
   (4.0  8.0 12.0 16.0))

If you have gnuplot, you can do:

guile> (define x (.. 0 6.28 0.1))
guile> (plot x (sin x))
guile> (hold)
Plot held
guile> (plot x (cos x))

But, probably, a real plotting interface should use GTk.

As I said, this is all very experimental, but maybe it can give some
ideas of what you could do using Guile.

Currently, vectors are matrices.  One of the first things I'd like to
do is to represent vectors as a separate type.

Best regards,
/mdj
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]