help-octave
[Top][All Lists]
Advanced

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

Oct-file version of x>0


From: John W. Eaton
Subject: Oct-file version of x>0
Date: Tue, 23 May 2006 23:09:10 -0400

On 23-May-2006, Keith Goodman wrote:

| While porting a m-file to an oct-file I got stuck on the line
| 
| y = x'*(x > 0);
| 
| where x is Nx1.
| 
| How do I port x>0?
| 
| I figured out how not to do it all by myself:
| 
| #include <oct.h>
| DEFUN_DLD(abc, args, nargout,"y = x'*(x > 0) where x is Nx1")
| {
|   octave_value retval;
|   Matrix x = args(0).matrix_value();
|   retval = x.transpose() * (x > 0);
|   return retval;
| }
| 
| $ mkoctfile abc.cc
| abc.cc: In function 'octave_value_list Fabc(const octave_value_list&, int)':
| abc.cc:6: error: ambiguous overload for 'operator>' in 'x > 0'

#include <oct.h>
DEFUN_DLD(abc, args, nargout,"y = x'*(x > 0) where x is Nx1")
{
  octave_value retval;
  Matrix x = args(0).matrix_value();
  retval = x.transpose() * mx_el_gt (x, 0);
  return retval;
}

If your next question is "Where is this documented?" the only answer I
has is that the internals of Octave are not well documented, so use
the Source, Luke.  Then you'll probably say, "I could have looked all
day/week/month/year/decade and not found this function!" and I'd have
to say, "Me too, when is someone going to document this mess?"

jwe


reply via email to

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