This file is indexed.

/usr/include/linbox/blackbox/inverse.h is in liblinbox-dev 1.4.2-3.

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
/* linbox/blackbox/inverse.h
 * Copyright (C) 2001 Bradford Hovinen
 *
 * Written by Bradford Hovinen <hovinen@cis.udel.edu>
 *
 * ========LICENCE========
 * This file is part of the library LinBox.
 *
  * LinBox is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

#ifndef __LINBOX_inverse_H
#define __LINBOX_inverse_H

#include "linbox/blackbox/blackbox-interface.h"
#include "linbox/blackbox/transpose.h"
#include "linbox/vector/vector-domain.h"
#include "linbox/solutions/minpoly.h"
#include "linbox/vector/vector-traits.h"

// Namespace in which all LinBox library code resides
namespace LinBox
{

	/** \brief A Blackbox for the inverse.  Not efficient if many applications are used.
	 * \ingroup blackbox
	 *
	 * The matrix itself is not stored in memory.  Rather, its apply
	 * methods use a vector of @link Fields field@endlink elements, which are
	 * used to "multiply" the matrix to a vector.
	 *
	 * This class has three template parameters.  The first is the field in
	 * which the arithmetic is to be done.  The second is the type of
	 * \ref LinBox vector to which to apply the matrix.  The
	 * third is chosen be default to be the \ref LinBox vector trait
	 * of the vector.  This class is then specialized for dense and sparse
	 * vectors.
	 *
	 * @param Field \ref LinBox field
	 * @param Vector \ref LinBox dense or sparse vector of field elements
	 * @param Trait  Marker whether to use dense or sparse LinBox vector
	 *               implementation.  This is chosen by a default parameter
	 *               and partial template specialization.  */
	template <class Blackbox>
	class Inverse : public BlackboxInterface {
	public:

		typedef typename Blackbox::Field Field;
		typedef typename Field::Element   Element;
		typedef BlasVector<Field>      Polynomial;

		/** Constructor from field and dense vector of field elements.
		 * @param BB   Black box of which to get the inverse
		 */
		Inverse (const Blackbox *BB) :
			_VD (BB->field()), _BB (BB)
			, _minpoly(BB->field())
			, _transposeMinpoly(BB->field())
			, _z(BB->field())
		{
			linbox_check ((BB->rowdim ()) == (BB->coldim ()));

			_minpoly.clear ();
			_transposeMinpoly.clear ();

			VectorWrapper::ensureDim (_z, _BB->coldim ());
		}

		/** Copy constructor, so that we don't have to recompute the
		 * minimal polynomial every time this black box is used inside
		 * another black box
		 */
		Inverse (const Inverse &BB) :
			_VD (BB->field()), _BB (BB._BB)
			, _minpoly (BB._minpoly)
			, _z(BB->field())
			, _transposeMinpoly(BB->field())

		{
			_z.resize (_BB->coldim ());
		}


		/** Application of BlackBox matrix.
		 * y= A*x.
		 * Requires one vector conforming to the \ref LinBox
		 * vector @link Archetypes archetype@endlink.
		 * Required by abstract base class.
		 * @return reference to vector y containing output.
		 * @param  y reference to vector into which to store the result
		 * @param  x constant reference to vector to contain input
		 */
		template<class OutVector, class InVector>
		OutVector& apply (OutVector &y, const InVector& x) const
		{
			int i;

			if (_minpoly.empty ()) {
				Polynomial _mp1(field());
				Element a0;

				minpoly (_mp1, *_BB);

				_minpoly.resize (_mp1.size () - 1);

				field().inv (a0, _mp1[0]);
				field().negin (a0);

				for (i = 1; i < (int) _mp1.size (); i++)
					field().mul (_minpoly[(size_t)i-1], _mp1[(size_t)i], a0);
			}

			int n = (int) _minpoly.size () - 1;

			_VD.mul (y, x, _minpoly[(size_t)n]);

			for (i = n - 1; i >= 0; i--) {
				_BB->apply (_z, y);
				_VD.axpy (y, _minpoly[(size_t)i], x, _z);
			}

			return y;
		}

		/** Application of BlackBox matrix transpose.
		 * \f$ y= A^t \cdot  x.\f$
		 * Requires one vector conforming to the \ref LinBox
		 * vector @link Archetypes archetype@endlink.
		 * Required by abstract base class.
		 * @return reference to vector y containing output.
		 * @param  x constant reference to vector to contain input
		 * @param y
		 */
		template<class OutVector, class InVector>
		OutVector& applyTranspose (OutVector &y, const InVector& x) const
		{
			int i;

			if (_transposeMinpoly.empty ()) {
				Polynomial _mp1(field());
				Element a0;

				Transpose<Blackbox> BBT (_BB);

				minpoly (_mp1, BBT);

				_transposeMinpoly.resize (_mp1.size () - 1);

				field().inv (a0, _mp1[0]);
				field().negin (a0);

				for (i = 1; i < (int) _mp1.size (); i++)
					field().mul (_transposeMinpoly[(size_t)i-1], _mp1[(size_t)i], a0);
			}

			int n = (int) _transposeMinpoly.size () - 1;

			_VD.mul (y, x, _transposeMinpoly[(size_t)n]);

			for (i = n - 1; i >= 0; i--) {
				_BB->applyTranspose (_z, y);
				_VD.axpy (y, _transposeMinpoly[(size_t)i], x, _z);
			}

			return y;
		}

		template<typename _Tp1>
		struct rebind
		{ typedef Inverse<typename Blackbox::template rebind<_Tp1>::other> other; };


		/** Retreive row dimensions of BlackBox matrix.
		 * This may be needed for applying preconditioners.
		 * Required by abstract base class.
		 * @return integer number of rows of black box matrix.
		 */
		size_t rowdim (void) const
		{
			return _BB->rowdim ();
		}

		/** Retreive column dimensions of BlackBox matrix.
		 * Required by abstract base class.
		 * @return integer number of columns of black box matrix.
		 */
		size_t coldim(void) const
		{
			return _BB->coldim ();
		}

		const Field& field() const
		{ return _BB->field();}
	protected:

		const VectorDomain<Field>  _VD;
		const Blackbox             *_BB;

		mutable Polynomial         _minpoly;
		mutable Polynomial         _transposeMinpoly;

		// Temporary for reducing necessary memory allocation
		mutable Polynomial         _z;

	};

} // namespace LinBox

#endif // __LINBOX_inverse_H


// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,:0,t0,+0,=s