1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library
2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra.
3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla
8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed
9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is a base class plugin containing common coefficient wise functions.
12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the difference of \c *this and \a other
14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-().
16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseBinaryOp, operator-=()
18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op)
20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the sum of \c *this and \a other
22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \note If you want to add a given scalar to all coefficients, see Cwise::operator+().
24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseBinaryOp, operator+=()
26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_MAKE_CWISE_BINARY_OP(operator+,internal::scalar_sum_op)
28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other
30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameter \a CustomBinaryOp is the type of the functor
32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * of the custom operator (see class CwiseBinaryOp for an example)
33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Here is an example illustrating the use of custom functors:
35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \include class_CwiseBinaryOp.cpp
36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude class_CwiseBinaryOp.out
37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct()
39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename CustomBinaryOp, typename OtherDerived>
41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>
42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathbinaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const
43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>(derived(), other.derived(), func);
45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
47