Skip to content

Commit 4ff828e

Browse files
committed
incompatible const & with modifiers
1 parent 27811e0 commit 4ff828e

3 files changed

Lines changed: 100 additions & 3 deletions

File tree

examples/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SUBDIRS=data
2929

3030
EXAMPLES=rank det minpoly valence solve dot-product echelon sparseelimdet \
3131
sparseelimrank checksolve doubledet smithvalence charpoly blassolve solverat \
32-
sparsesolverat poweroftwo_ranks power_rank genprime smithsparse matrices
32+
ratdet sparsesolverat poweroftwo_ranks power_rank genprime smithsparse matrices
3333
#polysmith bench-fft bench-matpoly-mult
3434
# EXAMPLES+=nulp yabla
3535
GIVARONTL_EXAMPLES=smith graph-charpoly
@@ -66,6 +66,7 @@ smithvalence_SOURCES = smithvalence.C
6666
sparseelimdet_SOURCES = sparseelimdet.C
6767
sparseelimrank_SOURCES = sparseelimrank.C
6868
solverat_SOURCES = solverat.C
69+
ratdet_SOURCES = ratdet.C
6970
sparsesolverat_SOURCES = sparsesolverat.C
7071
blassolve_SOURCES = blassolve.C
7172
power_rank_SOURCES = power_rank.C

examples/ratdet.C

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* examples/ratdet.C
3+
*
4+
* Copyright (C) 2020 The LinBox group
5+
* ========LICENCE========
6+
* This file is part of the library LinBox.
7+
*
8+
* LinBox is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; either
11+
* version 2.1 of the License, or (at your option) any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public
19+
* License along with this library; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
* ========LICENCE========
22+
*/
23+
24+
/**\file examples/ratdet.C
25+
* @example examples/ratdet.C
26+
\brief Determinant of rational matrix
27+
\ingroup examples
28+
*/
29+
30+
#include <linbox/linbox-config.h>
31+
#include <iostream>
32+
33+
#include <givaro/givrational.h>
34+
#include <linbox/matrix/sparse-matrix.h>
35+
#include <linbox/solutions/det.h>
36+
37+
using namespace LinBox;
38+
typedef SparseMatrixFormat::SparseSeq SparseStorage;
39+
typedef Givaro::QField<Givaro::Rational> Rationals;
40+
41+
template<typename RMatrix>
42+
int ratdet(int argc, char **argv) {
43+
44+
std::ifstream input (argv[1]);
45+
if (!input) {
46+
std::cerr << "Error opening matrix file: " << argv[1] << std::endl;
47+
return -1;
48+
}
49+
50+
Rationals QQ;
51+
MatrixStream<Rationals> ms (QQ, input);
52+
RMatrix A ( ms );
53+
54+
Rationals::Element det_A;
55+
56+
LinBox::Timer tim ; tim.clear() ; tim.start();
57+
det (det_A, A);
58+
tim.stop();
59+
60+
std::cout << "Determinant is ";
61+
QQ.write(std::cout, det_A) << ':' << std::flush;
62+
std::clog << tim << std::endl;
63+
64+
return 0;
65+
}
66+
67+
68+
int main (int argc, char **argv)
69+
{
70+
commentator().setMaxDetailLevel (-1);
71+
commentator().setMaxDepth (-1);
72+
commentator().setReportStream (std::cerr);
73+
74+
bool dense=true;
75+
if (argc < 2 || argc > 3) {
76+
std::cerr << "Usage: ratdet <matrix-file-in-supported-format> [d/s]" << std::endl;
77+
return -1;
78+
}
79+
80+
if (argc == 3) {
81+
if (argv[2][0] != 'd') dense=false;
82+
}
83+
84+
if (dense)
85+
return ratdet< DenseMatrix<Rationals> >(argc,argv);
86+
else
87+
return ratdet< SparseMatrix<Rationals, SparseStorage> >(argc, argv);
88+
}
89+
90+
// Local Variables:
91+
// mode: C++
92+
// tab-width: 4
93+
// indent-tabs-mode: nil
94+
// c-basic-offset: 4
95+
// End:
96+
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s

linbox/algorithms/det-rational.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ namespace LinBox
7979
struct MyRationalModularDet {
8080
const Blackbox &A;
8181
const MyMethod &M;
82-
const Integer &mul;//multiplicative prec;
83-
const Integer &div;
82+
Integer mul;//multiplicative prec;
83+
Integer div;
8484

8585
MyRationalModularDet(const Blackbox& b, const MyMethod& n,
8686
const Integer & p1, const Integer & p2) :

0 commit comments

Comments
 (0)