[Top][All Lists]

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

Re: about logarithm in .cc files

From: Andy Buckle
Subject: Re: about logarithm in .cc files
Date: Wed, 5 Jan 2011 16:04:57 +0000

On Wed, Jan 5, 2011 at 3:21 PM, 时刻 <address@hidden> wrote:
> Hello all,
>  I am working with Oct-Files, and  encountering a problem, that is, how to 
> write logarithm in .cc files. In .m files it is simple, i.e. log(x), here I 
> set x to be a matrix. So how to do it in .cc files?
> Thanks
> Best regards,

The trick seems to be to make it into an octave_value first.

#include "octave/oct.h"

DEFUN_DLD (log, args, nargout,"") {
  octave_value_list retval;

  const int rows=3, cols=4;

  dim_vector dv(rows,cols);
  NDArray arr(dv);
  double * pix_p=(double *)arr.fortran_vec();

  for (uint32_t i=0; i<rows*cols ;i++) {
    pix_p[i] = i;

  octave_value arrval(arr);

  return arrval.log();

/* andy buckle */

reply via email to

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