1 %module template_typedef_cplx
4 // Change this to #if 1 to test the 'test'
10 typedef std::complex<double> cmplx;
14 typedef cmplx Complex;
21 typedef std::complex<double> Complex;
31 struct UnaryFunctionBase
35 template <class ArgType, class ResType>
38 template <class ArgType, class ResType>
39 struct ArithUnaryFunction;
41 template <class ArgType, class ResType>
42 struct UnaryFunction : UnaryFunctionBase
46 template <class ArgType, class ResType>
47 struct ArithUnaryFunction : UnaryFunction<ArgType, ResType>
51 template <class ArgType, class ResType>
52 struct unary_func_traits
54 typedef ArithUnaryFunction<ArgType, ResType > base;
57 template <class ArgType>
59 typename unary_func_traits< ArgType, ArgType >::base
62 return typename unary_func_traits< ArgType, ArgType >::base();
65 template <class Arg1, class Arg2>
71 struct arith_traits< double, double >
74 typedef double argument_type;
75 typedef double result_type;
76 static const char* const arg_type;
77 static const char* const res_type;
81 struct arith_traits< Complex, Complex >
84 typedef Complex argument_type;
85 typedef Complex result_type;
86 static const char* const arg_type;
87 static const char* const res_type;
91 struct arith_traits< Complex, double >
93 typedef double argument_type;
94 typedef Complex result_type;
95 static const char* const arg_type;
96 static const char* const res_type;
100 struct arith_traits< double, Complex >
102 typedef double argument_type;
103 typedef Complex result_type;
104 static const char* const arg_type;
105 static const char* const res_type;
108 template <class AF, class RF, class AG, class RG>
110 ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
111 typename arith_traits< RF, RG >::result_type >
112 make_Multiplies(const ArithUnaryFunction<AF, RF>& f,
113 const ArithUnaryFunction<AG, RG >& g)
116 ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
117 typename arith_traits< RF, RG >::result_type>();
122 // Initialize these static class members
124 const char* const arith_traits< double, double >::arg_type = "double";
125 const char* const arith_traits< double, double >::res_type = "double";
127 const char* const arith_traits< Complex, Complex >::arg_type = "complex";
128 const char* const arith_traits< Complex, Complex >::res_type = "complex";
130 const char* const arith_traits< Complex, double>::arg_type = "double";
131 const char* const arith_traits< Complex, double >::res_type = "complex";
133 const char* const arith_traits< double, Complex >::arg_type = "double";
134 const char* const arith_traits< double, Complex >::res_type = "complex";
142 %template(UnaryFunction_double_double) UnaryFunction<double, double >;
143 %template(ArithUnaryFunction_double_double) ArithUnaryFunction<double, double >;
144 %template() unary_func_traits<double, double >;
145 %template() arith_traits<double, double >;
146 %template(make_Identity_double) make_Identity<double >;
148 %template(UnaryFunction_complex_complex) UnaryFunction<Complex, Complex >;
149 %template(ArithUnaryFunction_complex_complex) ArithUnaryFunction<Complex, Complex >;
151 %template() unary_func_traits<Complex, Complex >;
152 %template() arith_traits<Complex, Complex >;
153 %template(make_Identity_complex) make_Identity<Complex >;
155 /* [beazley] Added this part */
156 %template() unary_func_traits<double,Complex>;
157 %template(UnaryFunction_double_complex) UnaryFunction<double,Complex>;
158 %template(ArithUnaryFunction_double_complex) ArithUnaryFunction<double,Complex>;
162 %template() arith_traits<Complex, double >;
163 %template() arith_traits<double, Complex >;
165 %template(make_Multiplies_double_double_complex_complex)
166 make_Multiplies<double, double, Complex, Complex>;
168 %template(make_Multiplies_double_double_double_double)
169 make_Multiplies<double, double, double, double>;
171 %template(make_Multiplies_complex_complex_complex_complex)
172 make_Multiplies<Complex, Complex, Complex, Complex>;
174 %template(make_Multiplies_complex_complex_double_double)
175 make_Multiplies<Complex, Complex, double, double>;