This file is indexed.

/usr/include/fflas-ffpack/fflas/fflas_sparse/utils.h is in fflas-ffpack-common 2.2.2-5.

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
/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/*
 * Copyright (C) 2014 the FFLAS-FFPACK group
 *
 * Written by   Bastien Vialla <bastien.vialla@lirmm.fr>
 *
 *
 * ========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========
 *.
 */

/** @file fflas/fflas_sparse.h
*/

#ifndef __FFLASFFPACK_fflas_fflas_sparse_utils_H
#define __FFLASFFPACK_fflas_fflas_sparse_utils_H

#include <algorithm>
#include <numeric>
#include <vector>

namespace FFLAS{

struct StatsMatrix {
    uint64_t rowdim = 0;
    uint64_t coldim = 0;
    uint64_t nOnes = 0;
    uint64_t nMOnes = 0;
    uint64_t nOthers = 0;
    uint64_t nnz = 0;
    uint64_t maxRow = 0;
    uint64_t minRow = 0;
    uint64_t averageRow = 0;
    uint64_t deviationRow = 0;
    uint64_t maxCol = 0;
    uint64_t minCol = 0;
    uint64_t averageCol = 0;
    uint64_t deviationCol = 0;
    uint64_t minColDifference = 0;
    uint64_t maxColDifference = 0;
    uint64_t averageColDifference = 0;
    uint64_t deviationColDifference = 0;
    uint64_t minRowDifference = 0;
    uint64_t maxRowDifference = 0;
    uint64_t averageRowDifference = 0;
    uint64_t deviationRowDifference = 0;
    uint64_t nDenseRows = 0;
    uint64_t nDenseCols = 0;
    uint64_t nEmptyRows = 0;
    uint64_t nEmptyCols = 0;
    uint64_t nEmptyColsEnd = 0;
    std::vector<uint64_t> denseRows;
    std::vector<uint64_t> denseCols;
};

template <class It> double computeDeviation(It begin, It end) {
    using T = typename std::decay<decltype(*begin)>::type;
    T average = 0;
    average = std::accumulate(begin, end, 0) / (end - begin);
    T sum = 0;
    for (It i = begin; i != end; ++i) {
        sum += ((*(i)) - average) * ((*(i)) - average);
    }
    return std::sqrt(sum / (end - begin));
}

template <class Field>
StatsMatrix getStat(const Field &F, const index_t *row, const index_t *col, typename Field::ConstElement_ptr val,
              uint64_t rowdim, uint64_t coldim, uint64_t nnz) {
    StatsMatrix stats;
    stats.nnz = nnz;
    stats.rowdim = rowdim;
    stats.coldim = coldim;
    std::vector<int64_t> rows(rowdim+1);
    std::vector<int64_t> cols(coldim);
    std::fill(rows.begin(), rows.end(), 0);
    std::fill(cols.begin(), cols.end(), 0);
    for (uint64_t i = 0; i < nnz; ++i) {
        cols[col[i]]++;
        if (F.isOne(val[i])) {
            stats.nOnes++;
        } else if (F.isMOne(val[i])) {
            stats.nMOnes++;
        } else {
            stats.nOthers++;
        }
    }
    rows[0] = row[0];
    for(size_t i = 1 ; i < rowdim+1 ; ++i){
        rows[i] = row[i] - row[i-1];
    }
    stats.nEmptyRows = std::count(rows.begin(), rows.end(), 0);
    stats.nEmptyCols = std::count(cols.begin(), cols.end(), 0);
    auto rowMinMax = std::minmax_element(rows.begin(), rows.end());
    auto colMinMax = std::minmax_element(cols.begin(), cols.end());
    stats.minRow = (*(rowMinMax.first));
    stats.maxRow = (*(rowMinMax.second));
    stats.minCol = (*(colMinMax.first));
    stats.maxCol = (*(colMinMax.second));
    stats.averageRow = std::accumulate(rows.begin(), rows.end(), 0) / rowdim;
    stats.averageCol = std::accumulate(cols.begin(), cols.end(), 0) / coldim;
    stats.deviationRow = (uint64_t)computeDeviation(rows.begin(), rows.end());
    stats.deviationCol = (uint64_t)computeDeviation(cols.begin(), cols.end());
    stats.nDenseRows = std::count_if(rows.begin(), rows.begin(),
                                     [rowdim](uint64_t &x) { return x >= DENSE_THRESHOLD * rowdim; });
    stats.nDenseCols = std::count_if(cols.begin(), cols.begin(),
                                     [coldim](uint64_t &x) { return x >= DENSE_THRESHOLD * coldim; });
    return stats;
}

}

#endif