RectangularMatrix.H 5.27 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
9
    Copyright (C) 2011-2016 OpenFOAM Foundation
    Copyright (C) 2019 OpenCFD Ltd.
10
11
12
13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

14
15
16
17
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
18
19
20
21
22
23
24

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
25
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
26
27

Class
28
    Foam::RectangularMatrix
29
30

Description
31
32
33
    A templated 2D rectangular m x n matrix of objects of \<Type\>.

    The matrix dimensions are used for subscript bounds checking etc.
34
35

SourceFiles
36
37
    RectangularMatrixI.H
    RectangularMatrix.C
38
39
40

\*---------------------------------------------------------------------------*/

41
42
#ifndef RectangularMatrix_H
#define RectangularMatrix_H
43
44

#include "Matrix.H"
45
#include "SquareMatrix.H"
46
47
48
49
50
51
52

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
53
                      Class RectangularMatrix Declaration
54
55
\*---------------------------------------------------------------------------*/

56
57
58
59
template<class Type>
class RectangularMatrix
:
    public Matrix<RectangularMatrix<Type>, Type>
60
61
62
63
64
65
{

public:

    // Constructors

66
        //- Construct null
67
        inline RectangularMatrix();
68

69
70
71
72
        //- Construct a square matrix (rows == columns)
        inline explicit RectangularMatrix(const label n);

        //- Construct given number of rows/columns
73
        inline RectangularMatrix(const label m, const label n);
74

75
76
77
78
79
80
81
82
        //- Construct given number of rows/columns
        //- initializing all elements to zero
        inline RectangularMatrix(const label m, const label n, const zero);

        //- Construct given number of rows/columns
        //- initializing all elements to the given value
        inline RectangularMatrix(const label m, const label n, const Type& val);

83
84
85
86
87
        //- Construct for given number of rows/columns
        //- initializing all elements to zero, and diagonal to one
        template<class AnyType>
        inline RectangularMatrix(const labelPair& dims, const Identity<AnyType>);

88
89
90
91
92
93
94
95
96
97
98
        //- Construct given number of rows/columns
        inline explicit RectangularMatrix(const labelPair& dims);

        //- Construct given number of rows/columns
        //- initializing all elements to zero
        inline RectangularMatrix(const labelPair& dims, const zero);

        //- Construct given number of rows/columns
        //- initializing all elements to the given value
        inline RectangularMatrix(const labelPair& dims, const Type& val);

99
        //- Construct from a block of another matrix
100
        template<class MatrixType>
101
        inline RectangularMatrix(const ConstMatrixBlock<MatrixType>& mat);
102
103
104

        //- Construct from a block of another matrix
        template<class MatrixType>
105
        inline RectangularMatrix(const MatrixBlock<MatrixType>& mat);
106

107
        //- Construct as copy of a square matrix
108
        inline RectangularMatrix(const SquareMatrix<Type>& mat);
109

110
        //- Construct from Istream.
111
        inline explicit RectangularMatrix(Istream& is);
112

113
        //- Clone
114
        inline autoPtr<RectangularMatrix<Type>> clone() const;
115
116


117
    // Member Operators
118

119
120
        //- Assign all elements to zero
        inline void operator=(const zero);
121

122
123
        //- Assign all elements to value
        inline void operator=(const Type& val);
124
125
126
};


127
// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
128

129
130
131
132
133
134
135
136
template<class Type>
class typeOfInnerProduct<Type, RectangularMatrix<Type>, RectangularMatrix<Type>>
{
public:

    typedef RectangularMatrix<Type> type;
};

137

138
139
140
141
142
143
144
145
template<class Type>
class typeOfInnerProduct<Type, RectangularMatrix<Type>, SquareMatrix<Type>>
{
public:

    typedef RectangularMatrix<Type> type;
};

146

147
148
149
150
151
152
153
154
155
template<class Type>
class typeOfInnerProduct<Type, SquareMatrix<Type>, RectangularMatrix<Type>>
{
public:

    typedef RectangularMatrix<Type> type;
};


156
157
// * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //

158
159
160
161
template<class Type>
RectangularMatrix<Type> outer(const Field<Type>& f1, const Field<Type>& f2);


162
163
164
165
166
167
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

168
#include "RectangularMatrixI.H"
169
170
171
172
173
174

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //