initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / primitives / VectorSpace / products.H
blob34fda71b3c5527dafcff657ca015efbb66092812
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 InNamespace
26     Foam
28 Description
29     Traits classes for inner and outer products of primitives.
31 \*---------------------------------------------------------------------------*/
33 #ifndef products_H
34 #define products_H
36 #include "pTraits.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 namespace Foam
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 template<class Cmpt, int rank>
46 class typeOfRank
47 {};
50 template<class Cmpt, int rank>
51 class symmTypeOfRank
52 {};
55 template<class arg1, class arg2>
56 class typeOfSum
58 public:
60     typedef arg1 type;
64 #ifndef __CINT__
66 template<class arg1, class arg2>
67 class outerProduct
69 public:
71     typedef typename typeOfRank
72     <
73         typename pTraits<arg1>::cmptType,
74         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank)
75     >::type type;
79 template<class arg1, class arg2>
80 class crossProduct
82 public:
84     typedef typename typeOfRank
85     <
86         typename pTraits<arg2>::cmptType,
87         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 1
88     >::type type;
91 template<class arg1, class arg2>
92 class innerProduct
94 public:
96     typedef typename typeOfRank
97     <
98         typename pTraits<arg1>::cmptType,
99         int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 2
100     >::type type;
103 template<class arg1, class arg2>
104 class scalarProduct
106 public:
108     typedef typename pTraits<arg1>::cmptType type;
112 template<class arg1, int arg2>
113 class powProduct
115 public:
117     typedef typename symmTypeOfRank
118     <
119         typename pTraits<arg1>::cmptType,
120         arg2*int(pTraits<arg1>::rank)
121     >::type type;
124 #else
126 template<class arg1, class arg2>
127 class outerProduct
129 public:
131     typedef arg1 type;
135 template<class arg1, class arg2>
136 class crossProduct
138 public:
140     typedef arg1 type;
143 template<class arg1, class arg2>
144 class innerProduct
146 public:
148     typedef arg1 type;
151 template<class arg1, class arg2>
152 class scalarProduct
154 public:
156     typedef typename pTraits<arg1>::cmptType type;
160 template<class arg1, int arg2>
161 class powProduct
163 public:
165     typedef arg1 type;
168 #endif
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 } // End namespace Foam
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 #endif
179 // ************************************************************************* //