/usr/share/octave/packages/interval-2.1.0/verinvnonneg.m is in octave-interval 2.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | ## Copyright 2008 Jiří Rohn
## Copyright 2016 Oliver Heimlich
##
## This program is derived from verinvnonneg in VERSOFT, published on
## 2016-07-26, which is distributed under the terms of the Expat license,
## a.k.a. the MIT license. Original Author is Jiří Rohn. Migration to Octave
## code has been performed by Oliver Heimlich.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @documentencoding UTF-8
## @deftypefun {[nonneg, As] =} verinvnonneg (@var{A})
## Verified nonnegative invertibility of an interval matrix.
##
## For a square interval (or real) matrix @var{A}, this function verifies
## inverse nonnegativity of @var{A}, or not-inverse-nonnegativity of @var{A},
## or yields no verified result:
##
## @table @asis
## @item @var{nonneg} = 1
## @var{A} verified inverse nonnegative,
##
## @item @var{nonneg} = 0
## @var{A} verified not to be inverse nonnegative; @var{As} is a matrix in
## @var{A} (always one of the two bounds) which is verified not to be inverse
## nonnegative,
##
## @item @var{nonneg = -1}
## no verified result.
## @end table
##
## Based on the result by Kuttler, Math. of Computation 1971; see also J. Rohn,
## A Handbook of Results on Interval Linear Problems, posted at
## @url{http://www.cs.cas.cz/~rohn}, Section 3.9.
##
## This work was supported by the Czech Republic National Research
## Program “Information Society”, project 1ET400300415.
##
## @seealso{inv}
## @end deftypefun
## Author: Jiří Rohn
## Keywords: interval
## Created: 2008
function [nonneg, As] = verinvnonneg (A)
if (nargin ~= 1)
print_usage ();
return
endif
[m, n] = size (A);
nonneg = -1;
As = repmat (infsup, m, n);
if (m ~= n)
error ("verinvnonneg: matrix not square");
endif
if (~isa (A, "infsup"))
A = infsup (A); # allows for real input
endif
if (any (isempty (A)(:)))
# matrix is empty interval: no inverse
nonneg = 0;
return
endif
Al = infsup (inf (A), max (-realmax, inf (A)));
Bl = inv (Al);
if (all (all (issingleton (A))))
Au = Al;
Bu = Bl;
else
Au = infsup (min (realmax, sup (A)), sup (A));
Bu = inv (Au);
endif
if (any ((isempty (Bl) | isempty (Bu))(:)))
# empty inverse: no inverse exists
nonneg = 0;
return
endif
if (all (all (Bl.inf >= 0)) && all (all (Bu.inf >= 0)))
# verified inverse nonnegative; Kuttler, Math. of Comp. 1971
nonneg = 1;
return
endif
if (any ((Bl.sup < 0)(:)))
nonneg = 0;
As=Al; # A.inf verified not inverse nonnegative
return
endif
if (any ((Bu.sup < 0)(:)))
nonneg = 0;
As = Au; # A.sup verified not inverse nonnegative
return
end
endfunction
%!assert (verinvnonneg (eye (1)), 1)
%!assert (verinvnonneg (eye (2)), 1)
%!assert (verinvnonneg (eye (3)), 1)
%!assert (verinvnonneg (eye (4)), 1)
%!assert (verinvnonneg (eye (5)), 1)
%!assert (verinvnonneg (eye (6)), 1)
%!assert (verinvnonneg (eye (7)), 1)
%!assert (verinvnonneg (eye (8)), 1)
%!assert (verinvnonneg (zeros (1)), 0)
%!assert (verinvnonneg (zeros (2)), 0)
%!assert (verinvnonneg (zeros (3)), 0)
%!assert (verinvnonneg (zeros (4)), 0)
%!assert (verinvnonneg (zeros (5)), 0)
%!assert (verinvnonneg (zeros (6)), 0)
%!assert (verinvnonneg (zeros (7)), 0)
%!assert (verinvnonneg (zeros (8)), 0)
%!assert (verinvnonneg (magic (7)), 0)
%!assert (verinvnonneg (infsup (-inf, inf)), -1)
|