[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: I'll try again: oct and arrays
From: |
Jesper Schmidt Hansen |
Subject: |
Re: I'll try again: oct and arrays |
Date: |
Thu, 30 Dec 2010 12:52:21 +0100 |
Thank you for your prompt replies!
> How are you compiling, which compiler?
In this particular example I've used gcc version 4.4.3 using the flags
that comes with mkoctfile: -mieee-fp -O2 -g I have tried to change
the compiler flags before with earlier versions of gcc (and Octave)
without significant changes in the execution speed.
> Also, this is a rather artificial example.
The example came up because I wanted to illustrate the Gauss-Seidel
relaxation method using simple ISO-C, the OCT interface and the MEX
interface. It struck me that using the OCT interface resulted in the
slowest "executable" by far. And it seems to be due to the way one
access the array elements. I know that Octave's built-in solver is
much much faster than the Gauss-Seidel method, but let's say I for
some strange reason must implement a particular solver then it seems
to me that I should not try to do this directly in an OCT file but use
this for simple wrapping.
I have tried to use fortran_vec() as Martin and Søren suggested: this
gives a speed-up of two compared to using the ()-operator, but is
still slower than the corresponding MEX file. On the current machine
I get (different from the one I used in the original question), the
numbers in parenthesis denote the standard deviation
OCT using (): 0.0362 (0.0006)
OCT using fortran_vec(): 0.0143 (0.0006)
MEX : 0.0078 (0.0005)
Jesper
--
Jesper Schmidt Hansen, Ph.D. M.Sc.