/usr/include/fflas-ffpack/checkers/checker_pluq.inl 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | /* -*- mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
// vim:sts=4:sw=4:ts=4:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/* checkers/checker_pluq.inl
* Copyright (C) 2016 Jean-Guillaume Dumas
*
* Written by Ashley Lesdalons <Ashley.Lesdalons@e.ujf-grenoble.fr>
* Jean-Guillaume Dumas <Jean-Guillaume.Dumas@imag.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========
*.
*/
#ifndef __FFLASFFPACK_checker_pluq_INL
#define __FFLASFFPACK_checker_pluq_INL
#include "fflas-ffpack/ffpack/ffpack.h"
#ifdef TIME_CHECKER_PLUQ
#include <givaro/givtimer.h>
#endif
namespace FFPACK {
template <class Field>
class CheckerImplem_PLUQ {
const Field& F;
typename Field::Element_ptr v,w;
const size_t m,n;
#ifdef TIME_CHECKER_PLUQ
Givaro::Timer _time;
#endif
public:
CheckerImplem_PLUQ(const Field& F_, size_t m_, size_t n_,
typename Field::ConstElement_ptr A, size_t lda)
: F(F_),
v(FFLAS::fflas_new(F_,n_,1)),
w(FFLAS::fflas_new(F_,m_,1)),
m(m_), n(n_)
{
typename Field::RandIter G(F);
init(G,A,lda);
}
CheckerImplem_PLUQ(typename Field::RandIter &G, size_t m_, size_t n_,
typename Field::ConstElement_ptr A, size_t lda)
: F(G.ring()),
v(FFLAS::fflas_new(F,n_,1)),
w(FFLAS::fflas_new(F,m_,1)),
m(m_), n(n_)
{
init(G,A,lda);
}
~CheckerImplem_PLUQ() {
FFLAS::fflas_delete(v,w);
}
/** check if the PLUQ factorization is correct.
* Returns true if w - P(L(U(Q.v))) == 0
* @param A
* @param r
* @param P
* @param Q
*/
inline bool check(typename Field::ConstElement_ptr A, size_t lda,
size_t r, size_t *P, size_t *Q) {
#ifdef TIME_CHECKER_PLUQ
Givaro::Timer checktime; checktime.start();
#endif
// _w = [w1|w2]
typename Field::Element_ptr _w = FFLAS::fflas_new(F,m,1);
// v <-- Q.v
FFPACK::applyP(F, FFLAS::FflasLeft, FFLAS::FflasNoTrans, 1, 0, r, v, 1, Q);
// w1 <- V1 && w2 <- 0
FFLAS::fassign(F, r, 1, v, 1, _w, 1);
FFLAS::fzero(F, m-r, _w+r, 1);
// w1 <- U1.w1
// WARNING: should be ftrmv
FFLAS::ftrmm(F, FFLAS::FflasLeft, FFLAS::FflasUpper, FFLAS::FflasNoTrans, FFLAS::FflasNonUnit, r, 1, F.one, A, lda, _w, 1);
// w1 <- U2.V2 + w1
if (r < n)
FFLAS::fgemm(F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans, r, 1, n-r, F.one, A+r, lda, v+r, 1, F.one, _w, 1);
// w2 <- L2.w1
if (r < m)
FFLAS::fgemm(F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans, m-r, 1, r, F.one, A+r*n, lda, _w, 1, F.zero, _w+r, 1);
// w1 <- L1.w1
// WARNING: should be ftrmv
FFLAS::ftrmm(F, FFLAS::FflasLeft, FFLAS::FflasLower, FFLAS::FflasNoTrans, FFLAS::FflasUnit, r, 1, F.one, A, lda, _w, 1);
// _w <- P._w
FFPACK::applyP(F, FFLAS::FflasRight, FFLAS::FflasNoTrans, 1, 0, r, _w, 1, P);
// is _w == w ?
FFLAS::fsubin(F, m, w, 1, _w, 1);
bool pass = FFLAS::fiszero(F,m,_w,1);
FFLAS::fflas_delete(_w);
if (!pass) throw FailurePLUQCheck();
#ifdef TIME_CHECKER_PLUQ
checktime.stop(); _time += checktime;
std::cerr << "PLUQ CHECK: " << _time << std::endl;
#endif
return pass;
}
private:
inline void init(typename Field::RandIter &G,
typename Field::ConstElement_ptr A, size_t lda) {
#ifdef TIME_CHECKER_PLUQ
Givaro::Timer inittime; inittime.start();
#endif
FFLAS::frand(F,G,n,v,1);
// w <-- A.v
FFLAS::fgemv(F, FFLAS::FflasNoTrans, m, n, F.one, A, lda, v, 1, F.zero, w, 1);
#ifdef TIME_CHECKER_PLUQ
inittime.stop(); _time += inittime;
#endif
}
};
}
#endif // __FFLASFFPACK_checker_pluq_INL
|