Debian Codegraph @

examples/det.C

raw
1 /* Copyright (c) FFLAS-FFPACK
2 * ========LICENCE========
3 * This file is part of the library FFLAS-FFPACK.
4 *
5 * FFLAS-FFPACK is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 * ========LICENCE========
19 */
20
21 #include <givaro/modular.h>
22 #include <iostream>
23
24 #include "fflas-ffpack/fflas-ffpack-config.h"
25 #include "fflas-ffpack/fflas-ffpack.h"
26 #include "fflas-ffpack/utils/fflas_io.h"
27
28 /**
29 * This example computes the determinant of a matrix
30 * over a defined finite field.
31 *
32 * Outputs the determinant.
33 */
34 int main(int argc, char** argv)
35 {
36 if (argc != 3) {
37 std::cerr << "Usage: det <p> <matrix>" << std::endl;
38 return -1;
39 }
40
41 int p = atoi(argv[1]);
42 std::string file = argv[2];
43
44 // Creating the finite field Z/qZ
45 Givaro::Modular<double> F(p);
46
47 // Reading the matrix from a file
48 double* A;
49 size_t m, n;
50 FFLAS::ReadMatrix(file.c_str(), F, m, n, A);
51
52 double d;
53 FFPACK::Det(F, d, n, A, n);
54 std::cout << d << std::endl;
55
56 FFLAS::fflas_delete(A);
57
58 return 0;
59 }
60 /* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
61 // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s