finitediff
SNidentity.h
Go to the documentation of this file.
1 /*
2 Copyright 2017 Laurent Claessens
3 contact : laurent@claessens-donadello.eu
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 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef __SNIDENTITY_H__092622__
20 #define __SNIDENTITY_H__092622__
21 
22 #include "SNgeneric.h"
23 
24 /*
25  This class represent the identity matrix.
26 */
27 template <class T,unsigned int tp_size>
28 class SNidentity : public SNgeneric<T,tp_size>
29 {
30  private:
31  T& _at(const m_num,const m_num) override;
32  T _get(const m_num,const m_num) const override;
33 
34  public:
35  SNidentity();
36 };
37 
38 // CONSTRUCTORS, OPERATORS, ... -------------------------------------------
39 
40 template <class T,unsigned int tp_size>
42 
43 // _GET AND _AT METHODS ---------------------------
44 
45 template <class T,unsigned int tp_size>
47 {
48  throw SNchangeNotAllowedException(i,j);
49 };
50 
51 template <class T,unsigned int tp_size>
52 T SNidentity<T,tp_size>::_get(const m_num i,const m_num j) const
53 {
54  if (i==j)
55  {
56  return 1;
57  }
58  return 0;
59 };
60 
61 #endif
T & _at(const m_num, const m_num) override
Definition: SNidentity.h:46
This is the base class for the other matrices types.
Definition: MathUtilities.h:32
Definition: m_num.h:34
Definition: SNidentity.h:28
SNidentity()
Definition: SNidentity.h:41
T _get(const m_num, const m_num) const override
Definition: SNidentity.h:52
Definition: SNexceptions.cpp:81