Debian Codegraph @

tutorials/2x2-pluq.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 <iostream>
22 #include <vector>
23 #include <givaro/modular.h>
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 using namespace std;
29
30 int main(int argc, char** argv) {
31
32 if (argc > 2){
33 std::cerr<<"Usage: 2x2-pluq <p>"<<std::endl;
34 return -1;
35 }
36
37 int64_t p = (argc>1?atoi(argv[1]):5);
38 // Creating the finite field Z/pZ
39 Givaro::Modular<double> F(p);
40
41 size_t m(2),n(2);
42 double A[4] {1,2,3,4};
43 FFLAS::WriteMatrix (std::cout<<"A = "<<std::endl,F,m,n,A,n);
44
45 size_t * P = FFLAS::fflas_new<size_t>(m);
46 size_t * Q = FFLAS::fflas_new<size_t>(n);
47
48 FFPACK::PLUQ (F, FFLAS::FflasNonUnit, m, n, A, n, P, Q);
49
50 FFLAS::WritePermutation(std::cout<<"P = "<<std::endl,P,m);
51 FFLAS::WriteMatrix (std::cout<<"LU = "<<std::endl,F,m,n,A,n)<< " modulo " << p << std::endl;
52 FFLAS::WritePermutation(std::cout<<"Q = "<<std::endl,Q,n);
53
54 FFLAS::fflas_delete( P);
55 FFLAS::fflas_delete( Q);
56
57 return 0;
58 }
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