This file is indexed.

/usr/share/octave/packages/linear-algebra-2.2.2/condeig.m is in octave-linear-algebra 2.2.2-1.

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
## Copyright (C) 2006, 2007 Arno Onken <asnelt@asnelt.org>
##
## 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 -*-
## @deftypefn {Function File} {@var{c} =} condeig (@var{a})
## @deftypefnx {Function File} {[@var{v}, @var{lambda}, @var{c}] =} condeig (@var{a})
## Compute condition numbers of the eigenvalues of a matrix. The
## condition numbers are the reciprocals of the cosines of the angles
## between the left and right eigenvectors.
##
## @subheading Arguments
##
## @itemize @bullet
## @item
## @var{a} must be a square numeric matrix.
## @end itemize
##
## @subheading Return values
##
## @itemize @bullet
## @item
## @var{c} is a vector of condition numbers of the eigenvalue of
## @var{a}.
##
## @item
## @var{v} is the matrix of right eigenvectors of @var{a}. The result is
## the same as for @code{[v, lambda] = eig (a)}.
##
## @item
## @var{lambda} is the diagonal matrix of eigenvalues of @var{a}. The
## result is the same as for @code{[v, lambda] = eig (a)}.
## @end itemize
##
## @subheading Example
##
## @example
## @group
## a = [1, 2; 3, 4];
## c = condeig (a)
## @result{} [1.0150; 1.0150]
## @end group
## @end example
## @end deftypefn

function [v, lambda, c] = condeig (a)

  # Check arguments
  if (nargin != 1 || nargout > 3)
    print_usage ();
  endif

  if (! isempty (a) && ! (ismatrix (a) && isnumeric (a)))
    error ("condeig: a must be a numeric matrix");
  endif

  if (columns (a) != rows (a))
    error ("condeig: a must be a square matrix");
  endif

  if (issparse (a) && (nargout == 0 || nargout == 1) && exist ("svds", "file"))
    ## Try to use svds to calculate the condition as it will typically be much 
    ## faster than calling eig as only the smallest and largest eigenvalue are
    ## calculated.
    try
      s0 = svds (a, 1, 0);
      v = svds (a, 1) / s0;
    catch
      ## Caught an error as there is a singular value exactly at Zero!!
      v = Inf;
    end_try_catch
    return;
  endif

  # Right eigenvectors
  [v, lambda] = eig (a);

  if (isempty (a))
    c = lambda;
  else
    # Corresponding left eigenvectors
    vl = inv (v)';
    # Normalize vectors
    vl = vl ./ repmat (sqrt (sum (abs (vl .^ 2))), rows (vl), 1);

    # Condition numbers
    # cos (angle) = (norm (v1) * norm (v2)) / dot (v1, v2)
    # Norm of the eigenvectors is 1 => norm (v1) * norm (v2) = 1
    c = abs (1 ./ dot (vl, v)');
  endif

  if (nargout == 0 || nargout == 1)
    v = c;
  endif

endfunction

%!test
%! a = [1, 2; 3, 4];
%! c = condeig (a);
%! expected_c = [1.0150; 1.0150];
%! assert (c, expected_c, 0.001);

%!test
%! a = [1, 3; 5, 8];
%! [v, lambda, c] = condeig (a);
%! [expected_v, expected_lambda] = eig (a);
%! expected_c = [1.0182; 1.0182];
%! assert (v, expected_v, 0.001);
%! assert (lambda, expected_lambda, 0.001);
%! assert (c, expected_c, 0.001);