help-octave
[Top][All Lists]
Advanced

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

Re: I'll try again: oct and arrays


From: Søren Hauberg
Subject: Re: I'll try again: oct and arrays
Date: Wed, 29 Dec 2010 14:59:33 +0100

ons, 29 12 2010 kl. 14:34 +0100, skrev Jesper Schmidt Hansen:
> I think the difference is due to the fact that there exists an
> overhead using the () operator (not inlined by the compiler I guess),
> which is not there when you access the variable elements directly. Is
> this correct? If so, how to overcome this overhead without first
> copying everything to a second simple double array?

I am unsure of why the () operator causes slow down. A simple solution
would be to do something like (untested code):

  const double *values = A.fortran_vec ();
  const int numel = A.numel ();
  double sum = 0;
  for (int k = 0; k < numel; k++)
    sum += values [k];

Søren



reply via email to

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