help-octave
[Top][All Lists]
Advanced

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

Re: <unknown type> - numgradient and varargin


From: Olaf Till
Subject: Re: <unknown type> - numgradient and varargin
Date: Wed, 16 Apr 2014 15:59:01 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Apr 16, 2014 at 11:41:16AM +0300, Jose wrote:
> Hello.
> 
> I am trying to calculate gradients of a function f whose last
> argument is varargin. I am trying to use numgradient for that.
> 
> I have encountered a problem: the execution of numgradient seems to
> add an extra element to varargin (as seen by f) with unknown type.
> 
> Have a look:
> 
> ----->
> octave:16> clear all
> octave:17> pkg load optim
> octave:18> function a = f(x,varargin);
> > nargin
> > a = x;
> > endfunction
> octave:19> args{1}=2;
> octave:20> numel(args)
> ans =  1
> octave:21> f(1,args{:});
> ans =  2
> octave:22> numgradient('f',{1,args{:}});
> ans =  3
> ans =  3
> ans =  3
> octave:23> function a = f(x,varargin);
> > varargin
> > a = x;
> > endfunction
> octave:24> f(1,args{:});
> varargin =
> {
>   [1,1] =  2
> }
> octave:25> numgradient('f',{1,args{:}});
> varargin =
> {
>   [1,1] =  2
>   [1,2] =
> 
> error: octave_base_value::print (): wrong type argument '<unknown type>'
> 
> }
> error: called from:
> error:   f at line 2, column 1
> error: octave_base_value::matrix_value(): wrong type argument
> '<unknown type>'
> error: octave_base_value::matrix_value(): wrong type argument
> '<unknown type>'
> error: octave_base_value::matrix_value(): wrong type argument
> '<unknown type>'
> octave:25>
> <-----
> 
> I am using octave 3.8.1 and optim-1.3.0.
> 
> Am I missing something or should I file a bug?
> 
> Regards
> J.

There seems to be an off-by-one error in numgradient.cc, line number
108:

        f_args(k); // resize only once

should probably be:

        f_args(k - 1); // resize only once

This should explain the apparent extra argument.

You can file a bug, if you like, but I'll keep it in memory anyway and
correct it in the next days, if Michael shouldn't do it himself.

Regards, Olaf

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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