1## Copyright (C) 2008 simone pernice
2##
3## This program is free software; you can redistribute it and/or modify
4## it under the terms of the GNU General Public License as published by
5## the Free Software Foundation; either version 2 of the License, or
6## (at your option) any later version.
7##
8## This program is distributed in the hope that it will be useful,
9## but WITHOUT ANY WARRANTY; without even the implied warranty of
10## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11## GNU General Public License for more details.
12##
13## You should have received a copy of the GNU General Public License
14## along with this program; if not, write to the Free Software
15## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17## functionInt applies the given function f the required interval, it checks for monotonicitic. The user may set the minimum number of point to check on each interval
18
19## Author: simone pernice
20## Created: 2008-08-18
21
22function int = functionInt (f, interval, minPoints = 10)
23  if (nargin() != 2 && nargin() != 3)
24     error ("Wrong number of argument passed to the function.");
25  endif
26
27  if (rows(interval) == 0)
28    error ("The set of interval is empty");
29  endif
30
31  n = 100 / rows(inteval);
32  if (n<minPoints)
33    n = minPoints;
34    if (n < 3)
35      n = 3;
36    endif
37  endif
38
39  r=1;
40  mono = 1;
41  [ret, int] = __checkMonotonicity__ (f, interval(r, :), n);
42  mono = mono && ret;
43  while r <= rows (interval)
44    ++r;
45    [ret, int1] = __checkMonotonicity__ (f, interval(r, :), n);
46    int = [int; int1];
47    mono = mono && ret;
48  endwhile
49
50  if (~ mono)
51    warning ("Warning the given function does not seem monotonic, the solution may be not accurate");
52  endif
53endfunction
54