Debian Codegraph @

tutorials/2x2-fgemm.C

raw
1 /* Copyright (c) FFLAS-FFPACK
2 * Written by Jean-Guillaume Dumas <[email protected]>
3 * ========LICENCE========
4 * This file is part of the library FFLAS-FFPACK.
5 *
6 * FFLAS-FFPACK is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * ========LICENCE========
20 */
21
22
23 #include <fflas-ffpack/fflas-ffpack-config.h>
24 #include <givaro/modular-balanced.h>
25 #include <fflas-ffpack/fflas/fflas.h>
26 #include <fflas-ffpack/utils/timer.h>
27 #include <fflas-ffpack/utils/fflas_io.h>
28 #include <fflas-ffpack/utils/args-parser.h>
29
30 #include <iostream>
31
32 using namespace FFLAS;
33
34 int main(int argc, char** argv) {
35
36 Givaro::Modular<float> F(11);
37
38 constexpr size_t m(2),k(3),n(1);
39 float A[m*k]{1,2,3,4,5,6}, B[k*n]{7,8,9}, * C;
40
41 C = fflas_new(F,m,n);
42
43 // A is mxk with leading dimension k
44 FFLAS::WriteMatrix (std::cout << "A:="<<std::endl, F, m, k, A, k) << std::endl;
45 // B is kxn with leading dimension n
46 FFLAS::WriteMatrix (std::cout << "B:="<<std::endl, F, k, n, B, n) << std::endl;
47
48 // C <-- 1. A.B + 0. C
49 fgemm (F, FflasNoTrans, FflasNoTrans, m, n, k, F.one, A, k, B, n, F.zero, C, n);
50
51 // C is mxn with leading dimension n
52 FFLAS::WriteMatrix (std::cout << "C:="<<std::endl, F, m, n, C, n) << " modulo 11" << std::endl;
53
54 fflas_delete( C);
55
56 return 0;
57 }
58
59 /* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
60 // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s