annotate src/ov-mapper.h @ 4644:3b74f1a86750

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