/usr/include/fflas-ffpack/ffpack/ffpack_invert.inl is in fflas-ffpack-common 2.2.2-4.
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 | /* -*- 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
/*
* Copyright (C) 2014 FFLAS-FFACK group
*
* Written by Clement Pernet <Clement.Pernet@imag.fr>
* Brice Boyer (briceboyer) <boyer.brice@gmail.com>
*
*
* ========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_ffpack_invert_INL
#define __FFLASFFPACK_ffpack_invert_INL
namespace FFPACK {
template <class Field>
typename Field::Element_ptr
Invert (const Field& F, const size_t M,
typename Field::Element_ptr A, const size_t lda,
int& nullity)
{
FFLASFFPACK_check(lda >= M);
Checker_invert<Field> checker(F,M,A,lda);
if (M == 0) {
nullity = 0 ;
return NULL ;
}
size_t * P = FFLAS::fflas_new<size_t>(M);
size_t * Q = FFLAS::fflas_new<size_t>(M);
size_t R = ReducedColumnEchelonForm (F, M, M, A, lda, P, Q, true);
nullity = (int)(M - R);
applyP (F, FFLAS::FflasLeft, FFLAS::FflasTrans,
M, 0, (int)R, A, lda, P);
delete [] P;
delete [] Q;
checker.check(A,nullity);
return A;
}
template <class Field>
typename Field::Element_ptr
Invert (const Field& F, const size_t M,
typename Field::ConstElement_ptr A, const size_t lda,
typename Field::Element_ptr X, const size_t ldx,
int& nullity)
{
FFLASFFPACK_check(lda >= M);
FFLASFFPACK_check(ldx >= M);
if (M == 0) {
nullity = 0 ;
return NULL ;
}
FFLAS::fassign(F,M,M,A,lda,X,ldx);
Invert (F, M, X, ldx, nullity);
return X;
}
template <class Field>
typename Field::Element_ptr
Invert2( const Field& F, const size_t M,
typename Field::Element_ptr A, const size_t lda,
typename Field::Element_ptr X, const size_t ldx,
int& nullity)
{
FFLASFFPACK_check(lda >= M);
FFLASFFPACK_check(ldx >= M);
if (M == 0) {
nullity = 0 ;
return NULL ;
}
size_t *P = FFLAS::fflas_new<size_t>(M);
size_t *rowP = FFLAS::fflas_new<size_t>(M);
nullity = int(M - LUdivine( F, FFLAS::FflasNonUnit, FFLAS::FflasNoTrans, M, M, A, lda, P, rowP));
if (nullity > 0){
FFLAS::fflas_delete( P);
FFLAS::fflas_delete( rowP);
return NULL;
}
else {
// Initializing X to 0
#if 0/* timer remnants */
t1.clear();
t1.start();
#endif
//! @todo this init is not all necessary (done after ftrtri)
FFLAS::fzero(F,M,M,X,ldx);
// X = L^-1 in n^3/3
ftrtri (F, FFLAS::FflasLower, FFLAS::FflasUnit, M, A, lda);
for (size_t i=0; i<M; ++i){
for (size_t j=i; j<M; ++j)
F.assign(*(X +i*ldx+j), F.zero);
F.assign (*(X+i*(ldx+1)), F.one);
}
for (size_t i=1; i<M; ++i)
FFLAS::fassign (F, i, (A+i*lda), 1, (X+i*ldx), 1);
ftrsm( F, FFLAS::FflasLeft, FFLAS::FflasUpper, FFLAS::FflasNoTrans, FFLAS::FflasNonUnit,
M, M, F.one, A, lda , X, ldx);
// X = P^-1.X
applyP( F, FFLAS::FflasLeft, FFLAS::FflasTrans,
M, 0,(int) M, X, ldx, P );
FFLAS::fflas_delete( P);
FFLAS::fflas_delete( rowP);
return X;
}
}
} // FFPACK
#endif // __FFLASFFPACK_ffpack_invert_INL
|