This file is indexed.

/usr/include/linbox/solutions/trace.h 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
/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* linbox/solutions/trace.h
 *  Evolved from an earlier one by Bradford Hovinen <hovinen@cis.udel.edu>
 *  -bds
 *
 * See COPYING for license information.
 */

#ifndef __TRACE_H
#define __TRACE_H

#include <vector>
//#include <algorithm>

// must fix this list...
//#include "linbox/algorithms/wiedemann.h"
//#include "linbox/algorithms/lanczos.h"
//#include "linbox/algorithms/block-lanczos.h"
#include "linbox/util/debug.h"
#include "linbox/vector/vector-domain.h"
#include "linbox/blackbox/dense.h"
#include "linbox/blackbox/sparse.h"
#include "linbox/blackbox/scalar-matrix.h"
#include "linbox/solutions/methods.h"
#include "linbox/solutions/getentry.h"
#include "linbox/blackbox/diagonal.h"
#include "linbox/blackbox/compose.h"

namespace LinBox 
{


/* for trace we actually use only the blackbox method and local defs for sparse,
 dense, and a few other BB types.
*/
/** \brief sum of eigenvalues
 
Also sum of diagonal entries.
This is the generic one.

testing multiple doc comments.
*/
template <class BB> 
typename BB::Field::Element& trace(typename BB::Field::Element& t, const BB& A)
{ return trace(t, A, Method::Hybrid()); }

// Any BBs that offer a local trace can specialize the BB class for the Hybrid method.
/** \brief our best guess

Hybrid method will choose based on matrix size and type
*/

template <class BB> 
typename BB::Field::Element& trace(typename BB::Field::Element& t, const BB& A, 
		const Method::Hybrid& m)
{ return trace(t, A, Method::Blackbox(m)); }

// DenseMatrix specialization
template <class Field> 
typename Field::Element& trace(typename Field::Element& t, const DenseMatrix<Field>& A, 
		const Method::Hybrid& m)
{	typename Field::Element x;
	A.field().init(t, 0);
	for (size_t i = 0; i < A.coldim(); ++i)  {
		A.getEntry(x,i,i);
		A.field().addin(t, x);
	}
	return t;
}

// SparseMatrix specialization
template <class Field, class Row> 
typename Field::Element& trace(typename Field::Element& t, const SparseMatrix<Field, Row>& A, 
		const Method::Hybrid& m)
{	typename Field::Element x;
	A.field().init(t, 0);
	for (size_t i = 0; i < A.coldim(); ++i) { 
		A.getEntry(x,i,i);
		A.field().addin(t, x);
	}
	return t;
}

// Diagonal specialization
template <class Field, class Trait> 
typename Field::Element& trace(typename Field::Element& t, const Diagonal<Field, Trait>& A, 
		const Method::Hybrid& m)
{	typename Field::Element x;
	A.field().init(t, 0);
	for (size_t i = 0; i < A.coldim(); ++i) { 
		A.getEntry(x,i,i);
		A.field().addin(t, x);
	}
	return t;
}

// scalar matrix specialization 
template <class Field>
typename Field::Element & trace(typename Field::Element & t, const ScalarMatrix<Field>& A, const Method::Hybrid& m) 
{ return A.trace(t); }

/** \brief our elimination (a fake in this case)

Elimination method will go to blackbox.
*/
template <class BB> 
typename BB::Field::Element& trace(typename BB::Field::Element& t, const BB& A, const Method::Elimination& m)
{ return trace(t, A, Method::Blackbox(m)); 
}


    /** Compute the trace of a linear operator A, represented as a black
     * box. This class is parameterized by the black box type so that it can
     * be specialized for different black boxes.
     */

template <class Blackbox>
typename Blackbox::Field::Element &trace (typename Blackbox::Field::Element &res,
                                          const Blackbox          &A, 
                                          const Method::Blackbox& m)
{
    
    typedef typename Blackbox::Field Field;
    typedef std::vector<typename Field::Element> Vector;
    Vector v, w;
    Field F = A.field();
    StandardBasisStream<Field, Vector> stream (F, A.coldim ());
    
    VectorWrapper::ensureDim (v, A.coldim ());
    VectorWrapper::ensureDim (w, A.rowdim ());
    
    F.init (res, 0);
    
    while (stream) {
        stream >> v;
        A.apply (w, v);
        F.addin (res, VectorWrapper::constRef<Field, Vector> (w, stream.pos () - 1));
    }
    
    return res;
}


// Compose< Diagonal, BB > specialization
template <class Field, class Trait, class BlackBox> 
typename Field::Element& trace(typename Field::Element& t, const Compose<Diagonal<Field, Trait>, BlackBox>& A, const Method::Hybrid& m)
{
    typename Field::Element x, y;
    A.field().init(t, 0);
    size_t n = (A.coldim()<A.rowdim()?A.coldim():A.rowdim());
    for (size_t i = 0; i < n; ++i) { 
        getEntry(x, *(A.getRightPtr()), i, i);
        getEntry(y, *(A.getLeftPtr()), i, i);
        A.field().axpyin(t, x, y);
    }
    return t;
}

// Compose< BB, Diagonal > specialization
template <class BlackBox, class Field, class Trait> 
typename Field::Element& trace(typename Field::Element& t, const Compose<BlackBox, Diagonal<Field, Trait> >& A, const Method::Hybrid& m)
{
    typename Field::Element x, y;
    A.field().init(t, 0);
    size_t n = (A.coldim()<A.rowdim()?A.coldim():A.rowdim());
    for (size_t i = 0; i < n; ++i) { 
        getEntry(x, *(A.getRightPtr()), i, i);
        getEntry(y, *(A.getLeftPtr()), i, i);
        A.field().axpyin(t, x, y);
    }
    return t;
}


// Compose< Diagonal, Diagonal > specialization
template <class Field, class T1, class T2> 
typename Field::Element& trace(typename Field::Element& t, const Compose<Diagonal<Field,T1>, Diagonal<Field, T2> >& A, const Method::Hybrid& m)
{
    typename Field::Element x, y;
    A.field().init(t, 0);
    size_t n = (A.coldim()<A.rowdim()?A.coldim():A.rowdim());
    for (size_t i = 0; i < n; ++i) { 
        getEntry(x, *(A.getRightPtr()), i, i);
        getEntry(y, *(A.getLeftPtr()), i, i);
        A.field().axpyin(t, x, y);
    }
    return t;
}


}



#endif // __TRACE_H