help-octave
[Top][All Lists]
Advanced

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

map() versus apply()


From: Douglas Eck
Subject: map() versus apply()
Date: Tue, 11 Dec 2001 16:11:27 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.6) Gecko/20011120

In investigating this inplace matrix operation issue I started
testing what I thought was the obvious. Namely that map() should
be slower than apply() because map first makes a new Matrix
and then calls apply()..

Very very strangely (at least to my somewhat-dull-from-coding mind)
apply() is consistantly though very slightly *slower* for code like
this (consider it p-code... not all of it is reproduced.)


inline double logc(double x)  { return 1/(1+exp(-x));}

Matrix mywgts;
mywgts=wgts;
for (int i=0;i<loops;i++)
   mywgts.apply(logc);

mywgts=wgts;
for (int i=0;i<loops;i++)
   mywgts=mywgts.map(logc);




Can anyone shed light on this? I noticed that dMatrix::map is const while apply
isn't but since map() calls apply() I didn't think that would matter:

Matrix
Matrix::map (d_d_Mapper f) const
{
  Matrix b (*this);
  return b.apply (f);
}

Or is it just a one-off strange byproduct of bad measurement?

Doug
--
Dr. Douglas Eck, http://www.idsia.ch/~doug
Istituto Dalle Molle di Studi sull'Intelligenza Artificiale (IDSIA)
Neural Networks, Rhythm Perception and Production, Dynamical Systems



-------------------------------------------------------------
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]