This file is indexed.

/usr/include/linbox/blackbox/zero-one.inl is in liblinbox-dev 1.1.6~rc0-4.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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
/* -*- mode: C++; style: linux -*- */

/* linbox/blackbox/nag-sparse.h
 * Copyright (C) 2002 Rich Seagraves
 *
 * Written by Rich Seagraves <seagrave@cis.udel.edu>
 * Modified by Zhendong Wan, -bds
 * ------------------------------------
 *
 * See COPYING for license information.
 */

namespace LinBox
{
  template<class Field>
  class ZeroOne<Field>::RawIterator
  {	
  public:
    typedef Element value_type;
    
    RawIterator(size_t pos, Element elem) :
      _pos(pos), _elem(elem) {}
    
    RawIterator(const RawIterator &In) :
      _pos(In._pos), _elem(In._elem) {}
    
    const RawIterator& operator=(const RawIterator& rhs) 
    {
      _pos = rhs._pos;
      _elem = rhs._elem;
      return *this;
    }
    
        
    bool operator==(const RawIterator &rhs) 
    {
      return ( _pos == rhs._pos && _elem == rhs._elem);
    }
    
    bool operator!=(const RawIterator &rhs) 
    {
      return ( _pos != rhs._pos || _elem != rhs._elem );
    }
    
    RawIterator & operator++() 
    {
      ++_pos;
      return *this;
    }
    
    RawIterator operator++(int) 
    {
      RawIterator tmp = *this;
      _pos++;
      return tmp;
    }
    
    value_type operator*() { return _elem; }
    
    const value_type operator*() const { return _elem; }
    
  private:
    value_type _elem;
    size_t _pos;
  };  
  
  /* STL standard Begin and End functions.  Used to get
   * the beginning and end of the data.  So that RawIterator
   * can be used in algorithms like a normal STL iterator.
   */
  template<class Field> typename
  ZeroOne<Field>::RawIterator ZeroOne<Field>::rawBegin()
  { return RawIterator( 0, _F.init(_tmp, 1) ); }
  
  template<class Field> typename
  ZeroOne<Field>::RawIterator ZeroOne<Field>::rawEnd() 
  { return RawIterator( _nnz, _F.init(_tmp, 1) ); }
  
  template<class Field> 
  const typename ZeroOne<Field>::RawIterator ZeroOne<Field>::rawBegin() const
  { return RawIterator(0, _F.init(_tmp, 1) ); }

  template<class Field> 
  const typename ZeroOne<Field>::RawIterator ZeroOne<Field>::rawEnd() const 
  { return RawIterator(_nnz, _F.init(_tmp, 1) ); } 
  
  /* RawIndexIterator - Iterates through the i and j of the current element
   * and when accessed returns an STL pair containing the coordinates
   */
  template<class Field>
  class ZeroOne<Field>::RawIndexIterator 
  {
  public:
    typedef std::pair<size_t, size_t> value_type;
    
    RawIndexIterator() {}
    
    RawIndexIterator(size_t* row, size_t* col):
      _row(row), _col(col) {}
    
    RawIndexIterator(const RawIndexIterator &In):
      _row(In._row), _col(In._col) {}
    
    const RawIndexIterator &operator=(const RawIndexIterator &rhs) 
    {
      _row = rhs._row;
      _col = rhs._col;
      return *this;				
    }
    
    bool operator==(const RawIndexIterator &rhs) 
    {
      return _row == rhs._row && _col == rhs._col;     
    }
    
    bool operator!=(const RawIndexIterator &rhs) 
    {
      return _row != rhs._row || _col != rhs._col;
    }
    
    const RawIndexIterator& operator++() 
    {
      ++_row; ++_col;	
      return *this;
    }
    
    const RawIndexIterator operator++(int) 
    {
      RawIndexIterator tmp = *this;
      ++_row; ++_col;
      return tmp;
    }
    
    value_type operator*() 
    {
      return std::pair<size_t,size_t>(*_row, *_col);
    }
    
    const value_type operator*() const 
    {
      return std::pair<size_t,size_t>(*_row, *_col);
    }
  private:
    size_t* _row, *_col;
  };
  
  template<class Field> typename
  ZeroOne<Field>::RawIndexIterator ZeroOne<Field>::indexBegin() 
  {
    return RawIndexIterator(_rowP, _colP);
  }
  
  template<class Field> 
  const typename ZeroOne<Field>::RawIndexIterator ZeroOne<Field>::indexBegin() const
  {
    return RawIndexIterator(_rowP, _colP);
  }

