This file is indexed.

/usr/share/octave/packages/linear-algebra-2.2.0/circulant_eig.m is in octave-linear-algebra 2.2.0-1build1.

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
## Copyright (C) 2012 Nir Krakauer <nkrakauer@ccny.cuny.edu>
##
## 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{lambda} =} circulant_eig (@var{v})
## @deftypefnx{Function File} {[@var{vs}, @var{lambda}] =} circulant_eig (@var{v})
##
## Fast, compact calculation of eigenvalues and eigenvectors of a circulant matrix@*
## Given an @var{n}*1 vector @var{v}, return the eigenvalues @var{lambda} and optionally eigenvectors @var{vs} of the @var{n}*@var{n} circulant matrix @var{C} that has @var{v} as its first column
##
## Theoretically same as @code{eig(make_circulant_matrix(v))}, but many fewer computations; does not form @var{C} explicitly
##
## Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3
##
## @seealso{circulant_make_matrix, circulant_matrix_vector_product, circulant_inv}
## @end deftypefn

function [a, b] = circulant_eig (v)

  ## FIXME when warning for broadcastin is turned off by default, this
  ## unwind_protect block could be removed

  ## we are using broadcasting on the code below so we turn off the
  ## warnings but will restore to previous state at the end
  bc_warn = warning ("query", "Octave:broadcast");
  unwind_protect
    warning ("off", "Octave:broadcast");

    #find the eigenvalues
    n = numel(v);
    lambda = ones(n, 1);
    s = (0:(n-1));
    lambda = sum(v .* exp(-2*pi*i*s'*s/n))';

    if nargout < 2
      a = lambda;
      return
    endif

    #find the eigenvectors (which in fact do not depend on v)
    a = exp(-2*i*pi*s'*s/n) / sqrt(n);
    b = diag(lambda);
  unwind_protect_cleanup
    ## restore broadcats warning status
    warning (bc_warn.state, "Octave:broadcast");
  end_unwind_protect

endfunction

%!shared v,C,vs,lambda
%! v = [1 2 3]';
%! C = circulant_make_matrix(v);
%! [vs lambda] = circulant_eig(v);
%!assert (vs*lambda, C*vs, 100*eps);