From: Dimiter "malkia" Stanev
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <go4605$11h$1@malkia.motzarella.org>
Your code on my machine LispWorks 5.1:

User time    =       49.203
System time  =        0.031
Elapsed time =       49.250
Allocation   = 160266280 bytes

After some optimizations:

Now originally I was thinking you can put declare here and there, but 
the problem is in "nth" - e.g. your algorithm.

"nth" is not efficient when you have long list, you better convert that 
list temporarily to vector, array or if you know your data simple-array 
with the type.

Just changing this bit ("nth" to "elt") and mlist a coerced vector, 
speeded up 10 times.

I think with more optimizations, and lastly declares, it can go 100 if 
not more faster.

(defmacro while (condition &rest body)
   (let ((var (gensym)))
     `(do ((,var nil (progn ,@body)))
	 ((null ,condition) ,var))))

(defvar mlist (loop repeat 4000 collect (random 1.0))) ;;I need to use 
even 10000 repeats or more

;;The function to optimize
(defun run (mlist)
   (let* ((n (1- (length mlist)))
          (mlist (coerce (delete (nth 0 mlist) mlist) 'vector))
          (mtable (make-array
                   (list (/ (* n (1- n)) 2) 3)
                   :initial-element 0))
          (ind 0)
          (ind2 0)
          (Pm 0)
          (i 0))
   (while (<= i (1- n))
          (let ((sP 0)
                (j (1+ i)))
            (while (< j n)
                   (setf sP (+ sP (elt mlist (1- j))))
                   (setf (aref mtable ind 0) i)
                   (setf (aref mtable ind 1) j)
                   (setf (aref mtable ind 2)
                         (if (< sP 1)
                           (/ 1 (* (float (- j i))
                                   (float (+ (- n j) (1+ i))) (float sP)))
                           1))
                   (when (> (aref mtable ind 2) Pm)
                     (setf Pm (aref mtable ind 2)
                           ind2 ind))
                   (incf ind)
                   (incf j))
            (incf i)))
   (setf mtable2
         (loop for i from 0 to 2
               collect (aref mtable ind2 i)))))

(time (run mlist))

From: Dimiter "malkia" Stanev
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <go46ms$afl$1@malkia.motzarella.org>
Dimiter "malkia" Stanev wrote:
> Your code on my machine LispWorks 5.1:
> 
> User time    =       49.203
> System time  =        0.031
> Elapsed time =       49.250
> Allocation   = 160266280 bytes
> 
> After some optimizations:

I forgot to post the timing after my optimizations ("nth" to "elt")

User time    =        6.265
System time  =        0.000
Elapsed time =        6.265
Allocation   = 160251548 bytes
0 Page faults
;;; Compilation finished with 1 warning, 0 errors, 0 notes.

Really it can be optimized way above that - for example you putting in 
an array two types of data - fixnums (integers) and floats.

Also you can decide what float is going to work for you - single-float 
or double-float - the general float might not be efficient (I don't know 
that for certain).

You do use lots of "global" variables, not sure what your other 
programming languages are - but you should really look into trying to 
use lexical variables (let, and let*).

Also for the last statement, you can just make the run function return 
it, instead of putting it in a global var (mtable2).

Thanks,
Dimiter "malkia" Stanev.
From: William James
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <go5tg40bms@enews2.newsguy.com>
Dimiter "malkia" Stanev wrote:

> Your code on my machine LispWorks 5.1:
> 
> User time    =       49.203
> System time  =        0.031
> Elapsed time =       49.250
> Allocation   = 160266280 bytes
> 
> After some optimizations:
> 
> Now originally I was thinking you can put declare here and there, but 
> the problem is in "nth" - e.g. your algorithm.
> 
> "nth" is not efficient when you have long list, you better convert that 
> list temporarily to vector, array or if you know your data simple-array 
> with the type.
> 
> Just changing this bit ("nth" to "elt") and mlist a coerced vector, 
> speeded up 10 times.
> 
> I think with more optimizations, and lastly declares, it can go 100 if 
> not more faster.
> 
> (defmacro while (condition &rest body)
>    (let ((var (gensym)))
>      `(do ((,var nil (progn ,@body)))
> 	 ((null ,condition) ,var))))
> 
> (defvar mlist (loop repeat 4000 collect (random 1.0))) ;;I need to use 
> even 10000 repeats or more
> 
> ;;The function to optimize
> (defun run (mlist)
>    (let* ((n (1- (length mlist)))
>           (mlist (coerce (delete (nth 0 mlist) mlist) 'vector))
>           (mtable (make-array
>                    (list (/ (* n (1- n)) 2) 3)
>                    :initial-element 0))
>           (ind 0)
>           (ind2 0)
>           (Pm 0)
>           (i 0))
>    (while (<= i (1- n))
>           (let ((sP 0)
>                 (j (1+ i)))
>             (while (< j n)
>                    (setf sP (+ sP (elt mlist (1- j))))
>                    (setf (aref mtable ind 0) i)
>                    (setf (aref mtable ind 1) j)
>                    (setf (aref mtable ind 2)
>                          (if (< sP 1)
>                            (/ 1 (* (float (- j i))
>                                    (float (+ (- n j) (1+ i))) (float sP)))
>                            1))
>                    (when (> (aref mtable ind 2) Pm)
>                      (setf Pm (aref mtable ind 2)
>                            ind2 ind))
>                    (incf ind)
>                    (incf j))
>             (incf i)))
>    (setf mtable2
>          (loop for i from 0 to 2
>                collect (aref mtable ind2 i)))))
> 
> (time (run mlist))

Here's a Clojure version that's quite slow.
Is there a way to make it faster?


(set! *warn-on-reflection* true)

(def mlist (take 4000 (repeatedly #(double (rand)))))

(defn run [mlist]
  (let [  n  (dec (count mlist))
          mlist  (vec (rest mlist))
          size (/ (* n (dec n)) 2)
          int-table (make-array Integer/TYPE size 2)
          float-table (make-array Double/TYPE size)
       ]

    (with-local-vars
      [ ind1 0
        ind2 0
        pm  0.0
        sp  0.0 ]

      (dotimes [i n]
        (var-set sp  0.0)

        (doseq [j (range (inc i) n)]
          (var-set sp (+ @sp (mlist (dec j))))
          (aset int-table @ind1 0  i)
          (aset int-table @ind1 1  j)
          (aset float-table (int @ind1)
            (if (< @sp 1.0)
              (/ 1.0  (*  (- j i)
                      (+ (- n j) (inc i))  @sp))
              1.0))
          (when (> (aget float-table (int @ind1)) @pm)
            (var-set pm (aget float-table (int @ind1)))
            (var-set ind2 @ind1))
          (var-set ind1 (inc @ind1))
        )
      )

      (conj (vec (aget int-table @ind2)) (aget float-table @ind2))
)))

(time (prn (run mlist) ))
From: William James
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <go6km006h1@enews2.newsguy.com>
William James wrote:

> Dimiter "malkia" Stanev wrote:
> 
> > Your code on my machine LispWorks 5.1:
> > 
> > User time    =       49.203
> > System time  =        0.031
> > Elapsed time =       49.250
> > Allocation   = 160266280 bytes
> > 
> > After some optimizations:
> > 
> > Now originally I was thinking you can put declare here and there,
> > but the problem is in "nth" - e.g. your algorithm.
> > 
> > "nth" is not efficient when you have long list, you better convert
> > that list temporarily to vector, array or if you know your data
> > simple-array with the type.
> > 
> > Just changing this bit ("nth" to "elt") and mlist a coerced vector, 
> > speeded up 10 times.
> > 
> > I think with more optimizations, and lastly declares, it can go 100
> > if not more faster.
> > 
> > (defmacro while (condition &rest body)
> >    (let ((var (gensym)))
> >      `(do ((,var nil (progn ,@body)))
> > 	 ((null ,condition) ,var))))
> > 
> > (defvar mlist (loop repeat 4000 collect (random 1.0))) ;;I need to
> > use even 10000 repeats or more
> > 
> > ;;The function to optimize
> > (defun run (mlist)
> >    (let* ((n (1- (length mlist)))
> >           (mlist (coerce (delete (nth 0 mlist) mlist) 'vector))
> >           (mtable (make-array
> >                    (list (/ (* n (1- n)) 2) 3)
> >                    :initial-element 0))
> >           (ind 0)
> >           (ind2 0)
> >           (Pm 0)
> >           (i 0))
> >    (while (<= i (1- n))
> >           (let ((sP 0)
> >                 (j (1+ i)))
> >             (while (< j n)
> >                    (setf sP (+ sP (elt mlist (1- j))))
> >                    (setf (aref mtable ind 0) i)
> >                    (setf (aref mtable ind 1) j)
> >                    (setf (aref mtable ind 2)
> >                          (if (< sP 1)
> >                            (/ 1 (* (float (- j i))
> >                                    (float (+ (- n j) (1+ i)))
> > (float sP)))                            1))
> >                    (when (> (aref mtable ind 2) Pm)
> >                      (setf Pm (aref mtable ind 2)
> >                            ind2 ind))
> >                    (incf ind)
> >                    (incf j))
> >             (incf i)))
> >    (setf mtable2
> >          (loop for i from 0 to 2
> >                collect (aref mtable ind2 i)))))
> > 
> > (time (run mlist))
> 
> Here's a Clojure version that's quite slow.
> Is there a way to make it faster?
> 
> 
> (set! *warn-on-reflection* true)
> 
> (def mlist (take 4000 (repeatedly #(double (rand)))))
> 
> (defn run [mlist]
>   (let [  n  (dec (count mlist))
>           mlist  (vec (rest mlist))
>           size (/ (* n (dec n)) 2)
>           int-table (make-array Integer/TYPE size 2)
>           float-table (make-array Double/TYPE size)
>        ]
> 
>     (with-local-vars
>       [ ind1 0
>         ind2 0
>         pm  0.0
>         sp  0.0 ]
> 
>       (dotimes [i n]
>         (var-set sp  0.0)
> 
>         (doseq [j (range (inc i) n)]
>           (var-set sp (+ @sp (mlist (dec j))))
>           (aset int-table @ind1 0  i)
>           (aset int-table @ind1 1  j)
>           (aset float-table (int @ind1)
>             (if (< @sp 1.0)
>               (/ 1.0  (*  (- j i)
>                       (+ (- n j) (inc i))  @sp))
>               1.0))
>           (when (> (aget float-table (int @ind1)) @pm)
>             (var-set pm (aget float-table (int @ind1)))
>             (var-set ind2 @ind1))
>           (var-set ind1 (inc @ind1))
>         )
>       )
> 
>       (conj (vec (aget int-table @ind2)) (aget float-table @ind2))
> )))
> 
> (time (prn (run mlist) ))

The size of mlist had to be reduced to 1000 to avoid running out of
heap space.

This version is faster because it doesn't use multidimensional Java
arrays.

(set! *warn-on-reflection* true)

(def mlist (take 1000 (repeatedly #(double (rand)))))

(defn run [mlist]
  (let [  n  (dec (count mlist))
          mlist  (vec (rest mlist))
          size (/ (* n (dec n)) 2)
          float-table (make-array Double/TYPE size)
       ]

    (with-local-vars
      [ ind1 (int 0)
        ind2 0
        pm  0.0
        sp  0.0
        int-table (vec (replicate (* 2 size ) (int 0)))
      ]

      (dotimes [i n]
        (var-set sp  0.0)

        (doseq [j (range (inc i) n)]
          (var-set sp (+ @sp (mlist (dec j))))
          (var-set int-table (assoc @int-table (* 2 @ind1) i)) 
          (var-set int-table (assoc @int-table (inc (* 2 @ind1)) j))
          (aset float-table (int @ind1)
            (if (< @sp 1.0)
              (/ 1.0  (*  (- j i)
                      (+ (- n j) (inc i))  @sp))
              1.0))
          (when (> (aget float-table (int @ind1)) @pm)
            (var-set pm (aget float-table (int @ind1)))
            (var-set ind2 @ind1))
          (var-set ind1 (inc @ind1))
        )
      )

      [ (@int-table @ind2) (@int-table (inc @ind2))
        (aget float-table @ind2) ]
)))

(time (prn (run mlist) ))
From: André Thieme
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <go7151$rc9$1@news.motzarella.org>
William James schrieb:
> William James wrote:
> 
>> Dimiter "malkia" Stanev wrote:
>>
>>> Your code on my machine LispWorks 5.1:
>>>
>>> User time    =       49.203
>>> System time  =        0.031
>>> Elapsed time =       49.250
>>> Allocation   = 160266280 bytes
>>>
>>> After some optimizations:
>>>
>>> Now originally I was thinking you can put declare here and there,
>>> but the problem is in "nth" - e.g. your algorithm.
>>>
>>> "nth" is not efficient when you have long list, you better convert
>>> that list temporarily to vector, array or if you know your data
>>> simple-array with the type.
>>>
>>> Just changing this bit ("nth" to "elt") and mlist a coerced vector, 
>>> speeded up 10 times.
>>>
>>> I think with more optimizations, and lastly declares, it can go 100
>>> if not more faster.
>>>
>>> (defmacro while (condition &rest body)
>>>    (let ((var (gensym)))
>>>      `(do ((,var nil (progn ,@body)))
>>> 	 ((null ,condition) ,var))))
>>>
>>> (defvar mlist (loop repeat 4000 collect (random 1.0))) ;;I need to
>>> use even 10000 repeats or more
>>>
>>> ;;The function to optimize
>>> (defun run (mlist)
>>>    (let* ((n (1- (length mlist)))
>>>           (mlist (coerce (delete (nth 0 mlist) mlist) 'vector))
>>>           (mtable (make-array
>>>                    (list (/ (* n (1- n)) 2) 3)
>>>                    :initial-element 0))
>>>           (ind 0)
>>>           (ind2 0)
>>>           (Pm 0)
>>>           (i 0))
>>>    (while (<= i (1- n))
>>>           (let ((sP 0)
>>>                 (j (1+ i)))
>>>             (while (< j n)
>>>                    (setf sP (+ sP (elt mlist (1- j))))
>>>                    (setf (aref mtable ind 0) i)
>>>                    (setf (aref mtable ind 1) j)
>>>                    (setf (aref mtable ind 2)
>>>                          (if (< sP 1)
>>>                            (/ 1 (* (float (- j i))
>>>                                    (float (+ (- n j) (1+ i)))
>>> (float sP)))                            1))
>>>                    (when (> (aref mtable ind 2) Pm)
>>>                      (setf Pm (aref mtable ind 2)
>>>                            ind2 ind))
>>>                    (incf ind)
>>>                    (incf j))
>>>             (incf i)))
>>>    (setf mtable2
>>>          (loop for i from 0 to 2
>>>                collect (aref mtable ind2 i)))))
>>>
>>> (time (run mlist))
>> Here's a Clojure version that's quite slow.
>> Is there a way to make it faster?
>>
>>
>> (set! *warn-on-reflection* true)
>>
>> (def mlist (take 4000 (repeatedly #(double (rand)))))
>>
>> (defn run [mlist]
>>   (let [  n  (dec (count mlist))
>>           mlist  (vec (rest mlist))
>>           size (/ (* n (dec n)) 2)
>>           int-table (make-array Integer/TYPE size 2)
>>           float-table (make-array Double/TYPE size)
>>        ]
>>
>>     (with-local-vars
>>       [ ind1 0
>>         ind2 0
>>         pm  0.0
>>         sp  0.0 ]
>>
>>       (dotimes [i n]
>>         (var-set sp  0.0)
>>
>>         (doseq [j (range (inc i) n)]
>>           (var-set sp (+ @sp (mlist (dec j))))
>>           (aset int-table @ind1 0  i)
>>           (aset int-table @ind1 1  j)
>>           (aset float-table (int @ind1)
>>             (if (< @sp 1.0)
>>               (/ 1.0  (*  (- j i)
>>                       (+ (- n j) (inc i))  @sp))
>>               1.0))
>>           (when (> (aget float-table (int @ind1)) @pm)
>>             (var-set pm (aget float-table (int @ind1)))
>>             (var-set ind2 @ind1))
>>           (var-set ind1 (inc @ind1))
>>         )
>>       )
>>
>>       (conj (vec (aget int-table @ind2)) (aget float-table @ind2))
>> )))
>>
>> (time (prn (run mlist) ))
> 
> The size of mlist had to be reduced to 1000 to avoid running out of
> heap space.
> 
> This version is faster because it doesn't use multidimensional Java
> arrays.
> 
> (set! *warn-on-reflection* true)
> 
> (def mlist (take 1000 (repeatedly #(double (rand)))))
> 
> (defn run [mlist]
>   (let [  n  (dec (count mlist))
>           mlist  (vec (rest mlist))
>           size (/ (* n (dec n)) 2)
>           float-table (make-array Double/TYPE size)
>        ]
> 
>     (with-local-vars
>       [ ind1 (int 0)
>         ind2 0
>         pm  0.0
>         sp  0.0
>         int-table (vec (replicate (* 2 size ) (int 0)))
>       ]
> 
>       (dotimes [i n]
>         (var-set sp  0.0)
> 
>         (doseq [j (range (inc i) n)]
>           (var-set sp (+ @sp (mlist (dec j))))
>           (var-set int-table (assoc @int-table (* 2 @ind1) i)) 
>           (var-set int-table (assoc @int-table (inc (* 2 @ind1)) j))
>           (aset float-table (int @ind1)
>             (if (< @sp 1.0)
>               (/ 1.0  (*  (- j i)
>                       (+ (- n j) (inc i))  @sp))
>               1.0))
>           (when (> (aget float-table (int @ind1)) @pm)
>             (var-set pm (aget float-table (int @ind1)))
>             (var-set ind2 @ind1))
>           (var-set ind1 (inc @ind1))
>         )
>       )
> 
>       [ (@int-table @ind2) (@int-table (inc @ind2))
>         (aget float-table @ind2) ]
> )))
> 
> (time (prn (run mlist) ))

It�s terrible, it has nothing to do with Clojure.
But, I can understand that you tried it this way. It was not documented
what the code is actually doing. First one would need to understand the
program, and then one could write a version in functional style. I think
no var-set is needed, no mutation.
And if you run out of ram, then just start the JVM with more.
java -server -Xmx1024M -cp clojure.jar clojure.lang.Repl

This will start the server VM with 1024MB.


Andr�
-- 
Lisp is not dead. It�s just the URL that has changed:
http://clojure.org/
From: Marco Antoniotti
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <048e4b56-9b09-460d-bd3a-83a47da253e1@b16g2000yqb.googlegroups.com>
On Feb 26, 6:48 pm, "William James" <> wrote:
> William James wrote:
> > Dimiter "malkia" Stanev wrote:
>
> > > Your code on my machine LispWorks 5.1:
>
> > > User time    =       49.203
> > > System time  =        0.031
> > > Elapsed time =       49.250
> > > Allocation   = 160266280 bytes
>
> > > After some optimizations:
>
> > > Now originally I was thinking you can put declare here and there,
> > > but the problem is in "nth" - e.g. your algorithm.
>
> > > "nth" is not efficient when you have long list, you better convert
> > > that list temporarily to vector, array or if you know your data
> > > simple-array with the type.
>
> > > Just changing this bit ("nth" to "elt") and mlist a coerced vector,
> > > speeded up 10 times.
>
> > > I think with more optimizations, and lastly declares, it can go 100
> > > if not more faster.
>
> > > (defmacro while (condition &rest body)
> > >    (let ((var (gensym)))
> > >      `(do ((,var nil (progn ,@body)))
> > >        ((null ,condition) ,var))))
>
> > > (defvar mlist (loop repeat 4000 collect (random 1.0))) ;;I need to
> > > use even 10000 repeats or more
>
> > > ;;The function to optimize
> > > (defun run (mlist)
> > >    (let* ((n (1- (length mlist)))
> > >           (mlist (coerce (delete (nth 0 mlist) mlist) 'vector))
> > >           (mtable (make-array
> > >                    (list (/ (* n (1- n)) 2) 3)
> > >                    :initial-element 0))
> > >           (ind 0)
> > >           (ind2 0)
> > >           (Pm 0)
> > >           (i 0))
> > >    (while (<= i (1- n))
> > >           (let ((sP 0)
> > >                 (j (1+ i)))
> > >             (while (< j n)
> > >                    (setf sP (+ sP (elt mlist (1- j))))
> > >                    (setf (aref mtable ind 0) i)
> > >                    (setf (aref mtable ind 1) j)
> > >                    (setf (aref mtable ind 2)
> > >                          (if (< sP 1)
> > >                            (/ 1 (* (float (- j i))
> > >                                    (float (+ (- n j) (1+ i)))
> > > (float sP)))                            1))
> > >                    (when (> (aref mtable ind 2) Pm)
> > >                      (setf Pm (aref mtable ind 2)
> > >                            ind2 ind))
> > >                    (incf ind)
> > >                    (incf j))
> > >             (incf i)))
> > >    (setf mtable2
> > >          (loop for i from 0 to 2
> > >                collect (aref mtable ind2 i)))))
>
> > > (time (run mlist))
>
> > Here's a Clojure version that's quite slow.
> > Is there a way to make it faster?
>
> > (set! *warn-on-reflection* true)
>
> > (def mlist (take 4000 (repeatedly #(double (rand)))))
>
> > (defn run [mlist]
> >   (let [  n  (dec (count mlist))
> >           mlist  (vec (rest mlist))
> >           size (/ (* n (dec n)) 2)
> >           int-table (make-array Integer/TYPE size 2)
> >           float-table (make-array Double/TYPE size)
> >        ]
>
> >     (with-local-vars
> >       [ ind1 0
> >         ind2 0
> >         pm  0.0
> >         sp  0.0 ]
>
> >       (dotimes [i n]
> >         (var-set sp  0.0)
>
> >         (doseq [j (range (inc i) n)]
> >           (var-set sp (+ @sp (mlist (dec j))))
> >           (aset int-table @ind1 0  i)
> >           (aset int-table @ind1 1  j)
> >           (aset float-table (int @ind1)
> >             (if (< @sp 1.0)
> >               (/ 1.0  (*  (- j i)
> >                       (+ (- n j) (inc i))  @sp))
> >               1.0))
> >           (when (> (aget float-table (int @ind1)) @pm)
> >             (var-set pm (aget float-table (int @ind1)))
> >             (var-set ind2 @ind1))
> >           (var-set ind1 (inc @ind1))
> >         )
> >       )
>
> >       (conj (vec (aget int-table @ind2)) (aget float-table @ind2))
> > )))
>
> > (time (prn (run mlist) ))
>
> The size of mlist had to be reduced to 1000 to avoid running out of
> heap space.
>
> This version is faster because it doesn't use multidimensional Java
> arrays.

"Multidimensional Java arrays"?

Cheers
--
Marco











>
> (set! *warn-on-reflection* true)
>
> (def mlist (take 1000 (repeatedly #(double (rand)))))
>
> (defn run [mlist]
>   (let [  n  (dec (count mlist))
>           mlist  (vec (rest mlist))
>           size (/ (* n (dec n)) 2)
>           float-table (make-array Double/TYPE size)
>        ]
>
>     (with-local-vars
>       [ ind1 (int 0)
>         ind2 0
>         pm  0.0
>         sp  0.0
>         int-table (vec (replicate (* 2 size ) (int 0)))
>       ]
>
>       (dotimes [i n]
>         (var-set sp  0.0)
>
>         (doseq [j (range (inc i) n)]
>           (var-set sp (+ @sp (mlist (dec j))))
>           (var-set int-table (assoc @int-table (* 2 @ind1) i))
>           (var-set int-table (assoc @int-table (inc (* 2 @ind1)) j))
>           (aset float-table (int @ind1)
>             (if (< @sp 1.0)
>               (/ 1.0  (*  (- j i)
>                       (+ (- n j) (inc i))  @sp))
>               1.0))
>           (when (> (aget float-table (int @ind1)) @pm)
>             (var-set pm (aget float-table (int @ind1)))
>             (var-set ind2 @ind1))
>           (var-set ind1 (inc @ind1))
>         )
>       )
>
>       [ (@int-table @ind2) (@int-table (inc @ind2))
>         (aget float-table @ind2) ]
> )))
>
> (time (prn (run mlist) ))
From: Thomas F. Burdick
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <cfee5fa9-b74f-4759-9d33-a5a954f9f173@x38g2000yqj.googlegroups.com>
On Feb 27, 11:52 am, Marco Antoniotti <·······@gmail.com> wrote:
> On Feb 26, 6:48 pm, "William James" <> wrote:
>
> > This version is faster because it doesn't use multidimensional Java
> > arrays.
>
> "Multidimensional Java arrays"?

I don't use them myself, I find that they interoperate badly with
FORTRAN's garbage collector. Not to mention their effect on C's method
combinations.
From: Marco Antoniotti
Subject: Re: Optimize a function for speed
Date: 
Message-ID: <00f4f4f9-288b-4efa-9abb-0dbef4c9c3af@t3g2000yqa.googlegroups.com>
On Feb 27, 1:57 pm, "Thomas F. Burdick" <········@gmail.com> wrote:
> On Feb 27, 11:52 am, Marco Antoniotti <·······@gmail.com> wrote:
>
> > On Feb 26, 6:48 pm, "William James" <> wrote:
>
> > > This version is faster because it doesn't use multidimensional Java
> > > arrays.
>
> > "Multidimensional Java arrays"?
>
> I don't use them myself, I find that they interoperate badly with
> FORTRAN's garbage collector. Not to mention their effect on C's method
> combinations.

I agree that there are cases where Java Multidimensional arrays may
have some bad effect on C's method combinations.  OTOH, you can always
circumvent these problems by making sure that the finalizers in your
FORTRAN code eventually, during garbage collection, recode themselves
up as strings which can then be passed to the Ruby runtime.  I am
pretty sure this simple tool-chain will be soon coded up in Clojure by
our mutual friend. :)

Cheers
--
Marco