SquareMatrix.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::SquareMatrix
26 
27 Description
28  A templated 2D square matrix of objects of <T>, where the n x n matrix
29  dimension is known and used for subscript bounds checking, etc.
30 
31 SourceFiles
32  SquareMatrixI.H
33  SquareMatrix.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef SquareMatrix_H
38 #define SquareMatrix_H
39 
40 #include "Matrix.H"
41 #include "Identity.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of friend functions and operators
49 
50 template<class Type>
51 class RectangularMatrix;
52 
53 
54 /*---------------------------------------------------------------------------*\
55  Class Matrix Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Type>
59 class SquareMatrix
60 :
61  public Matrix<SquareMatrix<Type>, Type>
62 {
63 
64 public:
65 
66  // Constructors
67 
68  //- Null constructor.
69  inline SquareMatrix();
70 
71  //- Construct given number of rows/columns.
72  inline SquareMatrix(const label n);
73 
74  //- Construct from a block of another matrix
75  template<class MatrixType>
77 
78  //- Construct from a block of another matrix
79  template<class MatrixType>
81 
82  //- Construct given number of rows/columns
83  // initializing all elements to zero
84  inline SquareMatrix(const label n, const zero);
85 
86  //- Construct given number of rows and columns (checked to be equal)
87  // initializing all elements to zero
88  inline SquareMatrix(const label m, const label n, const zero);
89 
90  //- Construct given number of rows/columns
91  // Initializing to the identity matrix
92  inline SquareMatrix(const label n, const Identity<Type>);
93 
94  //- Construct with given number of rows and rows
95  // initializing all elements to the given value
96  inline SquareMatrix(const label n, const Type&);
97 
98  //- Construct as copy of a RectangularMatrix
99  // which is checked to be square
100  inline explicit SquareMatrix(const RectangularMatrix<Type>&);
101 
102  //- Construct from Istream.
103  inline SquareMatrix(Istream&);
104 
105  //- Clone
106  inline autoPtr<SquareMatrix<Type>> clone() const;
107 
108 
109  // Member Functions
110 
111  // Edit
112 
113  //- Resize the matrix preserving the elements
114  inline void setSize(const label m);
115 
116 
117  // Member operators
118 
119  //- Assignment of all elements to zero
120  void operator=(const zero);
121 
122  //- Assignment elements to the
123  void operator=(const Identity<Type>);
124 };
125 
126 
127 // Global functions and operators
128 
129 //- Return the LU decomposed SquareMatrix det
130 template<class Type>
131 scalar detDecomposed(const SquareMatrix<Type>&, const label sign);
132 
133 //- Return the SquareMatrix det
134 template<class Type>
135 scalar det(const SquareMatrix<Type>&);
136 
137 //- Return the SquareMatrix det and the LU decomposition in the original matrix
138 template<class Type>
139 scalar det(SquareMatrix<Type>&);
140 
141 template<class Type>
142 class typeOfInnerProduct<Type, SquareMatrix<Type>, SquareMatrix<Type>>
143 {
144 public:
146  typedef SquareMatrix<Type> type;
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #include "SquareMatrixI.H"
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #ifdef NoRepository
161  #include "SquareMatrix.C"
162 #endif
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
dimensionedScalar sign(const dimensionedScalar &ds)
scalar detDecomposed(const SquareMatrix< Type > &, const label sign)
Return the LU decomposed SquareMatrix det.
Abstract template class to provide the form resulting from.
Definition: products.H:47
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A templated block of an (m x n) matrix of type <MatrixType>.
Definition: Matrix.H:71
label m() const
Return the number of rows.
void operator=(const zero)
Assignment of all elements to zero.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
label n() const
Return the number of columns.
A templated 2D rectangular m x n matrix of objects of <Type>.
A templated (m x n) matrix of objects of <T>.
autoPtr< SquareMatrix< Type > > clone() const
Clone.
void setSize(const label m)
Resize the matrix preserving the elements.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:461
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:47
A templated 2D square matrix of objects of <T>, where the n x n matrix dimension is known and used fo...
Definition: SquareMatrix.H:58
SquareMatrix()
Null constructor.
Definition: SquareMatrixI.H:29
Namespace for OpenFOAM.