  template<class Field> typename
  ZeroOne<Field>::RawIndexIterator ZeroOne<Field>::indexEnd() 
  {
    return RawIndexIterator(_rowP + _nnz, _colP + _nnz);
  }

  template<class Field> 
  const typename ZeroOne<Field>::RawIndexIterator ZeroOne<Field>::indexEnd() const 
  {
    return RawIndexIterator(_rowP + _nnz, _colP + _nnz);
  }
 
  template<class Field>
  ZeroOne<Field>::ZeroOne() { srand( time(NULL) ); dynamic = false;}
    
  
  template<class Field>
  ZeroOne<Field>::ZeroOne(Field F, Index* rowP, Index* colP, Index rows, Index cols, Index NNz, bool rowSort, bool colSort):
    _F(F), _rows(rows), _cols(cols), _nnz(NNz), _rowP(rowP), _colP(colP), _rowSort(rowSort), _colSort(colSort) , dynamic(false) { srand(time(NULL)); }
  
  template<class Field>
  ZeroOne<Field>::~ZeroOne() 
  {
	  if(dynamic) {
		  delete [] _rowP;
		  delete [] _colP;
	  }
  }

  template<class Field>
  void ZeroOne<Field>::rowSort() const
  {
    int mode = 0;
    if( _rowSort) return;  // Already sorted, we're done   
    else _qsort( (size_t) 0, _nnz, mode);
    _rowSort = true;
    return;
  }

  template<class Field>
  void ZeroOne<Field>::colSort() const
  {
    int mode = 1;
    if( _colSort) return; // Already sorted, good to go  
    else _qsort( (size_t) 0, _nnz, mode);
    _colSort = true; _rowSort = false;
    return;
  }   
  
  template<class Field>
  void ZeroOne<Field>::_qsort(size_t p, size_t e, int &mode) const
  {
    int i;
    if( (e - p) <= 1) ;
    else 
      {
	i = 1 + _part(p, e, mode);
	_qsort(p, i, mode);
	_qsort(i, e, mode);
      }
  }
  
  template<class Field>
  size_t ZeroOne<Field>::_part(size_t p, size_t e, int &mode) const
  {
    size_t rtemp, ctemp, rowval, colval;
    int i = p + rand() % (e - p), j = e;
    rtemp = _rowP[p];
    ctemp = _colP[p];
    _rowP[p] = _rowP[i];
    _colP[p] = _colP[i];
    _rowP[i] = rtemp;
    _colP[i] = ctemp;
    rowval = _rowP[p];
    colval = _colP[p];
    i = p - 1;
    
    if(mode == 0) 
      { // Row mode, go by row order, then column
	while(true) 
	  {
	    do j--; while( _rowP[j] > rowval || ( _rowP[j] == rowval && _colP[j] > colval ));
	    do i++; while( _rowP[i] < rowval || ( _rowP[i] == rowval && _colP[i] < colval ));
	    if( i < j) 
	      {
		rtemp = _rowP[j];
		ctemp = _colP[j];
		_rowP[j] = _rowP[i];
		_colP[j] = _colP[i];
		_rowP[i] = rtemp;
		_colP[i] = ctemp;
	      }
	    else return j;
	  }
      }
    else 
      { // Col mode, go by col order, then row
	while(true) 
	  {
	    do j--; while( _colP[j] > colval || ( _colP[j] == colval && _rowP[j] > rowval ));
	    do i++; while( _colP[i] < colval || ( _colP[i] == colval && _rowP[i] < rowval ));
	    if( i < j) {
	      rtemp = _rowP[j];
	      ctemp = _colP[j];
	      _rowP[j] = _rowP[i];
	      _colP[j] = _colP[i];
	      _rowP[i] = rtemp;
	      _colP[i] = ctemp;
	    }
	    else return j;
	  }
      }
  }
      
