LCOV - code coverage report
Current view: top level - ugbase/lib_algebra/small_algebra/small_matrix - densevector_impl.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 29 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 4 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              : 
      34              : #ifndef __H__UG__COMMON__DENSEVECTOR_IMPL_H__
      35              : #define __H__UG__COMMON__DENSEVECTOR_IMPL_H__
      36              : 
      37              : #include "common/serialization.h"
      38              : 
      39              : namespace ug{
      40              : 
      41              : template<typename TStorage>
      42              : DenseVector<TStorage>::DenseVector(double alpha)
      43              : {
      44              :         operator=(alpha);
      45              : }
      46              : 
      47              : template<typename TStorage>
      48            0 : DenseVector<TStorage>::DenseVector(const DenseVector<TStorage> &rhs) : TStorage(rhs)
      49              : {
      50            0 : }
      51              : 
      52              : // operations with vectors
      53              : template<typename TStorage>
      54              : DenseVector<TStorage> &
      55            0 : DenseVector<TStorage>::operator = (const DenseVector<TStorage> &rhs)
      56              : {
      57            0 :         if(this == &rhs) return *this;
      58            0 :         if(size() != rhs.size()) resize(rhs.size());
      59              : 
      60            0 :         for(size_type i=0; i<size(); i++)
      61            0 :                 entry(i) = rhs[i];
      62              :         return *this;
      63              : }
      64              : 
      65              : 
      66              : template<typename TStorage>
      67              : DenseVector<TStorage> &
      68              : DenseVector<TStorage>::operator += (const DenseVector<TStorage> &rhs)
      69              : {
      70            0 :         for(size_type i=0; i<size(); i++)
      71            0 :                 entry(i) += rhs[i];
      72              :         return *this;
      73              : }
      74              : 
      75              : 
      76              : template<typename TStorage>
      77              : DenseVector<TStorage> &
      78              : DenseVector<TStorage>::operator -= (const DenseVector<TStorage> &rhs)
      79              : {
      80            0 :         for(size_type i=0; i<size(); i++)
      81            0 :                 entry(i) -= rhs[i];
      82              :         return *this;
      83              : }
      84              : 
      85              : 
      86              : // operations with scalars
      87              : template<typename TStorage>
      88              : template<typename T>
      89              : DenseVector<TStorage> &
      90              : DenseVector<TStorage>::operator=(const T &alpha)
      91              : {
      92            0 :         for(size_t i=0; i<size(); i++)
      93            0 :                 entry(i) = alpha;
      94              :         return *this;
      95              : }
      96              : 
      97              : template<typename TStorage>
      98              : DenseVector<TStorage> &
      99              : DenseVector<TStorage>::operator+=(const typename DenseVector<TStorage>::value_type &alpha)
     100              : {
     101            0 :         for(size_t i=0; i<size(); i++)
     102            0 :                 entry(i) += alpha;
     103              :         return *this;
     104              : }
     105              : 
     106              : template<typename TStorage>
     107              : DenseVector<TStorage> &
     108              : DenseVector<TStorage>::operator-=(const typename DenseVector<TStorage>::value_type &alpha)
     109              : {
     110              :         for(size_t i=0; i<size(); i++)
     111              :                 entry(i) -= alpha;
     112              :         return *this;
     113              : }
     114              : 
     115              : template<typename TStorage>
     116              : template<typename T>
     117              : DenseVector<TStorage> &
     118              : DenseVector<TStorage>::operator*=(const T &alpha)
     119              : {
     120            0 :         for(size_t i=0; i<size(); i++)
     121            0 :                 entry(i) *= alpha;
     122              :         return *this;
     123              : }
     124              : 
     125              : 
     126              : template<typename TStorage>
     127              : DenseVector<TStorage> &
     128              : DenseVector<TStorage>::operator/=(const typename DenseVector<TStorage>::value_type &alpha)
     129              : {
     130              :         for(size_t i=0; i<size(); i++)
     131              :                 entry(i) /= alpha;
     132              : 
     133              :         return *this;
     134              : }
     135              : 
     136              : template<typename TStorage>
     137            0 : void DenseVector<TStorage>::maple_print(const char *name)
     138              : {
     139            0 :         UG_LOG(name << " = vector([");
     140            0 :         for(size_t i=0; i<size(); ++i)
     141              :         {
     142            0 :                 if(i > 0) UG_LOG(", ");
     143            0 :                 UG_LOG(entry(i));
     144              :         }
     145              :         UG_LOG("]);\n");
     146            0 : }
     147              : 
     148              : // views
     149              : // methods
     150              : 
     151              : 
     152              : template<typename TStorage>
     153            0 : std::ostream &operator << (std::ostream &out, const DenseVector<TStorage> &vec)
     154              : {
     155            0 :         out << "[";
     156            0 :         for(size_t i=0; i<vec.size(); i++)
     157            0 :                 out << " " << vec[i];
     158            0 :         out << " ] ";
     159              : //      out << "(" << vec.size() << ")";
     160            0 :         return out;
     161              : }
     162              : 
     163              : 
     164              : 
     165              : template<typename TStorage>
     166              : template<typename Type>
     167              : DenseVector<TStorage> &
     168              : DenseVector<TStorage>::assign(const Type &t)
     169              : {
     170              :         VectorAssign(*this, t);
     171              :         return *this;
     172              : }
     173              : 
     174              : 
     175              : 
     176              : template<size_t n> inline void Serialize(std::ostream &buff, const DenseVector<FixedArray1<number, n> > &vec)
     177              : {
     178              :         buff.write((char*)&vec, sizeof(vec));
     179              : }
     180              : 
     181              : template<size_t n> inline void Deserialize(std::istream &buff, DenseVector<FixedArray1<number, n> > &vec)
     182              : {
     183              :         buff.read((char*)&vec, sizeof(vec));
     184              : }
     185              : 
     186              : 
     187              : template<typename T> inline void Serialize(std::ostream &buff, const DenseVector<VariableArray1<T> > &vec)
     188              : {
     189              :         size_t s = vec.size();
     190              :         buff.write((char*)&s, sizeof(s));
     191              :         for(size_t i=0; i<s; i++)
     192              :                 Serialize(buff, vec[i]);
     193              : }
     194              : 
     195              : template<typename T> inline void Deserialize(std::istream &buff, DenseVector<VariableArray1<double> > &vec)
     196              : {
     197              :         size_t s;
     198              :         buff.read((char*)&s, sizeof(s));
     199              :         vec.resize(s);
     200              :         for(size_t i=0; i<s; i++)
     201              :                 Deserialize(buff, vec[i]);
     202              : }
     203              : 
     204              : 
     205              : template<typename T >
     206              : inline bool IsFiniteAndNotTooBig(const DenseVector<T> &v)
     207              : {
     208              :         for(size_t r=0; r<v.size(); r++)
     209              :                 if(IsFiniteAndNotTooBig(v[r]) == false) return false;
     210              : 
     211              :         return true;
     212              : }
     213              : 
     214              : 
     215              : //MAKE_TEMPLATE_OPERATORS_VECTOR2(typename TStorage, DenseVector<TStorage>);
     216              : 
     217              : }
     218              : 
     219              : #endif // __H__UG__COMMON__DENSEVECTOR_IMPL_H__
        

Generated by: LCOV version 2.0-1