help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

octave_rand::scalar() speed


From: Steve C. Thompson
Subject: octave_rand::scalar() speed
Date: Mon, 21 Feb 2005 19:35:55 -0800
User-agent: Mutt/1.3.28i

Hello Group,

I'm finding octave_rand::scalar() to be slow.  Any idea why the
following code takes 10 seconds to run?


#include <octave/oct.h>
#include <octave/oct-rand.h>

DEFUN_DLD (slow, args, ,
  "This is slow")
{
  octave_value_list retval;

  double a;
  double b;
  double c = 0;

  while (c < 1e7)
    {
      a = octave_rand::scalar();
      b = octave_rand::scalar();
      a = octave_rand::scalar();
      b = octave_rand::scalar();
      a = octave_rand::scalar();
      b = octave_rand::scalar();
      c++;
    }

  retval(0) = a;
  retval(1) = b;
  retval(2) = c;

  return retval;
}

If I replace octave_rand::scalar() with rand() it runs faster, but the
algorithm is rand() is slower than MT.

Thanks,
Steve



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]