/usr/include/linbox/algorithms/cia.h is in liblinbox-dev 1.3.2-1.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 | /* linbox/algorithms/cia.h
* Copyright(C) LinBox
*
* Written by Clement Pernet <clement.pernet@imag.fr>
*
*
* ========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_cia_H
#define __LINBOX_cia_H
#include "linbox/ring/givaro-polynomial.h"
#include "linbox/field/modular.h"
#include "linbox/randiter/random-prime.h"
#include "linbox/matrix/blas-matrix.h"
#include "linbox/algorithms/blas-domain.h"
#include "linbox/solutions/minpoly.h"
namespace LinBox
{
/*! @ingroup algorithms
* Algorithm computing the integer characteristic polynomial
* of a dense matrix.
*
* @bib [Dumas-Pernet-Wan ISSAC05]
*
*
*/
template < class Polynomial, class Blackbox >
Polynomial& cia (Polynomial & P, const Blackbox & A,
const Method::BlasElimination & M)
{
commentator().start ("Integer Givaro::Dense Charpoly ", "CIA");
typename Blackbox::Field intRing = A.field();
typedef Modular<double> Field;
typedef typename Blackbox::template rebind<Field>::other FBlackbox;
typedef GivPolynomialRing<typename Blackbox::Field, Givaro::Dense> IntPolyDom;
typedef GivPolynomialRing<Field, Givaro::Dense> FieldPolyDom;
typedef typename IntPolyDom::Element IntPoly;
typedef typename FieldPolyDom::Element FieldPoly;
IntPolyDom IPD(intRing);
FieldPoly fieldCharPoly(A.coldim());
/* Computation of the integer minimal polynomial */
IntPoly intMinPoly;
minpoly (intMinPoly, A, RingCategories::IntegerTag(), M);
/* Factorization over the integers */
std::vector<IntPoly*> intFactors;
std::vector<unsigned long> mult;
IPD.factor (intFactors, mult, intMinPoly);
size_t nf = intFactors.size();
/* One modular characteristic polynomial computation */
RandomPrimeIterator primeg (22);
++primeg;
Field F(*primeg);
FBlackbox fbb(F, (int)A.rowdim(), (int)A.coldim());
MatrixHom::map(fbb, A);
charpoly (fieldCharPoly, fbb, M);
/* Determination of the multiplicities */
FieldPolyDom FPD (F);
std::vector<FieldPoly> fieldFactors (nf);
integer tmp_convert; // PG 2005-08-04
for (size_t i = 0; i < nf; ++i){
size_t d= intFactors[i]->size();
fieldFactors[i].resize(d);
for (size_t j = 0; j < d; ++j)
//F.init ((fieldFactors[i])[j], (*intFactors[i])[j]);
F.init ((fieldFactors[i])[j], intRing.convert(tmp_convert,(*intFactors[i])[j]));// PG 2005-08-04
}
FieldPoly currPol = fieldCharPoly;
FieldPoly r,tmp,q;
std::vector<long> multip (nf);
for (size_t i = 0; i < nf; ++i) {
FieldPoly currFact = fieldFactors[i];
r.clear();
int m=0;
q=currPol;
do{
currPol = q;
FPD.divmod (q, r, currPol, currFact);
m++;
} while (FPD.isZero (r));
multip[i] = m-1;
}
IntPoly intCharPoly (A.coldim());
intRing.init (intCharPoly[0], 1);
for (size_t i = 0; i < nf; ++i){
IPD.pow( P, *intFactors[i], multip[i] );
IPD.mulin( intCharPoly, P );
}
for (size_t i = 0; i < nf; ++i)
delete intFactors[i];
commentator().stop ("done", NULL, "CIA");
return P = intCharPoly;
}
}
#endif // __LINBOX_cia_H
// 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:
|