/usr/include/fflas-ffpack/fflas/fflas_ftrsm_src.inl is in fflas-ffpack-common 1.6.0-1.
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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | /* -*- 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) 2005 C. Pernet
* Written by C. Pernet
* ========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========
*/
#define Mjoin(pre, nam) my_join(pre, nam)
#define my_join(pre, nam) pre ## nam
#ifdef __FFLAS__TRANSPOSE
#define __FFLAS__Acolinc lda
#define __FFLAS__Arowinc 1
#else
#define __FFLAS__Acolinc 1
#define __FFLAS__Arowinc lda
#endif
#ifdef __FFLAS__LEFT
#define __FFLAS__SIDE Left
#define __FFLAS__Na M
#define __FFLAS__Nb N
#define __FFLAS__Mb nsplit
#define __FFLAS__Nb2 N
#define __FFLAS__Mb2 M-nsplit
#define __FFLAS__Mbrest nrestsplit
#define __FFLAS__Nbrest N
#define __FFLAS__Mupdate M-(i+1)*nsplit
#define __FFLAS__Nupdate N
#define __FFLAS__Anorminc __FFLAS__Acolinc
#define __FFLAS__Bnorminc 1
#define __FFLAS__Bnormnext ldb
#define __FFLAS__Bdim N
#ifdef __FFLAS__LOW
#define __FFLAS__Atriang A + i * nsplit * (lda + 1)
#define __FFLAS__Aupdate A + i * nsplit * (lda + 1) + nsplit*__FFLAS__Arowinc
#define __FFLAS__Arest A + (__FFLAS__Na - nrestsplit) * (lda + 1)
#define __FFLAS__Anormnext __FFLAS__Arowinc
#define __FFLAS__Bupdate B + (i+1)*nsplit*ldb
#define __FFLAS__Brec B + i * nsplit * ldb
#define __FFLAS__Brest B + (M - nrestsplit) * ldb
#define __FFLAS__A1 A
#define __FFLAS__A2 A + nsplit * __FFLAS__Arowinc
#define __FFLAS__A3 A + nsplit * (lda + 1)
#define __FFLAS__B1 B
#define __FFLAS__B2 B + nsplit * ldb
#define __FFLAS__Normdim i
#else
#define __FFLAS__Atriang A + (__FFLAS__Na - (i + 1) * nsplit) * (lda + 1)
#define __FFLAS__Aupdate A + (__FFLAS__Na - (i + 1) * nsplit) * __FFLAS__Acolinc
#define __FFLAS__Arest A
#define __FFLAS__Anormnext lda + 1
#define __FFLAS__Bupdate B
#define __FFLAS__Brec B + (M - (i + 1) * nsplit) * ldb
#define __FFLAS__Brest B
#define __FFLAS__A1 A + (__FFLAS__Na - nsplit) * (lda + 1)
#define __FFLAS__A2 A + (__FFLAS__Na - nsplit) * __FFLAS__Acolinc
#define __FFLAS__A3 A
#define __FFLAS__B1 B + (M - nsplit)*ldb
#define __FFLAS__B2 B
#define __FFLAS__Normdim __FFLAS__Na-i-1
#endif
#else
#define __FFLAS__SIDE Right
#define __FFLAS__Na N
#define __FFLAS__Nb nsplit
#define __FFLAS__Mb M
#define __FFLAS__Mb2 M
#define __FFLAS__Nb2 N-nsplit
#define __FFLAS__Mbrest M
#define __FFLAS__Nbrest nrestsplit
#define __FFLAS__Mupdate M
#define __FFLAS__Nupdate N - (i + 1) * nsplit
#define __FFLAS__Anorminc __FFLAS__Arowinc
#define __FFLAS__Bnorminc ldb
#define __FFLAS__Bnormnext 1
#define __FFLAS__Bdim M
#ifdef __FFLAS__UP
#define __FFLAS__Atriang A + i * nsplit * (lda + 1)
#define __FFLAS__Aupdate A + i * nsplit * (lda + 1) + nsplit * __FFLAS__Acolinc
#define __FFLAS__Arest A + (__FFLAS__Na - nrestsplit) * (lda + 1)
#define __FFLAS__Anormnext __FFLAS__Acolinc
#define __FFLAS__Bupdate B + (i + 1) * nsplit
#define __FFLAS__Brec B + i * nsplit
#define __FFLAS__Brest B + (N - nrestsplit)
#define __FFLAS__A1 A
#define __FFLAS__A2 A + nsplit * __FFLAS__Acolinc
#define __FFLAS__A3 A + nsplit * (lda + 1)
#define __FFLAS__B1 B
#define __FFLAS__B2 B + nsplit
#define __FFLAS__Normdim i
#else
#define __FFLAS__Atriang A + (__FFLAS__Na - (i + 1) * nsplit) * (lda + 1)
#define __FFLAS__Aupdate A + (__FFLAS__Na - (i + 1) * nsplit) * __FFLAS__Arowinc
#define __FFLAS__Arest A
#define __FFLAS__Anormnext lda + 1
#define __FFLAS__Bupdate B
#define __FFLAS__Brec B + N - (i + 1) * nsplit
#define __FFLAS__Brest B
#define __FFLAS__A1 A + (__FFLAS__Na - nsplit) * (lda + 1)
#define __FFLAS__A2 A + (__FFLAS__Na - nsplit) * __FFLAS__Arowinc
#define __FFLAS__A3 A
#define __FFLAS__B1 B + N - nsplit
#define __FFLAS__B2 B
#define __FFLAS__Normdim __FFLAS__Na - i -1
#endif
#endif
#ifdef __FFLAS__UP
#define __FFLAS__UPLO Upper
#else
#define __FFLAS__UPLO Lower
#endif
#ifdef __FFLAS__UNIT
#define __FFLAS__DIAG Unit
#else
#define __FFLAS__DIAG NonUnit
#endif
#ifdef __FFLAS__TRANSPOSE
#define __FFLAS__TRANS Trans
#else
#define __FFLAS__TRANS NoTrans
#endif
#ifdef __FFLAS__DOUBLE
#define __FFLAS__ELEMENT double
#define __FFLAS__DOMAIN DoubleDomain
#define __FFLAS__BLAS_PREFIX d
#endif
#ifdef __FFLAS__FLOAT
#define __FFLAS__ELEMENT float
#define __FFLAS__DOMAIN FloatDomain
#define __FFLAS__BLAS_PREFIX s
#endif
#ifdef __FFLAS__GENERIC
#define __FFLAS__ELEMENT Element
#endif
#ifndef __FFLAS__GENERIC
template <>
class Mjoin(ftrsm, Mjoin(__FFLAS__SIDE, Mjoin(__FFLAS__UPLO, Mjoin(__FFLAS__TRANS, __FFLAS__DIAG))))<__FFLAS__ELEMENT>{
public:
// TRSM with delayed updates: assumes input in Zp and ensures output in Zp.
// The multiple MatMul updates (recursive sequence) are done over Z
template<class Field>
void delayed (const Field& F, const size_t M, const size_t N,
typename Field::Element * A, const size_t lda,
typename Field::Element * B, const size_t ldb,
const size_t nblas, size_t nbblocsblas)
{
static __FFLAS__DOMAIN D; // is this safe ??
if ( __FFLAS__Na <= nblas ){
for (size_t i=0; i < M; ++i)
for (size_t j = 0; j < N; ++j)
F.init( *(B + i*ldb + j), *( B + i*ldb + j));
#ifndef __FFLAS__UNIT
typename Field::Element inv;
typename Field::Element * Ai = A, * Bi = B;
#ifdef __FFLAS__LEFT
#ifdef __FFLAS__UP
Ai += __FFLAS__Acolinc;
#endif
#endif
#ifdef __FFLAS__RIGHT
#ifdef __FFLAS__LOW
Ai += __FFLAS__Arowinc;
#endif
#endif
for (size_t i = 0; i < __FFLAS__Na; ++i){
#ifdef _FF_DEBUG
if ( F.isZero(*(A+i*(lda+1))) ) throw PreconditionFailed(__func__,__FILE__,__LINE__,"Triangular matrix not invertible");
#endif
F.inv (inv, *(A + i * (lda+1)));
fscal (F, __FFLAS__Normdim, inv, Ai, __FFLAS__Anorminc);
fscal (F, __FFLAS__Bdim, inv, Bi, __FFLAS__Bnorminc);
Ai += __FFLAS__Anormnext;
Bi += __FFLAS__Bnormnext;
}
#endif // __FFLAS__UNIT
Mjoin(cblas_,Mjoin(__FFLAS__BLAS_PREFIX,trsm))
(CblasRowMajor,
Mjoin (Cblas, __FFLAS__SIDE),
Mjoin (Cblas, __FFLAS__UPLO),
Mjoin (Cblas, __FFLAS__TRANS),
CblasUnit,
(int)M, (int)N, 1.0, A, (int)lda, B, (int)ldb );
for (size_t i = 0; i < M; ++i)
for (size_t j = 0; j < N; ++j)
F.init (*(B + i*ldb + j), *(B + i*ldb + j));
#ifndef __FFLAS__UNIT
Ai = A;
#ifdef __FFLAS__LEFT
#ifdef __FFLAS__UP
Ai += __FFLAS__Acolinc;
#endif
#endif
#ifdef __FFLAS__RIGHT
#ifdef __FFLAS__LOW
Ai += __FFLAS__Arowinc;
#endif
#endif
for (size_t i = 0; i < __FFLAS__Na; ++i){
fscal( F, __FFLAS__Normdim, *(A + i * (lda+1)) , Ai, __FFLAS__Anorminc);
Ai += __FFLAS__Anormnext;
}
#endif // __FFLAS__UNIT
} else { // __FFLAS__Na <= nblas
size_t nbblocsup = (nbblocsblas + 1) / 2;
size_t nsplit = nbblocsup * nblas;
this->delayed (F, __FFLAS__Mb, __FFLAS__Nb,
__FFLAS__A1, lda, __FFLAS__B1, ldb, nblas, nbblocsup);
#ifdef __FFLAS__RIGHT
fgemm (D, FflasNoTrans, Mjoin (Fflas, __FFLAS__TRANS), __FFLAS__Mb2, __FFLAS__Nb2, nsplit,
-1.0, __FFLAS__B1, ldb, __FFLAS__A2, lda, F.one, __FFLAS__B2, ldb);
#else
fgemm (D, Mjoin (Fflas, __FFLAS__TRANS), FflasNoTrans, __FFLAS__Mb2, __FFLAS__Nb2, nsplit,
-1.0, __FFLAS__A2, lda, __FFLAS__B1, ldb, F.one, __FFLAS__B2, ldb);
#endif
this->delayed (F, __FFLAS__Mb2, __FFLAS__Nb2,
__FFLAS__A3, lda, __FFLAS__B2, ldb, nblas, nbblocsblas - nbblocsup);
}
}
template <class Field>
void operator () (const Field& F, const size_t M, const size_t N,
typename Field::Element * A, const size_t lda,
typename Field::Element * B, const size_t ldb)
{
if (!M || !N ) return;
static __FFLAS__DOMAIN D;
size_t nblas = TRSMBound<Field> (F);
size_t ndel = DotProdBound (F, 0, F.one,
#ifdef __FFLAS__DOUBLE
FflasDouble
#else
FflasFloat
#endif
);
ndel = (ndel / nblas)*nblas;
size_t nsplit = ndel;
size_t nbblocsplit = (__FFLAS__Na-1) / nsplit;
size_t nrestsplit = ((__FFLAS__Na-1) % nsplit) +1;
for ( size_t i = 0; i < nbblocsplit; ++i) {
this->delayed (F, __FFLAS__Mb, __FFLAS__Nb,
__FFLAS__Atriang, lda, __FFLAS__Brec, ldb, nblas, nsplit / nblas);
#ifdef __FFLAS__RIGHT
fgemm (F, FflasNoTrans, Mjoin (Fflas, __FFLAS__TRANS),
__FFLAS__Mupdate, __FFLAS__Nupdate, nsplit, F.mOne,
__FFLAS__Brec, ldb, __FFLAS__Aupdate, lda, F.one, __FFLAS__Bupdate, ldb);
#else
fgemm (F, Mjoin (Fflas, __FFLAS__TRANS), FflasNoTrans,
__FFLAS__Mupdate, __FFLAS__Nupdate, nsplit, F.mOne,
__FFLAS__Aupdate, lda, __FFLAS__Brec, ldb, F.one, __FFLAS__Bupdate, ldb);
#endif
}
if (nrestsplit)
this->delayed (F, __FFLAS__Mbrest, __FFLAS__Nbrest,
__FFLAS__Arest, lda, __FFLAS__Brest, ldb, nblas, nrestsplit / nblas);
}
}; //class ftrsm....
#else // __FFLAS__GENERIC
template <class Element>
class Mjoin(ftrsm, Mjoin(__FFLAS__SIDE, Mjoin(__FFLAS__UPLO, Mjoin(__FFLAS__TRANS, __FFLAS__DIAG)))) {
public:
template<class Field>
void operator() (const Field& F, const size_t M, const size_t N,
typename Field::Element * A, const size_t lda,
typename Field::Element * B, const size_t ldb)
{
if (__FFLAS__Na == 1){
#ifndef __FFLAS__UNIT
typename Field::Element inv;
#ifdef _FF_DEBUG
if ( F.isZero(*A) ) throw PreconditionFailed(__func__,__FILE__,__LINE__,"Triangular matrix not invertible");
#endif
F.inv(inv, *A);
FFLAS::fscal(F, __FFLAS__Bdim, inv, B, __FFLAS__Bnorminc);
#endif //__FFLAS__UNIT
} else { // __FFLAS__Na > 1
size_t nsplit = __FFLAS__Na >> 1;
this->operator() (F, __FFLAS__Mb, __FFLAS__Nb, __FFLAS__A1, lda, __FFLAS__B1, ldb);
#ifdef __FFLAS__RIGHT
fgemm (F, FflasNoTrans , Mjoin (Fflas, __FFLAS__TRANS),
__FFLAS__Mb2, __FFLAS__Nb2, nsplit, F.mOne,
__FFLAS__B1, ldb, __FFLAS__A2, lda, F.one, __FFLAS__B2, ldb);
#else
fgemm (F, Mjoin (Fflas, __FFLAS__TRANS), FFLAS::FflasNoTrans,
__FFLAS__Mb2, __FFLAS__Nb2, nsplit, F.mOne,
__FFLAS__A2, lda, __FFLAS__B1, ldb, F.one, __FFLAS__B2, ldb);
#endif
this->operator() (F, __FFLAS__Mb2, __FFLAS__Nb2, __FFLAS__A3, lda, __FFLAS__B2, ldb);
}
}
};
#endif // __FFLAS__GENERIC
#undef __FFLAS__UPLO
#undef __FFLAS__DIAG
#undef __FFLAS__SIDE
#undef __FFLAS__TRANS
#undef __FFLAS__Na
#undef __FFLAS__Mb
#undef __FFLAS__Nb
#undef __FFLAS__Mbrest
#undef __FFLAS__Nbrest
#undef __FFLAS__Mupdate
#undef __FFLAS__Nupdate
#undef __FFLAS__Atriang
#undef __FFLAS__Aupdate
#undef __FFLAS__Arest
#undef __FFLAS__Bupdate
#undef __FFLAS__Brec
#undef __FFLAS__Brest
#undef __FFLAS__Bnorminc
#undef __FFLAS__Bnormnext
#undef __FFLAS__Anormnext
#undef __FFLAS__Anorminc
#undef __FFLAS__ELEMENT
#undef __FFLAS__BLAS_PREFIX
#undef __FFLAS__DOMAIN
#undef __FFLAS__A1
#undef __FFLAS__A2
#undef __FFLAS__A3
#undef __FFLAS__B1
#undef __FFLAS__B2
#undef __FFLAS__Nb2
#undef __FFLAS__Mb2
#undef __FFLAS__Bdim
#undef __FFLAS__Normdim
#undef __FFLAS__Acolinc
#undef __FFLAS__Arowinc
#undef Mjoin
#undef my_join
|