STK++ 0.9.13
STK_ExprBaseProduct.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Arrays
27 * created on: 26 nov. 2012
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
36#ifndef STK_EXPRBASEPRODUCT_H
37#define STK_EXPRBASEPRODUCT_H
38
39namespace STK
40{
41
42// this is the different class that will handle the product
43// there will be specialized for the different product cases
44// in the product folder
45template<typename Lhs, typename Rhs> class DotProduct;
46
47template<typename Lhs, typename Rhs> class ArrayByArrayProduct;
48template<typename Lhs, typename Rhs> class ArrayByVectorProduct;
49template<typename Lhs, typename Rhs> class ArrayByDiagonalProduct;
50
51template<typename Lhs, typename Rhs> class PointByArrayProduct;
52template<typename Lhs, typename Rhs> class VectorByPointProduct;
53
54template<typename Lhs, typename Rhs> class DiagonalByArrayProduct;
55template<typename Lhs, typename Rhs> class DiagonalByArrayProduct;
56
57
58namespace hidden
59{
66template<typename Lhs, typename Rhs, int LStructure_, int RStructure_>
71
72template<typename Lhs, typename Rhs, int LStructure_>
77
78template<typename Lhs, typename Rhs, int LStructure_>
83
84
85// point at left hand side
86template<typename Lhs, typename Rhs, int RStructure_>
91
92template<typename Lhs, typename Rhs>
97
98template<typename Lhs, typename Rhs>
105
106template<typename Lhs, typename Rhs>
107struct ProductSelector<Lhs, Rhs, Arrays::point_, Arrays::vector_>
108{
110};
111
112// vector as left hand side
113template<typename Lhs, typename Rhs>
116
117template<typename Lhs, typename Rhs>
124
125template<typename Lhs, typename Rhs, int RStructure_>
128
129// diagonal as left hand side
130template<typename Lhs, typename Rhs>
133
134template<typename Lhs, typename Rhs>
141
142// FIXME: will not work as UnaryOperator constructor take only Lhs
143template<typename Lhs, typename Rhs, int RStructure_>
144struct ProductSelector<Lhs, Rhs, Arrays::number_, RStructure_>
145{
146 typedef typename Rhs::Type Type;
148};
149
150// FIXME: will not work as UnaryOperator constructor take only Lhs
151template<typename Lhs, typename Rhs, int LStructure_>
152struct ProductSelector<Lhs, Rhs, LStructure_, Arrays::number_>
153{ typedef typename Lhs::Type Type;
155};
156
157} // namespace hidden
158
159
160template<typename Derived>
161template<typename Rhs>
164{
165 enum
166 {
167 rhs_structure_ = hidden::Traits<Rhs>::structure_,
168 productSizeIsValid_ =( sizeCols_ == UnknownSize
170 || int(sizeCols_) == int(hidden::Traits<Rhs>::sizeRows_)
171 ),
172 areVectors_ = ( structure_ == int(Arrays::vector_)
174 arePoints_ = ( structure_ == int(Arrays::point_)
176 haveSameSizeRows_ = ( sizeRows_ == UnknownSize
178 || int(sizeRows_) == int(hidden::Traits<Rhs>::sizeRows_)
179 ),
180 haveSameSizeCols_ = ( sizeCols_ == UnknownSize
182 || int(sizeCols_) == int(hidden::Traits<Rhs>::sizeCols_)
183 )
184 };
186
187 STK_STATIC_ASSERT(productSizeIsValid_ || !(areVectors_ && haveSameSizeRows_),INVALID_VECTOR_VECTOR_PRODUCT);
188 STK_STATIC_ASSERT(productSizeIsValid_ || !(arePoints_ && haveSameSizeCols_),INVALID_POINT_POINT_PRODUCT);
189
190 return ProductType(this->asDerived(), other.asDerived());
191}
192
193} // namespace STK
194
195#endif /* STK_EXPRBASEPRODUCT_H */
#define STK_STATIC_ASSERT(COND, MSG)
friend UnaryOperator< ProductWithOp< Type >, Derived > const operator*(Type const value, ExprBase< Derived > const &other)
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
@ point_
row oriented vector/array/expression
@ diagonal_
diagonal matrix/array/expression
@ vector_
column oriented vector/array/expression
const int UnknownSize
This value means that an integer is not known at compile-time, and that instead the value is stored i...
The namespace STK is the main domain space of the Statistical ToolKit project.
BinaryOperator< ProductOp< LType, RType >, Lhs, Rhs > ProductType
BinaryOperator< ProductOp< LType, RType >, Lhs, Rhs > ProductType
Helper class to select the correct ProductReturnType.
ArrayByArrayProduct< Lhs, Rhs > ProductType