1/* 2 * Copyright (C) 2014,2015 the FFLAS-FFPACK group 3 * 4 * Written by Clement Pernet <Clement.Pernet@imag.fr> 5 * Brice Boyer (briceboyer) <boyer.brice@gmail.com> 6 * 7 * 8 * ========LICENCE======== 9 * This file is part of the library FFLAS-FFPACK. 10 * 11 * FFLAS-FFPACK is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 * ========LICENCE======== 25 *. 26 */ 27 28 29namespace FFLAS { 30 //--------------------------------------------------------------------- 31 // Level 2 routines 32 //--------------------------------------------------------------------- 33 34 /** \brief fassign : \f$A \gets B \f$. 35 * @param F field 36 * @param m number of rows to copy 37 * @param n number of cols to copy 38 * \param A matrix in \p F 39 * \param lda stride of \p A 40 * \param B vector in \p F 41 * \param ldb stride of \p B 42 */ 43 template INST_OR_DECL 44 void 45 fassign (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 46 const FFLAS_ELT* B, const size_t ldb , 47 FFLAS_ELT* A, const size_t lda ); 48 49 /** \brief fzero : \f$A \gets 0 \f$. 50 * @param F field 51 * @param m number of rows to zero 52 * @param n number of cols to zero 53 * \param A matrix in \p F 54 * \param lda stride of \p A 55 * @warning may be buggy if Element is larger than int 56 */ 57 58 template INST_OR_DECL 59 void 60 fzero (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 61 FFLAS_ELT* A, const size_t lda); 62 // { 63 // /* use memset only with Elements that are ok */ 64 // if (n == lda) { // contigous data 65 // // memset(A,(int) F.zero,m*n); // might be bogus ? 66 // fzero(F,m*n,A,1); 67 // } 68 // else { // not contiguous (strided) 69 // for (size_t i = 0 ; i < m ; ++i) 70 // // memset(A+i*lda,(int) F.zero,n) ; // might be bogus ? 71 // fzero(F,n,A+i*lda,1); 72 // } 73 // } 74 /** \brief fequal : test \f$A = B \f$. 75 * @param F field 76 * @param m row dimension 77 * @param n column dimension 78 * \param A m x n matrix in \p F 79 * \param lda leading dimension of A 80 * \param B m x n matrix in \p F 81 * \param ldb leading dimension of B 82 */ 83 template INST_OR_DECL 84 bool 85 fequal (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 86 const FFLAS_ELT* A, const size_t lda, 87 const FFLAS_ELT* B, const size_t ldb); 88 // { 89 // bool res=true; 90 // for (size_t i = 0 ; i < m ; ++i) 91 // res &= fequal (F, n, A + i*lda, 1, B + i*ldb, 1); 92 // return res; 93 // } 94 /** \brief fiszero : test \f$A = 0 \f$. 95 * @param F field 96 * @param m row dimension 97 * @param n column dimension 98 * \param A m x n matrix in \p F 99 * \param lda leading dimension of A 100 */ 101 template INST_OR_DECL 102 bool 103 fiszero (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 104 const FFLAS_ELT* A, const size_t lda); 105 // { 106 // bool res=true; 107 // for (size_t i = 0 ; i < m ; ++i) 108 // res &= fiszero (F, n, A + i*lda, 1); 109 // return res; 110 // } 111 112 //! creates a diagonal matrix 113 template INST_OR_DECL 114 void 115 fidentity (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 116 FFLAS_ELT* A, const size_t lda, const FFLAS_ELT & d); 117 // { 118 // fzero(F,m,n,A,lda); 119 // for (size_t i = 0 ; i < std::min(m,n) ; ++i) 120 // F.assign(A[i*lda+i],d); 121 // } 122 123 //! creates a diagonal matrix 124 template INST_OR_DECL 125 void 126 fidentity (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 127 FFLAS_ELT* A, const size_t lda); 128 // { 129 // fzero(F,m,n,A,lda); 130 // for (size_t i = 0 ; i < std::min(m,n) ; ++i) 131 // F.assign(A[i*lda+i],F.one); 132 // } 133 134 /** freduce 135 * \f$A \gets A mod F\f$. 136 * @param F field 137 * @param m number of rows 138 * @param n number of cols 139 * \param A matrix in \p F 140 * \param lda stride of \p A 141 * @internal 142 */ 143 template INST_OR_DECL 144 void 145 freduce (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m , const size_t n, 146 FFLAS_ELT* A, const size_t lda); 147 148 /** freduce 149 * \f$A \gets B mod F\f$. 150 * @param F field 151 * @param m number of rows 152 * @param n number of cols 153 * \param A matrix in \p F 154 * \param lda stride of \p A 155 * \param B matrix in \p Element 156 * \param ldb stride of \p B 157 * @internal 158 */ 159 template INST_OR_DECL 160 void 161 freduce (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m , const size_t n, 162 const FFLAS_ELT* B, const size_t ldb, 163 FFLAS_ELT* A, const size_t lda); 164 165 /** finit 166 * \f$A \gets B mod F\f$. 167 * @param F field 168 * @param m number of rows 169 * @param n number of cols 170 * \param A matrix in \p F 171 * \param lda stride of \p A 172 * \param B matrix in \p F 173 * \param ldb stride of \p B 174 * @internal 175 */ 176 template INST_OR_DECL 177 void 178 finit (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m , const size_t n, 179 const FFLAS_ELT* B, const size_t ldb, 180 FFLAS_ELT* A, const size_t lda); 181 182 183 /** fnegin 184 * \f$A \gets - A\f$. 185 * @param F field 186 * @param m number of rows 187 * @param n number of cols 188 * \param A matrix in \p F 189 * \param lda stride of \p A 190 * @internal 191 */ 192 template INST_OR_DECL 193 void 194 fnegin (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m , const size_t n, 195 FFLAS_ELT* A, const size_t lda); 196 // { 197 // //!@todo check if n == lda 198 // for (size_t i = 0 ; i < m ; ++i) 199 // fnegin(F,n,A+i*lda,1); 200 // return; 201 // } 202 203 /** fneg 204 * \f$A \gets - B\f$. 205 * @param F field 206 * @param m number of rows 207 * @param n number of cols 208 * \param A matrix in \p F 209 * \param lda stride of \p A 210 * @internal 211 */ 212 template INST_OR_DECL 213 void 214 fneg (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m , const size_t n, 215 const FFLAS_ELT* B, const size_t ldb, 216 FFLAS_ELT* A, const size_t lda); 217 // { 218 // //!@todo check if n == lda 219 // for (size_t i = 0 ; i < m ; ++i) 220 // fneg(F,n,B+i*ldb,1,A+i*lda,1); 221 // return; 222 // } 223 224 /** fscalin 225 * \f$A \gets a \cdot A\f$. 226 * @param F field 227 * @param m number of rows 228 * @param n number of cols 229 * @param alpha homotecie scalar 230 * \param A matrix in \p F 231 * \param lda stride of \p A 232 * @internal 233 */ 234 template INST_OR_DECL 235 void 236 fscalin (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m , const size_t n, 237 const FFLAS_ELT alpha, 238 FFLAS_ELT* A, const size_t lda); 239 240 /** fscal 241 * \f$B \gets a \cdot A\f$. 242 * @param F field 243 * @param m number of rows 244 * @param n number of cols 245 * @param alpha homotecie scalar 246 * \param[in] A matrix in \p F 247 * \param lda stride of \p A 248 * \param[out] B matrix in \p F 249 * \param ldb stride of \p B 250 * @internal 251 */ 252 template INST_OR_DECL 253 void 254 fscal (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m , const size_t n, 255 const FFLAS_ELT alpha, 256 const FFLAS_ELT* A, const size_t lda, 257 FFLAS_ELT* B, const size_t ldb); 258 259 /** \brief faxpy : \f$y \gets \alpha \cdot x + y\f$. 260 * @param F field 261 * @param m row dimension 262 * @param n column dimension 263 * @param alpha scalar 264 * \param[in] X vector in \p F 265 * \param ldx leading dimension of \p X 266 * \param[in,out] Y vector in \p F 267 * \param ldy leading dimension of \p Y 268 */ 269 template INST_OR_DECL 270 void 271 faxpy (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n 272 , const FFLAS_ELT alpha, 273 const FFLAS_ELT* X, const size_t ldx, 274 FFLAS_ELT* Y, const size_t ldy ); 275 276 /** \brief faxpby : \f$y \gets \alpha \cdot x + \beta \cdot y\f$. 277 * @param F field 278 * @param m row dimension 279 * @param n column dimension 280 * @param alpha scalar 281 * \param[in] X vector in \p F 282 * \param ldx leading dimension of \p X 283 * \param beta scalar 284 * \param[in,out] Y vector in \p F 285 * \param ldy leading dimension of \p Y 286 * \note this is a catlas function 287 */ 288 // template INST_OR_DECL 289 // void 290 // faxpby (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 291 // const FFLAS_ELT alpha, 292 // const FFLAS_ELT* X, const size_t ldx, 293 // const FFLAS_ELT beta, 294 // FFLAS_ELT* Y, const size_t ldy ); 295 296 /** \brief fmove : \f$A \gets B \f$ and \f$ B \gets 0\f$. 297 * @param F field 298 * @param m number of rows to copy 299 * @param n number of cols to copy 300 * \param A matrix in \p F 301 * \param lda stride of \p A 302 * \param B vector in \p F 303 * \param ldb stride of \p B 304 */ 305 template INST_OR_DECL 306 void 307 fmove (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t m, const size_t n, 308 FFLAS_ELT* A, const size_t lda, 309 FFLAS_ELT* B, const size_t ldb ); 310 // { 311 // fassign(F,m,n,A,lda,B,ldb); 312 // fzero(F,m,n,B,ldb); 313 // } 314 315 /** fadd : matrix addition. 316 * Computes \p C = \p A + \p B. 317 * @param F field 318 * @param M rows 319 * @param N cols 320 * @param A dense matrix of size \c MxN 321 * @param lda leading dimension of \p A 322 * @param B dense matrix of size \c MxN 323 * @param ldb leading dimension of \p B 324 * @param C dense matrix of size \c MxN 325 * @param ldc leading dimension of \p C 326 */ 327 template INST_OR_DECL 328 void 329 fadd (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t M, const size_t N, 330 const FFLAS_ELT* A, const size_t lda, 331 const FFLAS_ELT* B, const size_t ldb, 332 FFLAS_ELT* C, const size_t ldc); 333 334 335 336 /** fsub : matrix subtraction. 337 * Computes \p C = \p A - \p B. 338 * @param F field 339 * @param M rows 340 * @param N cols 341 * @param A dense matrix of size \c MxN 342 * @param lda leading dimension of \p A 343 * @param B dense matrix of size \c MxN 344 * @param ldb leading dimension of \p B 345 * @param C dense matrix of size \c MxN 346 * @param ldc leading dimension of \p C 347 */ 348 template INST_OR_DECL 349 void 350 fsub (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t M, const size_t N, 351 const FFLAS_ELT* A, const size_t lda, 352 const FFLAS_ELT* B, const size_t ldb, 353 FFLAS_ELT* C, const size_t ldc); 354 355 //! fsubin 356 //! C = C - B 357 template INST_OR_DECL 358 void 359 fsubin (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t M, const size_t N, 360 const FFLAS_ELT* B, const size_t ldb, 361 FFLAS_ELT* C, const size_t ldc); 362 363 /** fadd : matrix addition with scaling. 364 * Computes \p C = \p A + alpha \p B. 365 * @param F field 366 * @param M rows 367 * @param N cols 368 * @param A dense matrix of size \c MxN 369 * @param lda leading dimension of \p A 370 * @param alpha some scalar 371 * @param B dense matrix of size \c MxN 372 * @param ldb leading dimension of \p B 373 * @param C dense matrix of size \c MxN 374 * @param ldc leading dimension of \p C 375 */ 376 template INST_OR_DECL 377 void 378 fadd (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t M, const size_t N, 379 const FFLAS_ELT* A, const size_t lda, 380 const FFLAS_ELT alpha, 381 const FFLAS_ELT* B, const size_t ldb, 382 FFLAS_ELT* C, const size_t ldc); 383 384 //! faddin 385 template INST_OR_DECL 386 void 387 faddin (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t M, const size_t N, 388 const FFLAS_ELT* B, const size_t ldb, 389 FFLAS_ELT* C, const size_t ldc); 390 391 392 /** @brief finite prime FFLAS_FIELD<FFLAS_ELT> GEneral Matrix Vector multiplication. 393 * 394 * Computes \f$Y \gets \alpha \mathrm{op}(A) X + \beta Y \f$. 395 * @param F field 396 * \param TransA if \c TransA==FflasTrans then \f$\mathrm{op}(A)=A^t\f$. 397 * @param M rows 398 * @param N cols 399 * @param alpha scalar 400 * @param A dense matrix of size \c MxN 401 * @param lda leading dimension of \p A 402 * @param X dense vector of size \c N 403 * @param incX stride of \p X 404 * @param beta scalar 405 * @param[out] Y dense vector of size \c M 406 * @param incY stride of \p Y 407 */ 408 template INST_OR_DECL 409 FFLAS_ELT* 410 fgemv (const FFLAS_FIELD<FFLAS_ELT>& F, const FFLAS_TRANSPOSE TransA, 411 const size_t M, const size_t N, 412 const FFLAS_ELT alpha, 413 const FFLAS_ELT* A, const size_t lda, 414 const FFLAS_ELT* X, const size_t incX, 415 const FFLAS_ELT beta, 416 FFLAS_ELT* Y, const size_t incY); 417 418 /** @brief fger: rank one update of a general matrix 419 * 420 * Computes \f$A \gets \alpha x . y^T + A\f$ 421 * @param F field 422 * @param M rows 423 * @param N cols 424 * @param alpha scalar 425 * @param[in,out] A dense matrix of size \c MxN and leading dimension \p lda 426 * @param lda leading dimension of \p A 427 * @param x dense vector of size \c M 428 * @param incx stride of \p X 429 * @param y dense vector of size \c N 430 * @param incy stride of \p Y 431 */ 432 template INST_OR_DECL 433 void 434 fger (const FFLAS_FIELD<FFLAS_ELT>& F, const size_t M, const size_t N, 435 const FFLAS_ELT alpha, 436 const FFLAS_ELT* x, const size_t incx, 437 const FFLAS_ELT* y, const size_t incy, 438 FFLAS_ELT* A, const size_t lda); 439 440 /** @brief ftrsv: TRiangular System solve with Vector 441 * Computes \f$ X \gets \mathrm{op}(A^{-1}) X\f$ 442 * @param F field 443 * @param X vector of size \p N on a field \p F 444 * @param incX stride of \p X 445 * @param A a matrix of leading dimension \p lda and size \p N 446 * @param lda leading dimension of \p A 447 * @param N number of rows or columns of \p A according to \p TransA 448 * \param TransA if \c TransA==FflasTrans then \f$\mathrm{op}(A)=A^t\f$. 449 * \param Diag if \c Diag==FflasUnit then \p A is unit. 450 * \param Uplo if \c Uplo==FflasUpper then \p A is upper triangular 451 */ 452 template INST_OR_DECL 453 void 454 ftrsv (const FFLAS_FIELD<FFLAS_ELT>& F, const FFLAS_UPLO Uplo, 455 const FFLAS_TRANSPOSE TransA, const FFLAS_DIAG Diag, 456 const size_t N,const FFLAS_ELT* A, const size_t lda, 457 FFLAS_ELT* X, int incX); 458 459 460 461} // FFLAS 462 463/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 464// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s 465