This file is indexed.

/usr/share/octave/packages/nnet-0.1.13/__rerangecolumns.m is in octave-nnet 0.1.13-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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
## Copyright (C) 2008 Michel D. Schmid  <michaelschmid@users.sourceforge.net>
##
##
## 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 2, 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; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {} @var{retmatrix} = __rerangecolumns (@var{matrix},@var{analyzeMatrix},@var{nTrainSets})
## @code{__rerangecolumns} reranges the data sets depending on the input arguments.
## @code{matrix} is the data set matrix containing inputs and outputs (targets) in row order.
## This means for example: the first three rows are inputs and the fourth row is an output row.
## The second argument is used in the optimizing algorithm. This matrix contains informations about
## the description of the rows data of matrix.
## The third argument is used to be sure, rerange all the columns to the correct position.
## @end deftypefn

## Author: mds

function retmatrix = __rerangecolumns(matrix,analyzeMatrix,nTrainSets)

  ## check number of inputs
  error(nargchk(3,3,nargin));

  # set default values

  # now sort "matrix" with help of analyzeMatrix
  # following conditions must be kept:
  # a.) rows containing unique values aren't sorted!
  # b.) sort first rows which contains min AND max values only once
  # c.) sort secondly rows which contains min OR max values only once
  # d.) at last, sort binary data if still needed!

  nRows = size(analyzeMatrix,1);   # get number of rows

  ## create i-vector
  i = 1;
  iVec = [];
  while (i <= nRows)
    if ( (analyzeMatrix(i,3)==1) && (analyzeMatrix(i,4)==1) )
      iVec = [iVec i];
    endif
    i += 1;
  endwhile
  i = 1;
  while (i <= nRows)
	if ( (analyzeMatrix(i,3)>1) || (analyzeMatrix(i,4)>1) )
	  iVec = [iVec i];
	endif
	i += 1;
  endwhile
  i = 1;
  while (i <= nRows)
    if (analyzeMatrix(i,1)==1)
      iVec = [iVec i];
    endif
  i += 1;
  endwhile


  ## now do main loop
  j = 1;
  i = iVec(j);
  nRows = length(iVec);
  while (j < nRows)
    if (analyzeMatrix(i,2)==1)
      # easiest case, nothing to do
    else

      # now let's see if min AND max values are only once in the row
      if ( (analyzeMatrix(i,3)==1) && (analyzeMatrix(i,4)==1) )
		# search at which index the min value is
		minVal = min(matrix(i,:));
        [rowInd, colInd] = find(matrix(i,:)==minVal);# colInd is searched
        if (colInd >= nTrainSets ) # move column
		  matrix = __copycoltopos1(matrix,colInd);
        endif
        # search at which index the max value is
        maxVal = max(matrix(i,:));
        [rowInd, colInd] = find(matrix(i,:)==maxVal);# colInd is searched
        if (colInd >= nTrainSets ) # move column
		  matrix = __copycoltopos1(matrix,colInd);
        endif

      else
        
		# now here, we have to copy the rows, if min OR max values are more than once in a row
        if ( (analyzeMatrix(i,3)>=1) || (analyzeMatrix(i,4)>=1) )

		  # search at which index the min value is
		  minVal = min(matrix(i,:));
          [rowInd, colInd] = find(matrix(i,:)==minVal);# colInd is searched
          if (colInd(1) >= nTrainSets ) # move column
		    matrix = __copycoltopos1(matrix,colInd(1));
          endif
          
          # search at which index the max value is
          maxVal = max(matrix(i,:));
          [rowInd, colInd] = find(matrix(i,:) == maxVal);# colInd is searched
          if (colInd(1) >= nTrainSets ) # move column
		    matrix = __copycoltopos1(matrix,colInd(1));
          endif

		else
		  # now sort binary data, if needed
		  
          # search at which index the 0-value is
		  [rowInd, colInd] = find(matrix(i,:)==0);# colInd is searched
          if (colInd(1) >= nTrainSets ) # move column
		    matrix = __copycoltopos1(matrix,colInd(1));
          endif
          # search at which index the 1-value is
          [rowInd, colInd] = find(matrix(i,:)==1);# colInd is searched
          if (colInd(1) >= nTrainSets ) # move column
		    matrix = __copycoltopos1(matrix,colInd(1));
          endif

        endif# END OF if ( (analyzeMatrix(i,3)>=1) || (analyzeMatrix(i,4)>=1) )

      endif # END OF if ( (analyzeMatrix(i,3)==1) AND (analyzeMatrix(i,4)==1) )

    endif # END OF if (analyzeMatrix(i,2)==1)
    j += 1;
    i = iVec(j);
  endwhile
  retmatrix = matrix;
endfunction

%!shared matrix,analyzeMatrix,nTrainSets, returnmatrix
%! disp("testing __rerangecolumns")
%! matrix = [0 1 0 0 0 0 1 0 1 1;  \
%!			 4 4 4 4 4 4 4 4 4 4;  \
%!        -1.1 -1.1 2 3 4 3.2 1 8 9 10; \
%!           0 1.1 3 4 5 2 10 10 2 3; \
%!          -1 1 1 1 1 2 3 4 1 5];
%! analyzeMatrix = [1 0 0 0; 0 1 0 0; 0 0 2 1; 0 0 1 2; 0 0 1 1];
%! nTrainSets = 8;
%! returnmatrix = __rerangecolumns(matrix,analyzeMatrix,nTrainSets);
%!assert(returnmatrix(1,1)==1);
%!assert(returnmatrix(2,1)==4);
%!assert(returnmatrix(3,1)==1);
%!assert(returnmatrix(4,1)==10);
%!assert(returnmatrix(5,1)==3);
%! matrix = [0 1 0 0 0 0 1 0 1 1; 			\
%!			 4 4 4 4 4 4 4 4 4 4; 			\
%!          -1.1 -1.1 2 3 4 3.2 1 8 9 10; 	\
%!           0 1.1 3 4 5 2 10 10 2 3; 		\
%!          -1 1 1 1 1 2 3 4 1 5;     		\
%!			 0 1 2 1 2 1 2 3 4 5;];  # the last row is euqal to the nnet targets
%! analyzeMatrix = [1 0 0 0; 0 1 0 0; 0 0 2 1; 0 0 1 2; 0 0 1 1];
%! nTrainSets = 8;
%! returnmatrix = __rerangecolumns(matrix,analyzeMatrix,nTrainSets);
%!assert(returnmatrix(1,1)==1);
%!assert(returnmatrix(2,1)==4);
%!assert(returnmatrix(3,1)==1);
%!assert(returnmatrix(4,1)==10);
%!assert(returnmatrix(5,1)==3);
%!assert(returnmatrix(6,1)==2);