octave-maintainers
[Top][All Lists]
Advanced

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

feval vs. Ffunction_name in C++


From: Rik
Subject: feval vs. Ffunction_name in C++
Date: Tue, 22 Jan 2019 10:13:06 -0800

jwe,

Happened to be looking at the code for the dot product in dot.cc today. 
There is an if/elseif tree to dispatch complex/real and single/double
inputs directly to Fortran routines.  However, for other cases, like int8,
there is an unoptimized path as shown below:

--- Start Code ---
  else
    {
      // Non-optimized evaluation.
      octave_value_list tmp;
      tmp(1) = dim + 1;
      tmp(0) = do_binary_op (octave_value::op_el_mul, argx, argy);

      tmp = octave::feval ("sum", tmp, 1);
      if (! tmp.empty ())
        retval = tmp(0);
    }
--- End Code ---

Do we need to use feval in this case or would it be slightly more efficient
to just call Fsum directly?

Presumably this code in dot.cc is never called if someone has overloaded
the dot function for their class.  I suppose it is possible that someone
has overloaded sum, but why wouldn't you just overload the base
mathematical functions plus() and then rely on Fsum to do the right thing?

--Rik






reply via email to

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