File: test-compressQ.C

package info (click to toggle)
fflas-ffpack 2.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,200 kB
  • sloc: cpp: 26,712; makefile: 784; sh: 430; csh: 95; ansic: 20
file content (118 lines) | stat: -rw-r--r-- 3,552 bytes parent folder | download | duplicates (3)
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
/*
 * Copyright (C) FFLAS-FFPACK
 * Written by Clément Pernet
 * This file is Free Software and part of FFLAS-FFPACK.
 *
 * ========LICENCE========
 * This file is part of the library FFLAS-FFPACK.
 *
 * FFLAS-FFPACK 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========
 *.
 */


//--------------------------------------------------------------------------
//          Test for the krylov-elimination
//--------------------------------------------------------------------------
// usage: test-krylov-elim p A, to compute the rank profile of the (n+m)xn matrix B
// formed by the n identity vectors and the mxn matrix A over Z/pZ
//-------------------------------------------------------------------------

//-------------------------------------------------------------------------

#include "fflas-ffpack/fflas-ffpack-config.h"
#include <iostream>
#include <list>
#include <vector>
#include <givaro/modular-balanced.h>

#include "fflas-ffpack/utils/timer.h"
#include "fflas-ffpack/ffpack/ffpack.h"
#include "fflas-ffpack/utils/args-parser.h"

using namespace std;
typedef Givaro::Modular<double> Field;

//! @bug does not belong here
template<class T>
std::ostream& printvect(std::ostream& o, vector<T>& vect){
    for(size_t i=0; i < vect.size(); ++i)
        o << vect[i] << " " ;
    return o << std::endl;
}

int main(int argc, char** argv)
{


    static Argument as[] = {
        END_OF_ARGUMENTS
    };

    FFLAS::parseArguments(argc,argv,as);

    // int m,n;

    Field F(65521);
    size_t N = 17;
    double * A = FFLAS::fflas_new<double>(N*N);
    double * tmp = FFLAS::fflas_new<double>(N*N);
    size_t * deg = FFLAS::fflas_new<size_t>(N);

    for (size_t i=0; i<(size_t)N*N; ++i)
        A[i] = 0;
    for (size_t i=0; i<3; ++i)
        A[i+i*N] = 1;

    for (size_t i=3; i<6; ++i)
        A[i+1+i*N] = 1;
    for (size_t i=6; i<9; ++i)
        A[i+2+i*N] = 1;

    A[12+9*N] = 1;
    A[13+10*N] = 1;
    A[14+12*N] = 1;
    A[15+15*N] = 1;
    A[16+16*N] = 1;
    deg[0]  = 4; deg[1] = 4; deg[2] = 4;deg[3] = 2; deg[4] = 1; deg[5] =2;
    for (size_t i=0; i<size_t(N); ++i)
        A[11+i*N] = A[7+i*N] = A[3+i*N] = double(i % 10);

    double * B = FFLAS::fflas_new<double>(N*N) ;
    FFLAS::fassign(F,N*N,A,1,B,1);

    FFPACK::Protected::CompressRowsQK (F, N, A+9*N, N, tmp, N, deg+3, 4, 3 );

    FFPACK::Protected::DeCompressRowsQK (F, N, N-9, A+9*N, N, tmp, N, deg+3, 4, 3 );

    int ok = 0 ;
    for (size_t i = 0 ; i < (size_t)N * (size_t)N ; ++i)
        if (A[i] != B[i])
        {
            ok = 1 ;
            break ;
        }

    FFLAS::fflas_delete( A );
    FFLAS::fflas_delete( tmp) ;
    FFLAS::fflas_delete(deg) ;
    FFLAS::fflas_delete(  B );

    return ok ;

}
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s