/usr/include/linbox/algorithms/triangular-solve-gf2.h is in liblinbox-dev 1.4.2-5build1.
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 | /* ===================================================================
* Copyright(C) LinBox 2008
* Written by Jean-Guillaume Dumas
* Triangular Solve
*
* ========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========
*.
* Time-stamp: <01 Oct 09 15:38:25 Jean-Guillaume.Dumas@imag.fr>
* ===================================================================
*/
#ifndef __LINBOX_tri_solve_gf2_INL
#define __LINBOX_tri_solve_gf2_INL
#include "linbox/vector/vector-domain.h"
#include "linbox/field/gf2.h"
namespace LinBox
{
template <class _Matrix, class Vector1, class Vector2> Vector1&
upperTriangularSolveBinary (Vector1& x,
const _Matrix &U,
const Vector2& b)
{
// linbox_check( x.size() == U.coldim() );
// linbox_check( b.size() == U.rowdim() );
typedef _Matrix Matrix;
typedef GF2 Field;
const GF2 F2;
commentator().start ("Sparse Elimination Upper Triangular Solve over GF(2)", "utrsmGF2");
typename Vector2::const_iterator vec=b.begin();
typename Vector1::iterator res=x.begin();
typename Matrix::const_iterator row=U.begin();
// Find last constrained values of x, U and b
// for( ; (res != x.end()) && (row != U.rowEnd()); ++res, ++row, ++vec) { }
size_t last = x.size();
if( b.size() < last ) last = b.size();
res += (ptrdiff_t)last;
row += (ptrdiff_t)last;
vec += (ptrdiff_t) last;
VectorCategories::DenseZeroOneVectorTag DZOtag;
VectorCategories::SparseZeroOneVectorTag SZOtag;
bool consistant = true;
for(typename Vector2::const_iterator bcheck=vec; bcheck != b.end(); ++bcheck) {
if( ! F2.isZero(*bcheck) ) {
consistant = false;
break;
}
}
if (consistant) {
--vec; --res; --row;
VectorDomain<Field> VD(F2);
for( ; row != U.begin(); --row, --vec, --res) {
F2.assign(*res, F2.zero);
if (row->size()) {
typename Field::Element tmp;
VD.dotSpecialized(tmp, x, *row, DZOtag, SZOtag);
F2.addin(tmp,*vec);
F2.assign(*res,tmp);
}
else {
// Consistency check
if( ! F2.isZero(*vec) ) {
consistant = false;
break;
}
}
}
F2.assign(*res, F2.zero);
if (row->size()) {
typename Field::Element tmp;
VD.dotSpecialized(tmp, x, *row, DZOtag, SZOtag);
F2.addin(tmp,*vec);
F2.assign(*res,tmp);
}
else {
// Consistency check
if( ! F2.isZero(*vec) ) consistant = false;
}
}
// if (! consistant) throw LinboxError ("upperTriangularSolveBinary returned INCONSISTENT");
linbox_check( consistant );
commentator().stop ("done", NULL, "utrsmGF2");
return x;
}
template <class _Matrix, class Vector1, class Vector2> Vector1&
lowerTriangularUnitarySolveBinary (Vector1& x,
const _Matrix &L,
const Vector2& b)
{
linbox_check( b.size() == L.coldim() );
typedef _Matrix Matrix;
const GF2 F2;
commentator().start ("Sparse Elimination Lower Triangular Unitary Solve over GF2", "ltrsmGF2");
typename Vector2::const_iterator vec=b.begin();
typename Vector1::iterator res=x.begin();
typename Matrix::const_iterator row=L.begin();
VectorCategories::DenseZeroOneVectorTag DZOtag;
VectorCategories::SparseZeroOneVectorTag SZOtag;
VectorDomain<GF2> VD(F2);
for( ; row != L.end(); ++row, ++vec, ++res) {
F2.assign(*res, F2.zero);
GF2::Element tmp;
VD.dotSpecialized(tmp, *row, x, SZOtag, DZOtag);
F2.negin(tmp);
F2.addin(tmp,*vec);
F2.assign(*res,tmp);
}
commentator().stop ("done", NULL, "ltrsmGF2");
return x;
}
}
#endif //__LINBOX_tri_solve_gf2_INL
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,:0,t0,+0,=s
// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
|