  template<class Field>
  template<class OutVector, class InVector>
  OutVector & ZeroOne<Field>::applySpecialization(OutVector & y, const InVector & x, const NormField& n) const
  {
    //std::cout<<"Call general case\n";
    linbox_check((y.size()==rowdim())&&(x.size()==coldim()));         
    typename OutVector::iterator yp;
    typename InVector::const_iterator xp;
    Index* ip, *jp;
    
    // 0 out y.  Note, this implementation assumes a dense vector.
    for(yp = y.begin(); yp != y.end(); ++yp)
      _F.init(*yp , 0);
    
    rowSort();
    
    yp=y.begin();
    xp=x.begin();
    ip=_rowP;
    jp=_colP;
    size_t rowI =0;
    
    for(; ip <_rowP+nnz(); ++ip,++jp) 
      {       
	if( *ip == rowI)
	  _F.addin(*yp,*(xp + *jp));
	else
	  {
	    if((*ip-rowI)==1)
	      ++yp;
	    else	      
	      yp=y.begin()+*ip;
	    
	    rowI=*ip;
	    _F.addin(*yp,*(xp + *jp));
	  }
      }  
    return y;
  }
  
   
  template<class Field>
  template<class OutVector, class InVector>
  OutVector & ZeroOne<Field>::applySpecialization(OutVector & y, const InVector & x, const Mod32Field& m) const
  {
    //std::cout<<"Called specialization\n";
    linbox_check((y.size()==rowdim())&&(x.size()==coldim()));
    
    typename OutVector::iterator yp;
    typename InVector::const_iterator xp;
    Index* ip, *jp;
        
    for(yp = y.begin(); yp != y.end(); ++yp)
      _F.init(*yp , 0);
    
    rowSort();
    
    yp=y.begin();
    xp=x.begin();
    ip=_rowP;
    jp=_colP;
    size_t rowI =0;
    integer _prime;

    _F.characteristic(_prime);
    
    uint32 prime = static_cast<uint32>(_prime);
    
    uint64 accum =0;
    
    for(; ip <_rowP+nnz(); ++ip,++jp) 
      {       
	if( *ip == rowI)
	  accum=accum+*(xp + *jp);
	else
	  {
	    *yp= accum % prime;
	    if((*ip-rowI)==1)
	      ++yp;
	    else	      
	      yp=y.begin()+*ip;
	    
	    rowI=*ip;	    
	    accum=*(xp+*jp);
	  }
      }
    if(rowI)
      *yp=accum % prime;
    
    return y;
  }
 
  
  template<class Field>
  template<class OutVector, class InVector>
  OutVector & ZeroOne<Field>::applyTransposeSpecialization(OutVector & y, const InVector & x, const NormField& n) const
  {
    //std::cout<<"Call general case\n";
    linbox_check((y.size()==coldim())&&(x.size()==rowdim()));   
    typename OutVector::iterator yp;
    typename InVector::const_iterator xp;
    Index* ip, *jp;
    
    // 0 out y.  Note, this implementation assumes a dense vector.
    for(yp = y.begin(); yp != y.end(); ++yp)
      _F.init(*yp , 0);
    
    rowSort();
    
    yp=y.begin();
    xp=x.begin();
    ip=_rowP;
    jp=_colP;
    size_t rowI =0;
    
    for(; ip <_rowP+nnz(); ++ip,++jp) 
      {       
	if( *ip == rowI)
	  _F.addin(*(yp+*jp),*xp);
	else
	  {
	    if((*ip-rowI)==1)
	      ++xp;
	    else	      
	      xp=x.begin()+*ip;
	    
	    rowI=*ip;
	    _F.addin(*(yp+*jp),*xp);
	  }
      }	
  
    return y;
  }
  
  
  template<class Field>
  template<class OutVector, class InVector>
  OutVector & ZeroOne<Field>::applyTransposeSpecialization(OutVector & y, const InVector & x, const Mod32Field& m) const
  {
    //std::cout<<"Called specialization\n";
    linbox_check((y.size()==coldim())&&(x.size()==rowdim()));
    
    std::vector<uint64> y_c (y.size(),0);
    
    typename OutVector::iterator yp;
    typename InVector::const_iterator xp;
    Index* ip, *jp;      
    
    rowSort();
     
    xp=x.begin();
    ip=_rowP;
    jp=_colP;
    size_t rowI =0;
    std::vector<uint64>::iterator y_cp;
    y_cp=y_c.begin();
    
    for(; ip <_rowP+nnz(); ++ip,++jp) 
      {       
	if( *ip == rowI)
	  *(y_cp+*jp) += *xp;
	else
	  {
	    if((*ip-rowI)==1)
	      ++xp;
	    else	      
	      xp=x.begin()+*ip;
	    
	    rowI=*ip;	    
	    *(y_cp+*jp) += *xp;
	  }
      }
    
    integer _prime;
    _F.characteristic(_prime);    
    uint32 prime = static_cast<uint32>(_prime);
    
    yp=y.begin();
    y_cp=y_c.begin();
    for(;yp!=y.end();++yp,++y_cp)
      *yp = (*y_cp) % prime;
    
    return y;
  }
       
}//End of LinBox