/usr/include/linbox/algorithms/gauss.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 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 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* linbox/algorithms/gauss.h
* Copyright (C) 1999 Jean-Guillaume Dumas
*
* Written by Jean-Guillaume Dumas <Jean-Guillaume.Dumas@imag.fr>
*
* -----------------------------------------------------------
* 2003-02-02 Bradford Hovinen <bghovinen@math.uwaterloo.ca>
*
* Ported to new matrix archetype; update interface to meet current
* standards. Rename gauss_foo as foo and gauss_Uin as upperin
*
* Move function definitions to gauss.inl
* -----------------------------------------------------------
*
* See COPYING for license information.
*/
// ========================================================================= //
// (C) The Linbox Group 1999
// Calcul de rang par la méthode de Gauss pivot par ligne, sur matrice creuse
// Time-stamp: <03 Nov 00 19:19:06 Jean-Guillaume.Dumas@imag.fr>
// ========================================================================= //
#ifndef __GAUSS_H
#define __GAUSS_H
#include "linbox/util/debug.h"
#include "linbox/util/commentator.h"
#include "linbox/field/archetype.h"
#include "linbox/vector/vector-domain.h"
#include "linbox/matrix/matrix-domain.h"
#include "linbox/matrix/archetype.h"
#include "linbox/solutions/methods.h"
namespace LinBox
{
/** \brief Repository of functions for rank by elimination on sparse matrices.
Several versions allow for adjustment of the pivoting strategy
and for choosing in-place elimination or for not modifying the input matrix.
Also an LU interface is offered.
*/
template <class _Field>
class GaussDomain {
public:
typedef _Field Field;
typedef typename Field::Element Element;
private:
const Field &_F;
public:
/** \brief The field parameter is the domain
* over which to perform computations
*/
GaussDomain (const Field &F) : _F (F) {}
//Copy constructor
///
GaussDomain (const GaussDomain &M) : _F (M._F) {}
/** accessor for the field of computation
*/
const Field &field () { return _F; }
/** @name rank
Callers of the different rank routines\\
-/ The "in" suffix indicates in place computation\\
-/ Without Ni, Nj, the Matrix parameter must be a vector of sparse
row vectors, NOT storing any zero.\\
-/ Calls {@link rankinLinearPivoting rankinLinearPivoting} (by default) or {@link rankinNoReordering rankinNoReordering}
*/
//@{
///
template <class Matrix> unsigned long& rankin(unsigned long &rank,
Matrix &A,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
///
template <class Matrix> unsigned long& rankin(unsigned long &rank,
Matrix &A,
unsigned long Ni,
unsigned long Nj,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
///
template <class Matrix> unsigned long& rank(unsigned long &rank,
const Matrix &A,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
///
template <class Matrix> unsigned long& rank(unsigned long &rank,
const Matrix &A,
unsigned long Ni,
unsigned long Nj,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
//@}
/** @name det
Callers of the different determinant routines\\
-/ The "in" suffix indicates in place computation\\
-/ Without Ni, Nj, the Matrix parameter must be a vector of sparse
row vectors, NOT storing any zero.\\
-/ Calls {@link LinearPivoting } (by default) or {@link NoReordering}
*/
//@{
///
template <class Matrix> Element& detin(Element &determinant,
Matrix &A,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
///
template <class Matrix> Element& detin(Element &determinant,
Matrix &A,
unsigned long Ni,
unsigned long Nj,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
///
template <class Matrix> Element& det(Element &determinant,
const Matrix &A,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
///
template <class Matrix> Element& det(Element &determinant,
const Matrix &A,
unsigned long Ni,
unsigned long Nj,
SparseEliminationTraits::PivotStrategy reord = SparseEliminationTraits::PIVOT_LINEAR);
//@}
/** \brief Sparse in place Gaussian elimination with reordering to reduce fill-in.
pivots are chosen in sparsest column of sparsest row.
This runs in linear overhead.
It is similar in spirit but different from Markovitz' approach.
<pre>
Using : SparseFindPivot(..., density) for sparsest column, and
eliminate (..., density)
</pre>
The Matrix parameter must meet the LinBox sparse matrix interface.
[check details].
The computedet indicates whether the algorithm must compute the determionant as it goes
@ref [Jean-Guillaume Dumas and Gilles Villard,
Computing the rank of sparse matrices over finite fields.
In Ganzha et~al. CASC'2002, pages 47--62.]
*/
template <class Matrix>
unsigned long& InPlaceLinearPivoting (unsigned long &rank,
Element& determinant,
Matrix &A,
unsigned long Ni,
unsigned long Nj);
/** \brief Sparse Gaussian elimination without reordering.
Gaussian elimination is done on a copy of the matrix.
Using : SparseFindPivot
eliminate
Requirements : SLA is an array of sparse rows
WARNING : NOT IN PLACE, THERE IS A COPY.
Without reordering (Pivot is first non-zero in row)
*/
template <class Matrix>
unsigned long& NoReordering (unsigned long &rank, Element& determinant, Matrix &LigneA, unsigned long Ni, unsigned long Nj);
/** \brief Dense in place LU factorization without reordering
Using : FindPivot and LU
*/
template <class Matrix>
unsigned long &LUin (unsigned long &rank, Matrix &A);
/** \brief Dense in place Gaussian elimination without reordering
Using : FindPivot and LU
*/
template <class Matrix>
unsigned long &upperin (unsigned long &rank, Matrix &A);
protected:
//-----------------------------------------
// Sparse elimination using a pivot row :
// lc <-- lc - lc[k]/lp[0] * lp
// D is the number of elements per column
// it is updated and used for reordering
// Vector is a vector of Pair (lin_pair.h)
//-----------------------------------------
template <class Vector, class D>
void eliminate (Vector &lignecourante,
const Vector &lignepivot,
const unsigned long &indcol,
const long &indpermut,
D &columns);
//-----------------------------------------
// Sparse elimination using a pivot row :
// lc <-- lc - lc[k]/lp[0] * lp
// No density update
// Vector is a vector of Pair (lin_pair.h)
//-----------------------------------------
template <class Vector>
void eliminate (Vector &lignecourante,
const Vector &lignepivot,
const unsigned long &indcol,
const long &indpermut);
//-----------------------------------------
// Dense elimination using a pivot row :
// lc <-- lc - lc[k]/lp[0] * lp
// Computing only for k to n (and not 0 to n in LU)
//-----------------------------------------
template<class Vector>
void Upper (Vector &lignecur,
const Vector &lignepivot,
unsigned long indcol,
long indpermut);
//-----------------------------------------
// Dense elimination using a pivot row :
// lc <-- lc - lc[k]/lp[0] * lp
//-----------------------------------------
template <class Vector>
void LU (Vector &lignecur,
const Vector &lignepivot,
unsigned long indcol,
long indpermut);
//------------------------------------------
// Looking for a non-zero pivot in a row
// Using the column density for reordering
// Pivot is chosen as to :
// 1. Row density is minimum
// 2. Column density is minimum for this row
//------------------------------------------
template <class Vector, class D>
void SparseFindPivot (Vector &lignepivot, unsigned long &indcol, long &indpermut, D &columns, Element& determinant);
//------------------------------------------
// Looking for a non-zero pivot in a row
// No reordering
//------------------------------------------
template <class Vector>
void SparseFindPivot (Vector &lignepivot, unsigned long &indcol, long &indpermut, Element& determinant);
//------------------------------------------
// Looking for a non-zero pivot in a row
// Dense search
//------------------------------------------
template <class Vector>
void FindPivot (Vector &lignepivot, unsigned long &k, long &indpermut);
};
} // namespace LinBox
#include "linbox/algorithms/gauss.inl"
#endif // __GAUSS_H
|