LCOV - code coverage report
Current view: top level - ugbase/lib_algebra/operator - matrix_operator_functions.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 21 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 12 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2011-2014:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Konstantinos Xylouris
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : /**
      34              :  * \file lib_algebra/operator/matrix_operator_functions.h
      35              :  * This file contains some methods that forward operations on
      36              :  * IMatrixOperator to the concrete matrix methods. It can be removed
      37              :  * as soon as IMatrixOperator is derived from its Matrix.
      38              :  */
      39              : 
      40              : #ifndef __H__LIB_ALGEBRA__MATRIX_OPERATOR_FUNCTIONS__
      41              : #define __H__LIB_ALGEBRA__MATRIX_OPERATOR_FUNCTIONS__
      42              : 
      43              : #include "lib_algebra/operator/interface/matrix_operator.h"
      44              : 
      45              : namespace ug
      46              : {
      47              : /*
      48              : template <typename X, typename Y, typename M>
      49              : void MatAdd(    IMatrixOperator<M, X, Y>& opOut,
      50              :                                 IMatrixOperator<M, X, Y>& op1,
      51              :                                 IMatrixOperator<M, X, Y>& op2)
      52              : {
      53              :         typedef IMatrixOperator<M, X, Y> MatrixOperator;
      54              : 
      55              :         typedef typename MatrixOperator::matrix_type Matrix;
      56              : 
      57              :         Matrix& matOut = opOut.get_matrix();
      58              :         Matrix& mat1 = op1.get_matrix();
      59              :         Matrix& mat2 = op2.get_matrix();
      60              : 
      61              : //      matOut = mat1 + mat2;
      62              :         MatAdd<X, M>(matOut, mat1, mat2);
      63              : }
      64              : */
      65              : 
      66              : template <typename X, typename Y, typename M>
      67            0 : void MatIdentity(       MatrixOperator<M, X, Y>& opOut)
      68              : {
      69              :         PROFILE_FUNC_GROUP("algebra");
      70              :         typedef MatrixOperator<M, X, Y> MatrixOperator;
      71              : 
      72              :         typedef typename MatrixOperator::matrix_type Matrix;
      73              : 
      74            0 :         Matrix& matOut = opOut.get_matrix();
      75              :         size_t numRows = matOut.num_rows();
      76              :         size_t numCols = matOut.num_cols();
      77              : 
      78            0 :         matOut.resize_and_clear(numRows, numCols);
      79              : 
      80            0 :         for(size_t i = 0; i < numRows; ++i)
      81            0 :                 matOut(i, i) = 1.0;
      82            0 : }
      83              : 
      84              : 
      85              : template <typename X, typename Y, typename M>
      86            0 : void MatAdd( MatrixOperator<M, X, Y>& res, number alpha1, MatrixOperator<M, X, Y>& A1, number alpha2, MatrixOperator<M, X, Y>& A2)
      87              : {
      88              :         PROFILE_FUNC_GROUP("algebra");
      89              :         typedef MatrixOperator<M, X, Y> MatrixOperator;
      90              : 
      91              :         typedef typename MatrixOperator::matrix_type Matrix;
      92              : 
      93            0 :         Matrix& matRes = res.get_matrix();
      94            0 :         Matrix& matA1 = A1.get_matrix();
      95            0 :         Matrix& matA2 = A2.get_matrix();
      96            0 :         MatAdd(matRes, alpha1, matA1, alpha2, matA2);
      97            0 : }
      98              : 
      99              : template <typename X, typename Y, typename M>
     100            0 : void MatScale( MatrixOperator<M, X, Y>& A, number alpha)
     101              : {
     102              :         PROFILE_FUNC_GROUP("algebra");
     103              :         typedef MatrixOperator<M, X, Y> MatrixOperator;
     104              :         typedef typename MatrixOperator::matrix_type Matrix;
     105            0 :         Matrix& matA = A.get_matrix();
     106              : 
     107            0 :         matA.scale(alpha);
     108            0 : }
     109              : 
     110              : template <typename X, typename Y, typename M>
     111            0 : void MatTranspose( MatrixOperator<M, X, Y>& AT,  MatrixOperator<M, X, Y>& A)
     112              : {
     113              :         PROFILE_FUNC_GROUP("algebra");
     114              :         typedef MatrixOperator<M, X, Y> MatrixOperator;
     115              :         typedef typename MatrixOperator::matrix_type Matrix;
     116              : 
     117            0 :         Matrix& matA = A.get_matrix();
     118            0 :         Matrix& matAT = AT.get_matrix();
     119              : 
     120            0 :         matAT.set_as_transpose_of(matA);
     121            0 : }
     122              : 
     123              : }//     end of namespace
     124              : 
     125              : #endif
        

Generated by: LCOV version 2.0-1