1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
383
|
23 #if !defined (octave_mappers_h) |
|
24 #define octave_mappers_h 1 |
1
|
25 |
1755
|
26 #include <string> |
|
27 |
1968
|
28 #include "lo-mappers.h" |
1651
|
29 #include "oct-cmplx.h" |
1
|
30 |
2087
|
31 typedef int (*ch_Mapper)(int); |
529
|
32 typedef double (*d_d_Mapper)(double); |
|
33 typedef double (*d_c_Mapper)(const Complex&); |
|
34 typedef Complex (*c_c_Mapper)(const Complex&); |
|
35 |
2087
|
36 // ch_mapper is a kluge. |
|
37 // |
529
|
38 // If can_return_complex_for_real_arg is 1, lower_limit and |
|
39 // upper_limit specify the range of values for which a real arg |
|
40 // returns a real value. Outside that range, we have to convert args |
|
41 // to complex, and call the complex valued function. |
|
42 // |
|
43 // If can_return_complex_for_real_arg is 0, lower_limit and |
|
44 // upper_limit are ignored. |
|
45 |
|
46 struct builtin_mapper_function |
|
47 { |
2089
|
48 builtin_mapper_function (ch_Mapper ch = 0, d_d_Mapper dd = 0, |
|
49 d_c_Mapper dc = 0, c_c_Mapper cc = 0, |
2275
|
50 double l = 0.0, double u = 0.0, int f = 0, |
2089
|
51 const string n = string (), |
|
52 const string& h = string ()) |
2087
|
53 : ch_mapper (ch), d_d_mapper (dd), d_c_mapper (dc), c_c_mapper (cc), |
2275
|
54 lower_limit (l), upper_limit (u), flag (f), |
2087
|
55 name (n), help_string (h) { } |
1755
|
56 |
2089
|
57 builtin_mapper_function (const builtin_mapper_function& mf) |
|
58 : ch_mapper (mf.ch_mapper), d_d_mapper (mf.d_d_mapper), |
|
59 d_c_mapper (mf.d_c_mapper), c_c_mapper (mf.c_c_mapper), |
|
60 lower_limit (mf.lower_limit), upper_limit (mf.upper_limit), |
2275
|
61 flag (mf.flag), name (mf.name), help_string (mf.help_string) { } |
2089
|
62 |
|
63 builtin_mapper_function& operator = (const builtin_mapper_function& mf) |
|
64 { |
|
65 if (&mf != this) |
|
66 { |
|
67 ch_mapper = mf.ch_mapper; |
|
68 d_d_mapper = mf.d_d_mapper; |
|
69 d_c_mapper = mf.d_c_mapper; |
|
70 c_c_mapper = mf.c_c_mapper; |
|
71 lower_limit = mf.lower_limit; |
|
72 upper_limit = mf.upper_limit; |
2275
|
73 flag = mf.flag; |
2089
|
74 name = mf.name; |
|
75 help_string = mf.help_string; |
|
76 } |
|
77 return *this; |
|
78 } |
|
79 |
|
80 ~builtin_mapper_function (void) { } |
|
81 |
2087
|
82 ch_Mapper ch_mapper; |
529
|
83 d_d_Mapper d_d_mapper; |
|
84 d_c_Mapper d_c_mapper; |
|
85 c_c_Mapper c_c_mapper; |
2087
|
86 double lower_limit; |
|
87 double upper_limit; |
2275
|
88 |
|
89 // For ch_mapper: |
|
90 // |
|
91 // 0 => this function returns a matrix of ones and zeros |
|
92 // 1 => this function returns a numeric matrix (any values) |
|
93 // 2 => this function returns a string array |
|
94 // |
|
95 // For other mappers, nonzero means that this function can return a |
|
96 // complex value for some real arguments. |
|
97 int flag; |
|
98 |
2087
|
99 string name; |
1755
|
100 string help_string; |
529
|
101 }; |
1
|
102 |
529
|
103 extern void install_mapper_functions (void); |
|
104 |
1
|
105 #endif |
|
106 |
|
107 /* |
|
108 ;;; Local Variables: *** |
|
109 ;;; mode: C++ *** |
|
110 ;;; End: *** |
|
111 */ |