annotate src/pt-const.h @ 453:393e95f46b51

[project @ 1994-06-06 00:05:20 by jwe]
author jwe
date Mon, 06 Jun 1994 00:14:55 +0000
parents 5e778965b6ea
children 8c6b86564cee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 // The rest of the tree classes. -*- C++ -*-
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
3
296
3c23b8ea9099 [project @ 1994-01-17 02:49:15 by jwe]
jwe
parents: 276
diff changeset
4 Copyright (C) 1992, 1993, 1994 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11 later version.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, write to the Free
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23
383
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 296
diff changeset
24 #if !defined (octave_tree_const_h)
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 296
diff changeset
25 #define octave_tree_const_h 1
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27 #include <stdlib.h>
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29 #include "builtins.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
30 #include "tree-base.h"
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
31 #include "Matrix.h" // Needed for some inline functions.
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
32 #include "Range.h" // Ditto.
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
33
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
34 class idx_vector;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
35
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
36 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
37 * How about a few macros?
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
38 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
39
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
40 #ifndef MAX
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
41 #define MAX(a,b) ((a) > (b) ? (a) : (b))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
42 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
43
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
44 #ifndef MIN
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45 #define MIN(a,b) ((a) < (b) ? (a) : (b))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
47
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
48 #ifndef ABS
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
49 #define ABS(x) (((x) < 0) ? (-x) : (x))
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
50 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
51
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
52 #ifndef NULL_TREE
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53 #define NULL_TREE (tree *)NULL
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
54 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
55
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56 #ifndef NULL_TREE_CONST
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
57 #define NULL_TREE_CONST (tree_constant *)NULL
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
58 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
60 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
61 * The following are used by some of the functions in the
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
62 * tree_constant_rep class that must deal with real and complex
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
63 * matrices. This was not done with overloaded or virtual functions
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
64 * from the Matrix class because there is no clean way to do that --
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
65 * the necessary functions (like elem) need to return values of
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
66 * different types...
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
67 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
68
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
69 // Given a tree_constant, and the names to be used for the real and
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
70 // complex matrix and their dimensions, declare a real or complex
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
71 // matrix, and initialize it from the tree_constant. Note that m, cm,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
72 // nr, and nc must not be previously declared, and they must not be
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
73 // expressions. Since only one of the matrices will be defined after
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
74 // this macro is used, only one set of dimesions is declared.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
75
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
76 // This macro only makes sense inside a friend or member function of
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
77 // the tree_constant_rep class
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
78
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
79 #define REP_RHS_MATRIX(tc,m,cm,nr,nc) \
399
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
80 int nr = 0; \
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
81 int nc = 0; \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
82 Matrix m; \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
83 ComplexMatrix cm; \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
84 if ((tc).const_type () == tree_constant_rep::complex_matrix_constant) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
85 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
86 cm = (tc).complex_matrix_value (); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
87 nr = (cm).rows (); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
88 nc = (cm).columns (); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
89 } \
399
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
90 else if ((tc).const_type () == tree_constant_rep::matrix_constant) \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
91 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
92 m = (tc).matrix_value (); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
93 nr = (m).rows (); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
94 nc = (m).columns (); \
399
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
95 } \
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
96 else \
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
97 abort ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
98
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
99 // Assign a real or complex value to a tree_constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
100 //
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
101 // This macro only makes sense inside a friend or member function of
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
102 // the tree_constant_rep class.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
103
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
104 #define REP_ELEM_ASSIGN(i,j,rval,cval,real_type) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
105 do \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
106 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
107 if (type_tag == tree_constant_rep::matrix_constant) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
108 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
109 if (real_type) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
110 matrix->elem ((i), (j)) = (rval); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
111 else \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
112 abort (); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
113 } \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
114 else \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
115 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
116 if (real_type) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
117 complex_matrix->elem ((i), (j)) = (rval); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
118 else \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
119 complex_matrix->elem ((i), (j)) = (cval); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
120 } \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
121 } \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
122 while (0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
123
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
124 // Given a real and complex matrix and row and column dimensions,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
125 // declare both and size one of them. Only one of the matrices should
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
126 // be used after this macro has been used.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
127
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
128 // This macro only makes sense inside a friend or member function of
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
129 // the tree_constant_rep class.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
130
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
131 #define CRMATRIX(m,cm,nr,nc) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
132 Matrix m; \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
133 ComplexMatrix cm; \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
134 if (type_tag == tree_constant_rep::matrix_constant) \
399
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
135 (m).resize ((nr), (nc)); \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
136 else if (type_tag == complex_matrix_constant) \
399
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
137 (cm).resize ((nr), (nc)); \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
138 else \
399
e3228e053d06 [project @ 1994-04-09 23:01:20 by jwe]
jwe
parents: 383
diff changeset
139 abort (); \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
140
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
141 // Assign a real or complex matrix to a tree constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
142
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
143 // This macro only makes sense inside a friend or member function of
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
144 // the tree_constant_rep class.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
145
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
146 #define ASSIGN_CRMATRIX_TO(tc,m,cm) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
147 do \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
148 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
149 if (type_tag == matrix_constant) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
150 tc = tree_constant (m); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
151 else \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
152 tc = tree_constant (cm); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
153 } \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
154 while (0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
155
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
156 // Assign an element of this tree_constant_rep's real or complex
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
157 // matrix to another real or complex matrix.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
158
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
159 // This macro only makes sense inside a friend or member function of
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
160 // the tree_constant_rep class.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
161
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
162 #define CRMATRIX_ASSIGN_REP_ELEM(m,cm,i1,j1,i2,j2) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
163 do \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
164 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
165 if (type_tag == matrix_constant) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
166 (m).elem ((i1), (j1)) = matrix->elem ((i2), (j2)); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
167 else \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
168 (cm).elem ((i1), (j1)) = complex_matrix->elem ((i2), (j2)); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
169 } \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
170 while (0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
171
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
172 // Assign a value to an element of a real or complex matrix. Assumes
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
173 // that the lhs and rhs are either both real or both complex types.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
174
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
175 #define CRMATRIX_ASSIGN_ELEM(m,cm,i,j,rval,cval,real_type) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
176 do \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
177 { \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
178 if (real_type) \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
179 (m).elem ((i), (j)) = (rval); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
180 else \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
181 (cm).elem ((i), (j)) = (cval); \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
182 } \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
183 while (0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
184
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
185
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
186 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
187 * Forward class declarations.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
188 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
189 class tree;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
190 class tree_constant;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
191
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
192 #ifndef TREE_FCN_TYPEDEFS
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
193 #define TREE_FCN_TYPEDEFS 1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
194
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
195 typedef tree_constant (*Text_fcn)(int, char **);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
196 typedef tree_constant* (*General_fcn)(tree_constant *, int, int);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
197
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
198 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
199
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
200 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
201 * The actual representation of the tree_constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
202 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
203 class
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
204 tree_constant_rep
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
205 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
206 friend class tree_constant;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
207
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
208 enum force_orient
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
209 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
210 no_orient,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
211 row_orient,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
212 column_orient,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
213 };
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
214
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
215 public:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
216 enum constant_type
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
217 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
218 unknown_constant,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
219 scalar_constant,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
220 matrix_constant,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
221 complex_scalar_constant,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
222 complex_matrix_constant,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
223 string_constant,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
224 range_constant,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
225 magic_colon,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
226 };
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
227
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
228 tree_constant_rep (void);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
229
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
230 tree_constant_rep (double d);
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
231 tree_constant_rep (const Matrix& m);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
232 tree_constant_rep (const DiagMatrix& d);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
233 tree_constant_rep (const RowVector& v);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
234 tree_constant_rep (const RowVector& v, int pcv);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
235 tree_constant_rep (const ColumnVector& v);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
236 tree_constant_rep (const ColumnVector& v, int pcv);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
237
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
238 tree_constant_rep (const Complex& c);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
239 tree_constant_rep (const ComplexMatrix& m);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
240 tree_constant_rep (const ComplexDiagMatrix& d);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
241 tree_constant_rep (const ComplexRowVector& v);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
242 tree_constant_rep (const ComplexRowVector& v, int pcv);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
243 tree_constant_rep (const ComplexColumnVector& v);
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
244 tree_constant_rep (const ComplexColumnVector& v, int pcv);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
245
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
246 tree_constant_rep (const char *s);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
247
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
248 tree_constant_rep (double base, double limit, double inc);
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
249 tree_constant_rep (const Range& r);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
250
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
251 tree_constant_rep (tree_constant_rep::constant_type t);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
252
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
253 tree_constant_rep (const tree_constant_rep& t);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
254
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
255 ~tree_constant_rep (void);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
256
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
257 #if defined (MDEBUG)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
258 void *operator new (size_t size);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
259 void operator delete (void *p, size_t size);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
260 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
261
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
262 void resize (int i, int j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
263 void resize (int i, int j, double val);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
264
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
265 void maybe_resize (int imax, force_orient fo = no_orient);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
266 void maybe_resize (int imax, int jmax);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
267
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
268 int valid_as_scalar_index (void) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
269
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
270 int is_defined (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
271 { return type_tag != tree_constant_rep::unknown_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
272
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
273 int is_undefined (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
274 { return type_tag == tree_constant_rep::unknown_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
275
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
276 int is_string_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
277 { return type_tag == tree_constant_rep::string_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
278
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
279 int is_scalar_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
280 { return type_tag == scalar_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
281 || type_tag == complex_scalar_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
282
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
283 int is_matrix_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
284 { return type_tag == matrix_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
285 || type_tag == complex_matrix_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
286
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
287 int is_real_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
288 { return type_tag == scalar_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
289 || type_tag == matrix_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
290 || type_tag == range_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
291
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
292 int is_complex_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
293 { return type_tag == complex_matrix_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
294 || type_tag == complex_scalar_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
295
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
296
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
297 int is_numeric_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
298 { return type_tag == scalar_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
299 || type_tag == matrix_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
300 || type_tag == complex_matrix_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
301 || type_tag == complex_scalar_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
302
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
303 int is_numeric_or_range_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
304 { return type_tag == scalar_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
305 || type_tag == matrix_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
306 || type_tag == complex_matrix_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
307 || type_tag == complex_scalar_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
308 || type_tag == range_constant; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
309
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
310 double to_scalar (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
311 ColumnVector to_vector (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
312 Matrix to_matrix (void) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
313
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
314 tree_constant_rep::constant_type force_numeric (int force_str_conv = 0);
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
315 tree_constant make_numeric (int force_str_conv = 0) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
316
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
317 friend tree_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
318 do_binary_op (tree_constant& a, tree_constant& b, tree::expression_type t);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
319
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
320 friend tree_constant
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
321 do_unary_op (tree_constant& a, tree::expression_type t);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
322
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
323 void assign (tree_constant& rhs, tree_constant *args, int nargs);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
324
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
325 void do_scalar_assignment
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
326 (tree_constant& rhs, tree_constant *args, int nargin);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
327
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
328 void do_matrix_assignment
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
329 (tree_constant& rhs, tree_constant *args, int nargin);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
330
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
331 void do_matrix_assignment
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
332 (tree_constant& rhs, tree_constant& i_arg);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
333
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
334 void do_matrix_assignment
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
335 (tree_constant& rhs, tree_constant& i_arg, tree_constant& j_arg);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
336
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
337 void fortran_style_matrix_assignment (tree_constant& rhs,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
338 tree_constant& i_arg);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
339
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
340 void fortran_style_matrix_assignment (tree_constant& rhs, constant_type ci);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
341
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
342 void fortran_style_matrix_assignment (tree_constant& rhs, idx_vector& i);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
343
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
344 void vector_assignment (tree_constant& rhs, tree_constant& i_arg);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
345
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
346 void check_vector_assign (int rhs_nr, int rhs_nc, int ilen,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
347 const char *rm);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
348
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
349 void do_vector_assign (tree_constant& rhs, int i);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
350 void do_vector_assign (tree_constant& rhs, idx_vector& i);
212
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
351 void do_vector_assign (tree_constant& rhs, Range& i);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
352
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
353 void do_matrix_assignment
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
354 (tree_constant& rhs, int i, tree_constant& j_arg);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
355 void do_matrix_assignment
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
356 (tree_constant& rhs, idx_vector& i, tree_constant& j_arg);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
357 void do_matrix_assignment
212
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
358 (tree_constant& rhs, Range& i, tree_constant& j_arg);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
359 void do_matrix_assignment
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
360 (tree_constant& rhs, constant_type i, tree_constant& j_arg);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
361
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
362 void do_matrix_assignment (tree_constant& rhs, int i, int j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
363 void do_matrix_assignment (tree_constant& rhs, int i, idx_vector& jv);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
364 void do_matrix_assignment (tree_constant& rhs, int i, Range& j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
365 void do_matrix_assignment (tree_constant& rhs, int i, constant_type cj);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
366
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
367 void do_matrix_assignment (tree_constant& rhs, idx_vector& iv, int j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
368 void do_matrix_assignment (tree_constant& rhs, idx_vector& iv,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
369 idx_vector& jv);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
370 void do_matrix_assignment (tree_constant& rhs, idx_vector& iv, Range& j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
371 void do_matrix_assignment (tree_constant& rhs, idx_vector& iv,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
372 constant_type j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
373
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
374 void do_matrix_assignment (tree_constant& rhs, Range& i, int j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
375 void do_matrix_assignment (tree_constant& rhs, Range& i, idx_vector& jv);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
376 void do_matrix_assignment (tree_constant& rhs, Range& i, Range& j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
377 void do_matrix_assignment (tree_constant& rhs, Range& i, constant_type j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
378
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
379 void do_matrix_assignment (tree_constant& rhs, constant_type i, int j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
380 void do_matrix_assignment (tree_constant& rhs, constant_type i,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
381 idx_vector& jv);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
382 void do_matrix_assignment (tree_constant& rhs, constant_type i, Range& j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
383 void do_matrix_assignment (tree_constant& rhs, constant_type i,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
384 constant_type j);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
385
208
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
386 void delete_row (int);
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
387 void delete_rows (idx_vector& i);
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
388 void delete_rows (Range& i);
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
389
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
390 void delete_column (int);
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
391 void delete_columns (idx_vector& j);
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
392 void delete_columns (Range& j);
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
393
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
394 void bump_value (tree::expression_type);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
395
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
396 void eval (int print);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
397
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
398 tree_constant *eval (const tree_constant *args, int n_in, int n_out,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
399 int print);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
400
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
401 tree_constant do_scalar_index (const tree_constant *args,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
402 int nargin) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
403
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
404 tree_constant do_matrix_index (const tree_constant *args, int nargin) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
405
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
406 tree_constant do_matrix_index (const tree_constant& i_arg) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
407
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
408 tree_constant do_matrix_index (const tree_constant& i_arg,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
409 const tree_constant& j_arg) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
410
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
411 tree_constant do_matrix_index (constant_type i) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
412
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
413 tree_constant fortran_style_matrix_index (const tree_constant& i_arg) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
414 tree_constant fortran_style_matrix_index (const Matrix& mi) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
415
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
416 tree_constant do_vector_index (const tree_constant& i_arg) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
417
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
418 tree_constant do_matrix_index (int i, const tree_constant& i_arg) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
419 tree_constant do_matrix_index (const idx_vector& i,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
420 const tree_constant& i_arg) const;
212
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
421 tree_constant do_matrix_index (const Range& i,
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
422 const tree_constant& i_arg) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
423 tree_constant do_matrix_index (constant_type i,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
424 const tree_constant& i_arg) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
425
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
426 tree_constant do_matrix_index (int i, int j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
427 tree_constant do_matrix_index (int i, const idx_vector& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
428 tree_constant do_matrix_index (int i, const Range& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
429 tree_constant do_matrix_index (int i, constant_type cj) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
430
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
431 tree_constant do_matrix_index (const idx_vector& i, int j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
432 tree_constant do_matrix_index (const idx_vector& i,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
433 const idx_vector& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
434 tree_constant do_matrix_index (const idx_vector& i, const Range& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
435 tree_constant do_matrix_index (const idx_vector& i, constant_type j) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
436
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
437 tree_constant do_matrix_index (const Range& i, int j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
438 tree_constant do_matrix_index (const Range& i, const idx_vector& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
439 tree_constant do_matrix_index (const Range& i, const Range& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
440 tree_constant do_matrix_index (const Range& i, constant_type j) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
441
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
442 tree_constant do_matrix_index (constant_type i, int j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
443 tree_constant do_matrix_index (constant_type i, const idx_vector& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
444 tree_constant do_matrix_index (constant_type i, const Range& j) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
445 tree_constant do_matrix_index (constant_type i, constant_type j) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
446
276
4cf3c7df0e3d [project @ 1994-01-07 02:05:57 by jwe]
jwe
parents: 259
diff changeset
447 int save (ostream& os, int mark_as_global, int precision);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
448 int save_three_d (ostream& os, int parametric);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
449 int load (istream& is);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
450 constant_type load (istream& is, constant_type t);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
451
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
452 double double_value (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
453 Matrix matrix_value (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
454 Complex complex_value (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
455 ComplexMatrix complex_matrix_value (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
456 char *string_value (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
457 Range range_value (void) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
458
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
459 int rows (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
460 int columns (void) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
461
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
462 tree_constant all (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
463 tree_constant any (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
464 tree_constant isstr (void) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
465
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
466 tree_constant convert_to_str (void);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
467
435
5e778965b6ea [project @ 1994-05-25 23:59:02 by jwe]
jwe
parents: 428
diff changeset
468 void convert_to_row_or_column_vector (void);
5e778965b6ea [project @ 1994-05-25 23:59:02 by jwe]
jwe
parents: 428
diff changeset
469
428
fa0453b25410 [project @ 1994-05-25 01:06:28 by jwe]
jwe
parents: 399
diff changeset
470 int is_true (void) const;
fa0453b25410 [project @ 1994-05-25 01:06:28 by jwe]
jwe
parents: 399
diff changeset
471
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
472 tree_constant cumprod (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
473 tree_constant cumsum (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
474 tree_constant prod (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
475 tree_constant sum (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
476 tree_constant sumsq (void) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
477
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
478 tree_constant diag (void) const;
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
479 tree_constant diag (const tree_constant& a) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
480
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
481 friend tree_constant fill_matrix (const tree_constant& a,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
482 double d, const char *warn_for);
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
483 friend tree_constant fill_matrix (const tree_constant& a,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
484 const tree_constant& b,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
485 double d, const char *warn_for);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
486
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
487 friend tree_constant identity_matrix (const tree_constant& a);
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
488 friend tree_constant identity_matrix (const tree_constant& a,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
489 const tree_constant& b);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
490
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
491 friend tree_constant find_nonzero_elem_idx (const tree_constant& a);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
492
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
493 friend tree_constant *matrix_log (const tree_constant& a);
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
494 friend tree_constant *matrix_sqrt (const tree_constant& a);
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
495
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
496 friend tree_constant *column_max (const tree_constant *args, int nargin,
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
497 int nargout);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
498
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
499 friend tree_constant *column_min (const tree_constant *args, int nargin,
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
500 int nargout);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
501
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
502 friend tree_constant *sort (const tree_constant *args, int nargin,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
503 int nargout);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
504
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
505 friend tree_constant *feval (const tree_constant *args, int nargin,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
506 int nargout);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
507
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
508 friend tree_constant eval_string (const tree_constant& arg, int&
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
509 parse_status);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
510
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
511 friend tree_constant get_user_input (const tree_constant *args,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
512 int nargin, int nargout,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
513 int debug = 0);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
514
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
515 constant_type const_type (void) const { return type_tag; }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
516
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
517 tree_constant mapper (Mapper_fcn& m_fcn, int print) const;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
518
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
519 private:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
520 int count;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
521 constant_type type_tag;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
522 union
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
523 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
524 double scalar; // A real scalar constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
525 Matrix *matrix; // A real matrix constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
526 Complex *complex_scalar; // A real scalar constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
527 ComplexMatrix *complex_matrix; // A real matrix constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
528 char *string; // A character string constant.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
529 Range *range; // A set of evenly spaced values.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
530 };
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
531 };
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
532
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
533 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
534 * Constants. Nice -- No need to interpret them anymore. Logically,
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
535 * this should be ahead of the tree_constant_rep class, but that
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
536 * causes problems with my version of g++ (~2.2.2)...
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
537 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
538 class tree_constant : public tree
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
539 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
540 friend class tree_constant_rep;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
541
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
542 public:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
543 tree_constant (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
544 { rep = new tree_constant_rep (); rep->count = 1; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
545
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
546 tree_constant (double d)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
547 { rep = new tree_constant_rep (d); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
548 tree_constant (const Matrix& m)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
549 { rep = new tree_constant_rep (m); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
550 tree_constant (const DiagMatrix& d)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
551 { rep = new tree_constant_rep (d); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
552 tree_constant (const RowVector& v)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
553 { rep = new tree_constant_rep (v); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
554 tree_constant (const RowVector& v, int pcv)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
555 { rep = new tree_constant_rep (v, pcv); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
556 tree_constant (const ColumnVector& v)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
557 { rep = new tree_constant_rep (v); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
558 tree_constant (const ColumnVector& v, int pcv)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
559 { rep = new tree_constant_rep (v, pcv); rep->count = 1; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
560
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
561 tree_constant (const Complex& c)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
562 { rep = new tree_constant_rep (c); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
563 tree_constant (const ComplexMatrix& m)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
564 { rep = new tree_constant_rep (m); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
565 tree_constant (const ComplexDiagMatrix& d)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
566 { rep = new tree_constant_rep (d); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
567 tree_constant (const ComplexRowVector& v)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
568 { rep = new tree_constant_rep (v); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
569 tree_constant (const ComplexRowVector& v, int pcv)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
570 { rep = new tree_constant_rep (v, pcv); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
571 tree_constant (const ComplexColumnVector& v)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
572 { rep = new tree_constant_rep (v); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
573 tree_constant (const ComplexColumnVector& v, int pcv)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
574 { rep = new tree_constant_rep (v, pcv); rep->count = 1; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
575
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
576 tree_constant (const char *s)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
577 { rep = new tree_constant_rep (s); rep->count = 1; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
578
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
579 tree_constant (double base, double limit, double inc)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
580 { rep = new tree_constant_rep (base, limit, inc); rep->count = 1; }
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
581 tree_constant (const Range& r)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
582 { rep = new tree_constant_rep (r); rep->count = 1; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
583
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
584 tree_constant (tree_constant_rep::constant_type t)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
585 { rep = new tree_constant_rep (t); rep->count = 1; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
586
161
21b599370728 [project @ 1993-10-16 17:20:32 by jwe]
jwe
parents: 97
diff changeset
587 tree_constant (const tree_constant& a)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
588 { rep = a.rep; rep->count++; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
589 tree_constant (tree_constant_rep& r)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
590 { rep = &r; rep->count++; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
591
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
592 ~tree_constant (void);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
593
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
594 #if defined (MDEBUG)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
595 void *operator new (size_t size);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
596 void operator delete (void *p, size_t size);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
597 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
598
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
599 tree_constant operator = (tree_constant& a)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
600 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
601 if (--rep->count <= 0 && rep != a.rep)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
602 delete rep;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
603
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
604 rep = a.rep;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
605 rep->count++;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
606 return *this;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
607 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
608
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
609 int is_constant (void) const { return 1; }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
610
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
611 int is_scalar_type (void) const { return rep->is_scalar_type (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
612 int is_matrix_type (void) const { return rep->is_matrix_type (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
613
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
614 int is_real_type (void) const { return rep->is_real_type (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
615 int is_complex_type (void) const { return rep->is_complex_type (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
616
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
617 int is_numeric_type (void) const { return rep->is_numeric_type (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
618
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
619 int is_numeric_or_range_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
620 { return rep->is_numeric_or_range_type (); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
621
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
622 int is_string_type (void) const { return rep->is_string_type (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
623
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
624 int valid_as_scalar_index (void) const
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
625 { return rep->valid_as_scalar_index (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
626
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
627 int is_defined (void) const { return rep->is_defined (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
628 int is_undefined (void) const { return rep->is_undefined (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
629
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
630 double to_scalar (void) const { return rep->to_scalar (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
631 ColumnVector to_vector (void) const { return rep->to_vector (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
632 Matrix to_matrix (void) const { return rep->to_matrix (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
633
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
634 tree_constant_rep::constant_type force_numeric (int force_str_conv = 0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
635 { return rep->force_numeric (force_str_conv); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
636
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
637 tree_constant make_numeric (int force_str_conv = 0) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
638 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
639 if (is_numeric_type ())
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
640 return *this;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
641 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
642 return rep->make_numeric (force_str_conv);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
643 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
644
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
645 tree_constant make_numeric_or_range (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
646 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
647 if (is_numeric_type ()
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
648 || rep->type_tag == tree_constant_rep::range_constant)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
649 return *this;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
650 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
651 return rep->make_numeric ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
652 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
653
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
654 tree_constant make_numeric_or_magic (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
655 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
656 if (is_numeric_type ()
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
657 || rep->type_tag == tree_constant_rep::magic_colon)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
658 return *this;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
659 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
660 return rep->make_numeric ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
661 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
662
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
663 tree_constant make_numeric_or_range_or_magic (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
664 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
665 if (is_numeric_type ()
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
666 || rep->type_tag == tree_constant_rep::magic_colon
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
667 || rep->type_tag == tree_constant_rep::range_constant)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
668 return *this;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
669 else
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
670 return rep->make_numeric ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
671 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
672
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
673 tree_constant assign (tree_constant& rhs, tree_constant *args, int nargs)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
674 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
675 if (rep->count > 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
676 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
677 --rep->count;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
678 rep = new tree_constant_rep (*rep);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
679 rep->count = 1;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
680 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
681 rep->assign (rhs, args, nargs);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
682 return *this;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
683 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
684
276
4cf3c7df0e3d [project @ 1994-01-07 02:05:57 by jwe]
jwe
parents: 259
diff changeset
685 int save (ostream& os, int mark_as_global = 0, int precision = 17)
4cf3c7df0e3d [project @ 1994-01-07 02:05:57 by jwe]
jwe
parents: 259
diff changeset
686 { return rep->save (os, mark_as_global, precision); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
687 int save_three_d (ostream& os, int parametric = 0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
688 { return rep->save_three_d (os, parametric); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
689
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
690 int load (istream& is) { return rep->load (is); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
691 tree_constant_rep::constant_type load
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
692 (istream& is, tree_constant_rep::constant_type t)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
693 { return rep->load (is, t); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
694
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
695 double double_value (void) const { return rep->double_value (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
696 Matrix matrix_value (void) const { return rep->matrix_value (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
697 Complex complex_value (void) const { return rep->complex_value (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
698 ComplexMatrix complex_matrix_value (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
699 { return rep->complex_matrix_value (); }
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
700 char *string_value (void) const { return rep->string_value (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
701 Range range_value (void) const { return rep->range_value (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
702
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
703 int rows (void) const { return rep->rows (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
704 int columns (void) const { return rep->columns (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
705
208
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
706 int is_empty (void) const
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
707 {
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
708 return (rep->type_tag != tree_constant_rep::magic_colon
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
709 && rep->type_tag != tree_constant_rep::unknown_constant
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
710 && (rows () == 0 || columns () == 0));
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
711 }
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
712
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
713 int is_zero_by_zero (void) const
212
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
714 {
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
715 return (rep->type_tag != tree_constant_rep::magic_colon
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
716 && rep->type_tag != tree_constant_rep::unknown_constant
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
717 && rows () == 0
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
718 && columns () == 0);
6188aa8d1fec [project @ 1993-11-13 03:44:55 by jwe]
jwe
parents: 208
diff changeset
719 }
208
380cb9ccc889 [project @ 1993-11-12 10:35:05 by jwe]
jwe
parents: 191
diff changeset
720
93
0a3d698c6e60 [project @ 1993-09-13 02:29:54 by jwe]
jwe
parents: 51
diff changeset
721
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
722 tree_constant all (void) const { return rep->all (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
723 tree_constant any (void) const { return rep->any (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
724 tree_constant isstr (void) const { return rep->isstr (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
725
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
726 tree_constant convert_to_str (void) { return rep->convert_to_str (); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
727
435
5e778965b6ea [project @ 1994-05-25 23:59:02 by jwe]
jwe
parents: 428
diff changeset
728 void convert_to_row_or_column_vector (void)
5e778965b6ea [project @ 1994-05-25 23:59:02 by jwe]
jwe
parents: 428
diff changeset
729 {
5e778965b6ea [project @ 1994-05-25 23:59:02 by jwe]
jwe
parents: 428
diff changeset
730 rep->convert_to_row_or_column_vector ();
5e778965b6ea [project @ 1994-05-25 23:59:02 by jwe]
jwe
parents: 428
diff changeset
731 }
5e778965b6ea [project @ 1994-05-25 23:59:02 by jwe]
jwe
parents: 428
diff changeset
732
428
fa0453b25410 [project @ 1994-05-25 01:06:28 by jwe]
jwe
parents: 399
diff changeset
733 int is_true (void) const { return rep->is_true (); }
fa0453b25410 [project @ 1994-05-25 01:06:28 by jwe]
jwe
parents: 399
diff changeset
734
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
735 tree_constant cumprod (void) const { return rep->cumprod (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
736 tree_constant cumsum (void) const { return rep->cumsum (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
737 tree_constant prod (void) const { return rep->prod (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
738 tree_constant sum (void) const { return rep->sum (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
739 tree_constant sumsq (void) const { return rep->sumsq (); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
740
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
741 tree_constant diag (void) const { return rep->diag (); }
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
742 tree_constant diag (const tree_constant& a) const { return rep->diag (a); }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
743
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
744 tree_constant_rep::constant_type const_type (void) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
745 { return rep->const_type (); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
746
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
747 tree_constant mapper (Mapper_fcn& m_fcn, int print) const
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
748 { return rep->mapper (m_fcn, print); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
749
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
750 void bump_value (tree::expression_type et)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
751 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
752 if (rep->count > 1)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
753 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
754 --rep->count;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
755 rep = new tree_constant_rep (*rep);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
756 rep->count = 1;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
757 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
758 rep->bump_value (et);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
759 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
760
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
761 tree_constant eval (int print)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
762 { rep->eval (print); return *this; }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
763
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
764 // A tree constant can have one and only one value to return.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
765 tree_constant *eval (int print, int nargout)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
766 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
767 rep->eval (print);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
768 tree_constant *retval = new tree_constant [2];
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
769 retval[0] = *this;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
770 return retval;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
771 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
772
259
23866011a5f2 [project @ 1993-12-14 22:21:12 by jwe]
jwe
parents: 240
diff changeset
773 tree_constant eval (int argc, char **argv, int print);
23866011a5f2 [project @ 1993-12-14 22:21:12 by jwe]
jwe
parents: 240
diff changeset
774
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
775 tree_constant *eval (const tree_constant *args, int n_in, int n_out,
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
776 int print)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
777 { return rep->eval (args, n_in, n_out, print); }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
778
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
779 private:
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
780 tree_constant_rep *rep;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
781 };
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
782
94
c568ba9fc151 [project @ 1993-09-13 02:45:55 by jwe]
jwe
parents: 93
diff changeset
783 /*
c568ba9fc151 [project @ 1993-09-13 02:45:55 by jwe]
jwe
parents: 93
diff changeset
784 * Here are some extra functions that are related to the tree_constant
c568ba9fc151 [project @ 1993-09-13 02:45:55 by jwe]
jwe
parents: 93
diff changeset
785 * class but that don't need to be class members or friends.
c568ba9fc151 [project @ 1993-09-13 02:45:55 by jwe]
jwe
parents: 93
diff changeset
786 */
c568ba9fc151 [project @ 1993-09-13 02:45:55 by jwe]
jwe
parents: 93
diff changeset
787
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 161
diff changeset
788 extern tree_constant *vector_of_empties (int nargout, const char *fcn_name);
94
c568ba9fc151 [project @ 1993-09-13 02:45:55 by jwe]
jwe
parents: 93
diff changeset
789
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
790 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
791
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
792 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
793 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
794 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
795 ;;; page-delimiter: "^/\\*" ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
796 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
797 */