| 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 |
typedef Givaro::ModularBalanced<float> Ring; |
| 37 |
Ring F(101); |
| 38 |
|
| 39 |
Ring::Element * A, * B, * C; |
| 40 |
|
| 41 |
A = fflas_new(F,2,3); |
| 42 |
B = fflas_new(F,3,2); |
| 43 |
C = fflas_new(F,2,2); |
| 44 |
|
| 45 |
F.init(*(A+0)); |
| 46 |
F.assign(*(A+0),F.one); |
| 47 |
F.init(*(A+1),2); |
| 48 |
F.init(*(A+2),3); |
| 49 |
F.init(*(A+3),5); |
| 50 |
F.init(*(A+4),7); |
| 51 |
F.init(*(A+5),11); |
| 52 |
|
| 53 |
Ring::Element t,u,v; |
| 54 |
F.init(t, 2); F.init(u, 4); F.init(v); |
| 55 |
|
| 56 |
F.assign(*(B+0),F.zero); // B[0] <- 0 |
| 57 |
F.assign(*(B+1),t); // B[1] <- 2 |
| 58 |
F.assign(*(B+2),u); // B[2] <- 4 |
| 59 |
F.add(v,t,u); F.assign(*(B+3),v); // B[3] <- 2+4 |
| 60 |
F.mul(*(B+4),t,u); // B[4] <- 2*4 |
| 61 |
F.add(*(B+5),u,v); // B[5] <- 4+6 |
| 62 |
|
| 63 |
FFLAS::WriteMatrix (std::cout << "A:=", F, 2, 3, A, 3) << std::endl; |
| 64 |
FFLAS::WriteMatrix (std::cout << "B:=", F, 3, 2, B, 2) << std::endl; |
| 65 |
|
| 66 |
fgemm (F, FflasNoTrans, FflasNoTrans, 2,2,3, F.one, A, 3, B, 2, F.zero, C, 2 ); |
| 67 |
|
| 68 |
FFLAS::WriteMatrix (std::cout << "C:=", F, 2, 2, C,2) << std::endl; |
| 69 |
|
| 70 |
fflas_delete( A); |
| 71 |
fflas_delete( B); |
| 72 |
fflas_delete( C); |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 80 |
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s |