help-octave
[Top][All Lists]

## Re: Segmentation fault

 From: Juan I. Arribas Subject: Re: Segmentation fault Date: Tue, 08 Apr 1997 18:19:48 +0200

```Friedrich Leisch wrote:

> hope you appreciate some suggestions by me, too ;-)
>
> anyway, to get started you should include some code (causing the
> problem) into a help request, simply saying `I get a seg fault' is not
> very informative ...
>
> best,
> fritz
>
> --
> ---------------------------------------------------------------------
>                          Friedrich  Leisch
>  Institut für Statistik                      Tel: (+43 1) 58801 4541
>  Technische Universität Wien                 Fax: (+43 1)  504 14 98
>  A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch
>       PGP public key http://www.ci.tuwien.ac.at/~leisch/pgp.key
> ---------------------------------------------------------------------

Dear Friedrich,
here they are, the two functions in files .m which I
think are causing me the problem: delta.m and logsig.m. They are both
called for around 30 million times from the inner part of a for
statement inside another function file.
My octave is version 1.1.1 (binary distribution) on a 2.0.0 Linux
Kernel.

I am thinking on writing the contents of both files explic inside the
general function which now calls them, to avoid calling them for so many
times.

Hope you have enough information now to properly answer me, I appreciate

best

Juan I. Arribas
Dept. of Teoria de la
Senal,Comunicaciones e Ingenieria Telematica
```
```function delta=delta(d,y,BETA)

if d==0
delta=(-1).*y.^(2-BETA).*(1-y).^(1-BETA);

else
delta=y.^(1-BETA).*(1-y).^(2-BETA);

endif

endfunction
```
```function a = logsig(n,b)
%LOGSIG Log sigmoid transfer function.
%
%       LOGSIG(N)
%         N - SxQ Matrix of net input (column) vectors.
%       Returns the values of N squashed between 0 and 1.
%
%       EXAMPLE: n = -10:0.1:10;
%                a = logsig(n);
%                plot(n,a)
%
%       LOGSIG(Z,B) ...Used when Batching.
%         Z - SxQ Matrix of weighted input (column) vectors.
%         B - Sx1 Bias (column) vector.
%       Returns the squashed net input values found by adding
%         B to each column of Z.
%
%       LOGSIG('delta') returns name of delta function.
%       LOGSIG('init') returns name of initialization function.
%       LOGSIG('name') returns full name of this transfer function.
%       LOGSIG('output') returns output range of this function.
%

% Mark Beale, 1-31-92
% Revised 12-15-93, MB
% Copyright (c) 1992-94 by The MathWorks, Inc.
% \$Revision: 1.1 \$  \$Date: 1994/01/11 16:25:39 \$

if nargin < 1, error('Note enough arguments.'); endif

if isstr(n)
if strcmp(lower(n),'delta')
a = 'deltalog';
elseif strcmp(lower(n),'init')
a = 'nwlog';
elseif strcmp(lower(n),'name')
a = 'Log Sigmoid';
elseif strcmp(lower(n),'output')
a = [0 1];
else
error('Unrecognized property.')
endif
else
if nargin==2
[nr,nc] = size(n);
n = n + b*ones(1,nc);
endif
a = 1 ./ (1+exp(-n));
i = find(~finite(a));
a(i) = sign(n(i))*0.5 + 0.5;
return;
endif

endfunction
```