[racket] math/matrix

From: Eduardo Costa (edu500ac at gmail.com)
Date: Sun May 11 00:09:49 EDT 2014

The documentation says that one should expect typed/racket to be faster
than racket. I tested the math/matrix library and it seems to be almost as
slow in typed/racket as in racket. Here is the program in typed racket:

#lang typed/racket ; file: matrix.rkt
(require math/matrix)

(: mx Index)
(define mx 600)

(: r (Index Index -> Flonum))
(define (r i j) (random))

(: A : (Matrix Flonum))
(define A (build-matrix mx mx r))

(: sum : Integer Integer -> Flonum)
(define (sum i n)
  (let loop ((j 0) (acc 0.0))
    (if (>= j mx) acc
        (loop (+ j 1) (+ acc (matrix-ref A i j))) )))

(: b : (Matrix Flonum))
(define b (build-matrix mx 1 sum))

(let [(m (matrix-solve A b))]
  (displayln (matrix-ref m 0 0)))

You can run it thus:

time racket matrix.rkt

What should I do to speedup the above code?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140511/30eb9634/attachment.html>

Posted on the users mailing list.