1%%%%%%%%%%%%%%%%%%% 2% XLiFE++ is an extended library of finite elements written in C++ 3% Copyright (C) 2014 Lunéville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin 4% 5% This program is free software: you can redistribute it and/or modify 6% it under the terms of the GNU General Public License as published by 7% the Free Software Foundation, either version 3 of the License, or 8% (at your option) any later version. 9% This program is distributed in the hope that it will be useful, 10% but WITHOUT ANY WARRANTY; without even the implied warranty of 11% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12% GNU General Public License for more details. 13% You should have received a copy of the GNU General Public License 14% along with this program. If not, see <http://www.gnu.org/licenses/>. 15%%%%%%%%%%%%%%%%%%% 16 17\section{The {\classtitle LcTerm} class} 18 19The {\class LcTerm} class is a template class handling a linear combination of terms of type {\class TermVector}, {\class TermMatrix}, {\class SuTermVector} or {\class SuTermMatrix}. It is automatically involved as a result whenever any linear combination of {\class Term}'s is handled: 20\vspace{.1cm} 21\begin{lstlisting}[]{} 22TermVector tv1, tv2; 23... 24out<<norm2(tv1-tv2); 25\end{lstlisting} 26\vspace{.1cm} 27In this example \verb?tv1-tv2? produces a {\class LcTerm<TermVector>} that is cast implicitly to a {\class TermVector} because the definition of a constructor of {\class TermVector} from a {\class LcTerm<TermVector>}. Then any functions defined on {\class TermVector} may be applied, the {\cmd norm2} function in this example.\\ 28 29The {\class LcTerm} class inherits from \verb?vector<pair<const TT *, complex_t >>? 30\vspace{.1cm} 31\begin{lstlisting}[]{} 32template <typename TT> 33class LcTerm : public vector<pair<const TT *, complex_t> > 34{ 35public: 36 string_t nametype; 37 typedef typename vector<pair<const TT *, complex_t> >::iterator iterator; 38 typedef typename vector<pair<const TT *, complex_t> >::const_iterator const_iterator; 39\end{lstlisting} 40\vspace{.3cm} 41It has template constructors and insertion functions (\verb?push_back?): 42\vspace{.1cm} 43\begin{lstlisting}[]{} 44template<typename T> 45 LcTerm(const TT*,const T&); 46 LcTerm(const TT*,const T&, const TT*, const T&); 47 LcTerm(const TT&,const T&); 48 LcTerm(const TT&,const T&, const TT&, const T&); 49 LcTerm(const vector<const TT *>&, const vector<T>&); 50 void push_back(const Term*,const T&); 51 void push_back(const Term&,const T&); 52\end{lstlisting} 53\vspace{.2cm} 54and to avoid some \verb?std::vector? member functions are overloaded: 55\vspace{.1cm} 56\begin{lstlisting}[]{} 57number_t size() const ; 58const_iterator begin(); 59const_iterator end(); 60iterator begin(); 61iterator end(); 62\end{lstlisting} 63\vspace{.2cm} 64It supports the following algebraic operations: 65\vspace{.1cm} 66\begin{lstlisting}[]{} 67template<typename T> 68 LcTerm<TT>& operator*=(const T&); 69 LcTerm<TT>& operator/=(const T&); 70LcTerm<TT>& operator+=(const LcTerm<TT>&); 71LcTerm<TT>& operator-=(const LcTerm<TT>&); 72\end{lstlisting} 73\vspace{.2cm} 74and provides the following utilities 75\vspace{.1cm} 76\begin{lstlisting}[]{} 77ValueType coefType() const; 78void print(ostream &) const; 79template <typename TX> 80friend ostream& operator<<(ostream &,const LcTerm<TX>&) 81\end{lstlisting} 82\vspace{.2cm} 83Note that {\class TermVector} and {\class TermMatrix} classes have functions that creates some {\class LcTerm} objects. 84 85\displayInfos{ 86library=term, 87header=LcTerm.hpp, 88implementation=, 89test=, 90header dep={Term.hpp, config.h, utils.h} 91} 92