aboutsummaryrefslogtreecommitdiffhomepage
path: root/tvmet-1.7.1/include/tvmet/UnaryFunctionals.h
blob: 3ba35f2e3580bff6497c26840bece022c92f9617 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Tiny Vector Matrix Library
 * Dense Vector Matrix Libary of Tiny size using Expression Templates
 *
 * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: UnaryFunctionals.h,v 1.18 2004/10/04 11:44:42 opetzold Exp $
 */

#ifndef TVMET_UNARY_FUNCTIONAL_H
#define TVMET_UNARY_FUNCTIONAL_H

namespace tvmet {

/** \class Fcnl_compl	UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */
/** \class Fcnl_neg		UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */
#define TVMET_IMPLEMENT_MACRO(NAME, OP)					\
template <class T>							\
struct Fcnl_##NAME : public UnaryFunctional {				\
  typedef T						value_type;	\
									\
  static inline 							\
  value_type apply_on(value_type rhs) {					\
    return OP rhs;							\
  }									\
  									\
  static 								\
  void print_xpr(std::ostream& os, int l=0) {			\
    os << IndentLevel(l) << "Fcnl_" << #NAME << "<T="			\
       << typeid(T).name() << ">,"					\
       << std::endl;							\
  }									\
};

TVMET_IMPLEMENT_MACRO(neg, -)
#undef TVMET_IMPLEMENT_MACRO

/*
 * complex support
 */


#if defined(EIGEN_USE_COMPLEX)

/**
 * \class Fcnl_conj< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h"
 * \brief %Functional for conj.
 */
template <class T> struct Fcnl_conj : public UnaryFunctional { };


/** \class Fcnl_conj< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */
template <class T>
struct Fcnl_conj< std::complex<T> > : public UnaryFunctional {
  typedef std::complex<T>                               value_type;

  static inline
  value_type apply_on(const std::complex<T>& rhs) {
    return std::conj(rhs);
  }

  static
  void print_xpr(std::ostream& os, int l=0) {
    os << IndentLevel(l) << "Fcnl_conj<T="
       << typeid(std::complex<T>).name() << ">,"
       << std::endl;
  }
};


/** \class Fcnl_real< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */
/** \class Fcnl_imag< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */
#define TVMET_IMPLEMENT_MACRO(NAME)					\
template <class T> struct Fcnl_##NAME;					\
template <class T>							\
struct Fcnl_##NAME< std::complex<T> > : public UnaryFunctional {	\
  typedef T						value_type;	\
									\
  static inline 							\
  value_type apply_on(const std::complex<T>& rhs) {			\
    return TVMET_STD_SCOPE(NAME)(rhs);					\
  }									\
  									\
  static 								\
  void print_xpr(std::ostream& os, int l=0) {			\
    os << IndentLevel(l) << "Fcnl_" << #NAME << "<T="			\
       << typeid(std::complex<T>).name() << ">,"			\
       << std::endl;							\
  }									\
};

TVMET_IMPLEMENT_MACRO(real)
TVMET_IMPLEMENT_MACRO(imag)

#undef TVMET_IMPLEMENT_MACRO

#endif // defined(EIGEN_USE_COMPLEX)

} // namespace tvmet

#endif // TVMET_UNARY_FUNCTIONAL_H

// Local Variables:
// mode:C++
// End: