| 1 |
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 2 |
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 3 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 4 |
// vi: set et ts=4 sw=2 sts=2: |
| 5 |
#include <iostream> |
| 6 |
#include <dune/common/fmatrix.hh> |
| 7 |
#include <dune/istl/io.hh> |
| 8 |
#include <dune/istl/matrixmatrix.hh> |
| 9 |
|
| 10 |
int main(int argc, char** argv) |
| 11 |
{ |
| 12 |
typedef Dune::BCRSMatrix<Dune::FieldMatrix<double, 1, 1> > MatrixType; |
| 13 |
MatrixType m1(2,2,MatrixType::random) , |
| 14 |
m2(2,2,MatrixType::random) , |
| 15 |
res(2,2,MatrixType::random); |
| 16 |
|
| 17 |
// initialize first matrix [1,0;0,1] |
| 18 |
m1.setrowsize(0,1); |
| 19 |
m1.setrowsize(1,1); |
| 20 |
m1.endrowsizes(); |
| 21 |
m1.addindex(0,0); |
| 22 |
m1.addindex(1,1); |
| 23 |
m1.endindices(); |
| 24 |
m1[0][0] = 1; |
| 25 |
m1[1][1] = 1; |
| 26 |
// initialize second matrix [0,1;1,0] |
| 27 |
m2.setrowsize(0,1); |
| 28 |
m2.setrowsize(1,1); |
| 29 |
m2.endrowsizes(); |
| 30 |
m2.addindex(0,1); |
| 31 |
m2.addindex(1,0); |
| 32 |
m2.endindices(); |
| 33 |
m2[0][1] = 1; |
| 34 |
m2[1][0] = 1; |
| 35 |
Dune::printmatrix(std::cout, m1, "m1", ""); |
| 36 |
Dune::printmatrix(std::cout, m2, "m2", ""); |
| 37 |
Dune::matMultTransposeMat(res, m1, m2); |
| 38 |
Dune::printmatrix(std::cout, res, "res", ""); |
| 39 |
return 0; |
| 40 |
} |