2974
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_mapper_h) |
|
24 #define octave_mapper_h 1 |
|
25 |
4066
|
26 #if defined (__GNUG__) && ! defined (NO_PRAGMA_INTERFACE_IMPLEMENTATION) |
2974
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
4055
|
32 #include "oct-obj.h" |
2974
|
33 #include "ov-fcn.h" |
|
34 #include "ov-typeinfo.h" |
|
35 |
|
36 class octave_value; |
|
37 class octave_value_list; |
|
38 |
|
39 // Builtin mapper functions. |
|
40 |
|
41 class |
|
42 octave_mapper : public octave_function |
|
43 { |
|
44 public: |
|
45 |
|
46 typedef int (*ch_mapper) (int); |
3249
|
47 typedef bool (*d_b_mapper) (double); |
|
48 typedef bool (*c_b_mapper) (const Complex&); |
2974
|
49 typedef double (*d_d_mapper) (double); |
|
50 typedef double (*d_c_mapper) (const Complex&); |
|
51 typedef Complex (*c_c_mapper) (const Complex&); |
|
52 |
3249
|
53 octave_mapper (ch_mapper ch, d_b_mapper db, c_b_mapper cb, |
|
54 d_d_mapper dd, d_c_mapper dc, |
4100
|
55 c_c_mapper cc, double ll, double ul, |
|
56 int cmf, bool crcfr, |
3523
|
57 const std::string& nm = std::string (), |
|
58 const std::string& ds = std::string ()) |
3249
|
59 : octave_function (nm, ds), ch_map_fcn (ch), |
|
60 d_b_map_fcn (db), c_b_map_fcn (cb), |
|
61 d_d_map_fcn (dd), d_c_map_fcn (dc), c_c_map_fcn (cc), |
4100
|
62 lower_limit (ll), upper_limit (ul), ch_map_flag (cmf), |
|
63 can_ret_cmplx_for_real (crcfr) { } |
2974
|
64 |
|
65 ~octave_mapper (void) { } |
|
66 |
|
67 octave_function *function_value (bool) { return this; } |
|
68 |
3933
|
69 octave_value_list subsref (const std::string type, |
|
70 const SLList<octave_value_list>& idx, |
|
71 int nargout); |
|
72 |
3544
|
73 octave_value_list |
|
74 do_multi_index_op (int nargout, const octave_value_list& args); |
2974
|
75 |
|
76 private: |
|
77 |
|
78 octave_mapper (void); |
|
79 |
|
80 octave_mapper (const octave_mapper& m); |
|
81 |
|
82 octave_value apply (const octave_value& arg) const; |
|
83 |
|
84 // ch_map_fcn is a kluge. |
|
85 |
|
86 ch_mapper ch_map_fcn; |
3249
|
87 d_b_mapper d_b_map_fcn; |
|
88 c_b_mapper c_b_map_fcn; |
2974
|
89 d_d_mapper d_d_map_fcn; |
|
90 d_c_mapper d_c_map_fcn; |
|
91 c_c_mapper c_c_map_fcn; |
|
92 |
|
93 // If flag is nonzero and we are not calling ch_map_fcn, lower_limit |
|
94 // and upper_limit specify the range of values for which a real arg |
|
95 // returns a real value. Outside that range, we have to convert args |
|
96 // to complex, and call the complex valued function. |
|
97 |
|
98 double lower_limit; |
|
99 double upper_limit; |
|
100 |
4100
|
101 // ch_map_flag has the following meanings: |
2974
|
102 // |
|
103 // 0 => this function returns a matrix of ones and zeros |
|
104 // 1 => this function returns a numeric matrix (any values) |
3523
|
105 // 2 => this function returns a std::string array |
4100
|
106 |
|
107 int ch_map_flag; |
2974
|
108 |
4100
|
109 // can_ret_cmplx_for_real is a flag that says whether this function |
|
110 // can create a complex number given a real-valued argument |
|
111 // (e.g., sqrt (-1)). |
|
112 |
|
113 bool can_ret_cmplx_for_real; |
2974
|
114 |
3219
|
115 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974
|
116 |
3219
|
117 DECLARE_OCTAVE_ALLOCATOR |
2974
|
118 }; |
|
119 |
|
120 #endif |
|
121 |
|
122 /* |
|
123 ;;; Local Variables: *** |
|
124 ;;; mode: C++ *** |
|
125 ;;; End: *** |
|
126 */ |