finitediff
SNupperTriangular.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 __SNupperTriangular_H__103047
20 #define __SNupperTriangular_H__103047
21 
22 #include <array>
23 
24 #include "SNgeneric.h"
25 #include "../exceptions/SNexceptions.cpp"
26 
27 /*
28  This represents a upper triangular matrix (the diagonal can be non zero).
29 */
30 
31 // THE CLASS HEADER -----------------------------------------
32 
33 template <class T,unsigned int tp_size>
34 class SNupperTriangular : public SNgeneric<T,tp_size>
35 {
36  private:
37  std::array<T,tp_size*tp_size> data; // many remain uninitialized
38 
39  T _get(const m_num,const m_num) const override;
40  T& _at(m_num,m_num) override;
41  public :
50  std::array<T,tp_size*tp_size> _get_other_data(const SNmatrix<T,tp_size>&) const;
51 
54 };
55 
56 // CONSTRUCTOR ---------------------------------------
57 
58 template <class T,unsigned int tp_size>
60  data()
61 { };
62 
63 template <class T,unsigned int tp_size>
64 std::array<T,tp_size*tp_size> SNupperTriangular<T,tp_size>::_get_other_data(const SNmatrix<T,tp_size>& A) const
65 {
66  return A.data;
67 }
68 
69 template <class T,unsigned int tp_size>
72 {};
73 
74 // _GET AND _AT METHODS ---------------------------------------
75 
76 template <class T,unsigned int tp_size>
78 {
79  if (l>c)
80  {
81  return 0;
82  }
83  return data.at(c*tp_size+l);
84 }
85 
86 template <class T,unsigned int tp_size>
88 {
89  if (l>c)
90  {
91  throw SNchangeNotAllowedException(l,c);
92  }
93  return data.at(c*tp_size+l);
94 }
95 
96 #endif
Definition: SNupperTriangular.h:34
SNupperTriangular()
Definition: SNupperTriangular.h:59
Represent a square numerical matrix.
Definition: SNline.h:29
This is the base class for the other matrices types.
Definition: MathUtilities.h:32
T & _at(m_num, m_num) override
Definition: SNupperTriangular.h:87
Definition: m_num.h:34
std::array< T, tp_size *tp_size > _get_other_data(const SNmatrix< T, tp_size > &) const
Definition: SNupperTriangular.h:64
std::array< T, tp_size *tp_size > data
Definition: SNupperTriangular.h:37
T _get(const m_num, const m_num) const override
Definition: SNupperTriangular.h:77
std::array< T, tp_size *tp_size > data
Definition: SNmatrix.h:95
Definition: SNexceptions.cpp:81