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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2010-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Martin Rupp
       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              : #ifndef __H__UG__CPU_ALGEBRA__OPERATIONS_MAT__
      34              : #define __H__UG__CPU_ALGEBRA__OPERATIONS_MAT__
      35              : 
      36              : #include "common/common.h"
      37              : #include "matrix_algebra_types.h"
      38              : 
      39              : // operations for matrices
      40              : //-----------------------------------------------------------------------------
      41              : // these functions execute matrix operations
      42              : 
      43              : #include "matrix_use_operators.h"
      44              : 
      45              : #include "matrix_use_global_functions.h"
      46              : 
      47              : #include "matrix_use_row_functions.h"
      48              : 
      49              : #include "matrix_use_member_functions.h"
      50              : 
      51              : namespace ug
      52              : {
      53              : 
      54              : // functions transforming MatMult into the right operation, depending on matrix_algebra_type_traits.
      55              : /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      56              : 
      57              : //! calculates dest = beta1 * A1;
      58              : template<typename vector_t, typename matrix_t>
      59              : inline bool MatMult(vector_t &dest,
      60              :                 const number &beta1, const matrix_t &A1, const vector_t &w1)
      61              : {
      62              :         return mat_operations_class<vector_t, matrix_t, matrix_algebra_type_traits<matrix_t>::type>
      63            0 :                 ::MatMult(dest, beta1, A1, w1);
      64              : }
      65              : 
      66              : //! calculates dest = alpha1*v1 + beta1 * A1 *w1;
      67              : template<typename vector_t, typename matrix_t>
      68              : inline bool MatMultAdd(vector_t &dest,
      69              :                 const number &alpha1, const vector_t &v1,
      70              :                 const number &beta1, const matrix_t &A1, const vector_t &w1 )
      71              : {
      72              :         return mat_operations_class<vector_t, matrix_t, matrix_algebra_type_traits<matrix_t>::type>
      73              :                         ::MatMultAdd(dest, alpha1, v1, beta1, A1, w1);
      74              : }
      75              : 
      76              : //! calculates dest = alpha1*v1 + alpha2*v2 + beta1 * A1 *w1;
      77              : template<typename vector_t, typename matrix_t>
      78              : inline bool MatMultAdd(vector_t &dest,
      79              :                 const number &alpha1, const vector_t &v1,
      80              :                 const number &alpha2, const vector_t &v2,
      81              :                 const number &beta1, const matrix_t &A1, const vector_t &w1)
      82              : {
      83              :         return mat_operations_class<vector_t, matrix_t, matrix_algebra_type_traits<matrix_t>::type>
      84              :                         ::MatMultAdd(dest, alpha1, v1, alpha2, v2, beta1, A1, w1);
      85              : }
      86              : 
      87              : //! calculates dest = beta1 * A1 *w1 + beta2 * A2*w2;
      88              : template<typename vector_t, typename matrix_t>
      89              : inline bool MatMultAdd(vector_t &dest,
      90              :                 const number &beta1, const matrix_t &A1, const vector_t &w1,
      91              :                 const number &beta2, const matrix_t &A2, const vector_t &w2)
      92              : {
      93              :         return mat_operations_class<vector_t, matrix_t, matrix_algebra_type_traits<matrix_t>::type>
      94              :                         ::MatMultAdd(dest, beta1, A1, w1, A2, w2);
      95              : }
      96              : 
      97              : //! calculates dest = alpha1*v1 + beta1 * A1 *w1 + beta2 * A2*w2;
      98              : template<typename vector_t, typename matrix_t>
      99              : inline bool MatMultAdd(vector_t &dest,
     100              :                 const number &alpha1, const vector_t &v1,
     101              :                 const number &beta1, const matrix_t &A1, const vector_t &w1,
     102              :                 const number &beta2, const matrix_t &A2, const vector_t &w2)
     103              : {
     104              :         return mat_operations_class<vector_t, matrix_t, matrix_algebra_type_traits<matrix_t>::type>
     105              :                         ::MatMultAdd(dest, alpha1, v1, beta1, A1, w1, beta2, A2, w2);
     106              : }
     107              : 
     108              : 
     109              : //! calculates dest = alpha1*v1 + beta1 * A1 *w1;
     110              : template<typename vector_t, typename matrix_t>
     111              : inline bool MatMultTransposed(vector_t &dest,
     112              :                 const number &beta1, const matrix_t &A1, const vector_t &w1 )
     113              : {
     114              :         return mat_operations_class<vector_t, matrix_t, matrix_algebra_type_traits<matrix_t>::type>
     115              :                         ::MatMultTransposed(dest, beta1, A1, w1);
     116              : }
     117              : 
     118              : 
     119              : //! calculates dest = alpha1*v1 + beta1 * A1 *w1;
     120              : template<typename vector_t, typename matrix_t>
     121              : inline bool MatMultTransposedAdd(vector_t &dest,
     122              :                 const number &alpha1, const vector_t &v1,
     123              :                 const number &beta1, const matrix_t &A1, const vector_t &w1 )
     124              : {
     125              :         return mat_operations_class<vector_t, matrix_t, matrix_algebra_type_traits<matrix_t>::type>
     126              :                         ::MatMultTransposedAdd(dest, alpha1, v1, beta1, A1, w1);
     127              : }
     128              : /*
     129              : //! calculates dest = beta1*A1*w1 + alpha1*v1, and norm = norm^2(dest)
     130              : template<typename vector_t, typename matrix_t>
     131              : inline void MatMultAddNorm(vector_t &dest,
     132              :                 const number &beta1, const TE_MAT_RowApplicable<matrix_t> &A1, const vector_t &w1,
     133              :                 const number &alpha1, const vector_t &v1,
     134              :                 double &norm)
     135              : {
     136              :         if(OPERATIONS_VERBOSE) cout << "dest: " << dest << endl <<
     137              :                         "\t= " << beta1 << " * " << A1.cast() << "\t * " << w1 << endl <<
     138              :                         "\t+ " << alpha1 << " * " << v1 << endl;
     139              : 
     140              :         norm=0;
     141              :         for(size_t i=0; i<dest.size(); i++)
     142              :         {
     143              :                 VecScaleAssign(dest[i], alpha1, v1[i]);
     144              :                 A1.cast().mat_mult_add_row(i, dest[i], beta1, w1);
     145              :                 VecNormSquaredAdd(dest[i], norm);
     146              :         }
     147              : }
     148              : */
     149              : 
     150              : 
     151              : 
     152              : } // namespace ug
     153              : #endif /* __H__UG__CPU_ALGEBRA__OPERATIONS_MAT__ */
        

Generated by: LCOV version 2.0-1