/usr/include/linbox/solutions/getentry.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 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* linbox/solutions/getentry.h
* Evolved from an earlier one by Bradford Hovinen <hovinen@cis.udel.edu>
* -bds
*
* See COPYING for license information.
*/
#ifndef __GETENTRY_H
#define __GETENTRY_H
#include <vector>
#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/blackbox/compose.h"
#include "linbox/blackbox/diagonal.h"
#include "linbox/solutions/methods.h"
namespace LinBox
{
/** \brief
* Getting the i,j entry of the blackbox.
*/
template <class BB>
typename BB::Field::Element& getEntry(typename BB::Field::Element& x, const BB& A, const size_t i, const size_t j)
{ return getEntry(x, A, i, j, Method::Hybrid()); }
// Any BBs that offer a local getEntry 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& getEntry(typename BB::Field::Element& x, const BB& A, const size_t i, const size_t j,
const Method::Hybrid& m)
{ return getEntry(x, A, i, j, Method::Blackbox(m)); }
// DenseMatrix specialization
template <class Field>
typename Field::Element& getEntry(typename Field::Element& x, const DenseMatrix<Field>& A, const size_t i, const size_t j,
const Method::Hybrid& m)
{
return A.getEntry(x,i,j);
}
// SparseMatrix specialization
template <class Field>
typename Field::Element& getEntry(typename Field::Element& x, const SparseMatrix<Field>& A, const size_t i, const size_t j,
const Method::Hybrid& m)
{
return A.getEntry(x,i,j);
}
// scalar matrix specialization
template <class Field>
typename Field::Element & getEntry(typename Field::Element & x, const ScalarMatrix<Field>& A, const size_t i, const size_t j, const Method::Hybrid& m)
{ return A.getEntry(x, i, j); }
// diagonal specialization
template <class Field, class Trait>
typename Field::Element & getEntry(typename Field::Element & x, const Diagonal<Field, Trait>& A, const size_t i, const size_t j, const Method::Hybrid& m)
{ return A.getEntry(x, i, j); }
/** \brief our elimination (a fake in this case)
Elimination method will go to blackbox.
*/
template <class BB>
typename BB::Field::Element& getEntry(typename BB::Field::Element& x, const BB& A, const size_t i, const size_t j, const Method::Elimination& m)
{ return getEntry(x, A, i, j, Method::Blackbox(m));
}
/** Compute the getEntry 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 &getEntry (typename Blackbox::Field::Element &res,
const Blackbox &A, const size_t i, const size_t j,
const Method::Blackbox& m)
{
typedef typename Blackbox::Field Field;
typedef std::vector<typename Field::Element> Vector;
Vector v, w;
VectorWrapper::ensureDim (v, A.coldim ());
VectorWrapper::ensureDim (w, A.rowdim ());
const Field& F = A.field();
typename Field::Element zero; F.init(zero, 0UL);
typename Vector::iterator it;
for (it = v.begin (); it != v.end (); ++it)
F.assign (*it, zero);
F.init(v[j],1UL);
F.init (res, 0);
A.apply (w, v);
F.assign (res, VectorWrapper::constRef<Field, Vector> (w, i));
return res;
}
// Compose< Diagonal, BB > specialization
template <class Field, class Trait, class BlackBox>
typename Field::Element& getEntry(typename Field::Element& t, const Compose<Diagonal<Field, Trait>, BlackBox>& A, const size_t i, const size_t j, const Method::Hybrid& m)
{
typename Field::Element y;
getEntry(y, *(A.getLeftPtr()), i, i);
getEntry(t, *(A.getRightPtr()), i, j);
return A.field().mulin(t, y);
}
// Compose< BB, Diagonal > specialization
template <class BlackBox, class Field, class Trait>
typename Field::Element& getEntry(typename Field::Element& t, const Compose<BlackBox, Diagonal<Field, Trait> >& A, const size_t i, const size_t j, const Method::Hybrid& m)
{
typename Field::Element y;
getEntry(y, *(A.getLeftPtr()), i, j);
getEntry(t, *(A.getRightPtr()), j, j);
return A.field().mulin(t, y);
}
// Compose< Diagonal, Diagonal > specialization
template <class Field, class T1, class T2>
typename Field::Element& getEntry(typename Field::Element& t, const Compose<Diagonal<Field,T1>, Diagonal<Field, T2> >& A, const size_t i, const size_t j, const Method::Hybrid& m)
{
if (i != j)
return A.field().init(t, 0UL);
else {
typename Field::Element y;
getEntry(y, *(A.getLeftPtr()), i, i);
getEntry(t, *(A.getRightPtr()), j, j);
return A.field().mulin(t, y);
}
}
}
#endif // __GETENTRY_H
|