Mercurial > hg > octave-terminal
changeset 164:e2c950dd96d2
[project @ 1993-10-18 19:32:00 by jwe]
author | jwe |
---|---|
date | Mon, 18 Oct 1993 19:32:00 +0000 |
parents | b4bdbdf95e05 |
children | 31bd3f646964 |
files | liboctave/idx-vector.cc liboctave/idx-vector.h src/arith-ops.cc src/arith-ops.h src/builtins.cc src/builtins.h src/dynamic-ld.cc src/dynamic-ld.h src/file-io.cc src/file-io.h src/g-builtins.cc src/g-builtins.h src/input.cc src/input.h src/mappers.cc src/mappers.h src/pr-output.cc src/pr-output.h src/pt-base.h src/pt-const.cc src/pt-const.h src/symtab.cc src/symtab.h src/tc-assign.cc src/tc-extras.cc src/tc-index.cc src/tc-inlines.h src/tree.h.old src/unwind-prot.h src/utils.cc src/utils.h src/variables.cc src/xdiv.cc src/xdiv.h src/xpow.cc src/xpow.h |
diffstat | 36 files changed, 798 insertions(+), 747 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -25,9 +25,13 @@ #pragma implementation #endif +#include <iostream.h> + +#include "Matrix.h" +#include "Range.h" #include "idx-vector.h" +#include "user-prefs.h" #include "error.h" -#include "user-prefs.h" #include "utils.h" idx_vector::idx_vector (const idx_vector& a) @@ -59,7 +63,8 @@ return ((int) (x - 0.5) - 1); } -idx_vector::idx_vector (Matrix& m, int do_ftn_idx, char *rc, int z_len = 0) +idx_vector::idx_vector (const Matrix& m, int do_ftn_idx, + const char *rc, int z_len = 0) { int nr = m.rows (); int nc = m.columns (); @@ -146,7 +151,7 @@ } void -idx_vector::init_state (char *rc, int z_len = 0) +idx_vector::init_state (const char *rc, int z_len = 0) { one_zero = 1; num_zeros = 0;
--- a/liboctave/idx-vector.h +++ b/liboctave/idx-vector.h @@ -30,20 +30,21 @@ #include <stdlib.h> #include <assert.h> -#include <iostream.h> -#include "Matrix.h" -#include "Range.h" #define FAIL assert(0) /* XXX FIXME XXX */ +class ostream; +class Matrix; +class Range; + class idx_vector { public: idx_vector (void); idx_vector (const idx_vector& a); - idx_vector (Matrix& m, int do_ftn_idx, char *rc = (char *) NULL, - int z_len = 0); + idx_vector (const Matrix& m, int do_ftn_idx, + const char *rc = (char *) NULL, int z_len = 0); idx_vector (const Range& r); @@ -81,7 +82,7 @@ int min_val; int *data; - void init_state (char *rc = (char *) NULL, int z_len = 0); + void init_state (const char *rc = (char *) NULL, int z_len = 0); void convert_one_zero_to_idx (void); };
--- a/src/arith-ops.cc +++ b/src/arith-ops.cc @@ -29,6 +29,7 @@ #include <ctype.h> #include <setjmp.h> #include <math.h> +#include <Complex.h> #include "error.h" #include "gripes.h" @@ -79,7 +80,7 @@ * Check row and column dimensions for binary matrix operations. */ static inline int -m_add_conform (Matrix& a, Matrix& b, int warn) +m_add_conform (const Matrix& a, const Matrix& b, int warn) { int ar = a.rows (); int ac = a.columns (); @@ -95,7 +96,7 @@ } static inline int -m_add_conform (Matrix& a, ComplexMatrix& b, int warn) +m_add_conform (const Matrix& a, const ComplexMatrix& b, int warn) { int ar = a.rows (); int ac = a.columns (); @@ -111,7 +112,7 @@ } static inline int -m_add_conform (ComplexMatrix& a, Matrix& b, int warn) +m_add_conform (const ComplexMatrix& a, const Matrix& b, int warn) { int ar = a.rows (); int ac = a.columns (); @@ -127,7 +128,7 @@ } static inline int -m_add_conform (ComplexMatrix& a, ComplexMatrix& b, int warn) +m_add_conform (const ComplexMatrix& a, const ComplexMatrix& b, int warn) { int ar = a.rows (); int ac = a.columns (); @@ -143,7 +144,7 @@ } static inline int -m_mul_conform (Matrix& a, Matrix& b, int warn) +m_mul_conform (const Matrix& a, const Matrix& b, int warn) { int ac = a.columns (); int br = b.rows (); @@ -157,7 +158,7 @@ } static inline int -m_mul_conform (Matrix& a, ComplexMatrix& b, int warn) +m_mul_conform (const Matrix& a, const ComplexMatrix& b, int warn) { int ac = a.columns (); int br = b.rows (); @@ -171,7 +172,7 @@ } static inline int -m_mul_conform (ComplexMatrix& a, Matrix& b, int warn) +m_mul_conform (const ComplexMatrix& a, const Matrix& b, int warn) { int ac = a.columns (); int br = b.rows (); @@ -185,7 +186,7 @@ } static inline int -m_mul_conform (ComplexMatrix& a, ComplexMatrix& b, int warn) +m_mul_conform (const ComplexMatrix& a, const ComplexMatrix& b, int warn) { int ac = a.columns (); int br = b.rows (); @@ -216,7 +217,7 @@ /* 1 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, double s, Matrix& a) +mx_stupid_bool_op (Matrix_bool_op op, double s, const Matrix& a) { int ar = a.rows (); int ac = a.columns (); @@ -263,7 +264,7 @@ /* 2 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, double s, ComplexMatrix& a) +mx_stupid_bool_op (Matrix_bool_op op, double s, const ComplexMatrix& a) { int ar = a.rows (); int ac = a.columns (); @@ -310,7 +311,7 @@ /* 3 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, Matrix& a, double s) +mx_stupid_bool_op (Matrix_bool_op op, const Matrix& a, double s) { int ar = a.rows (); int ac = a.columns (); @@ -357,7 +358,7 @@ /* 4 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, Matrix& a, Complex& s) +mx_stupid_bool_op (Matrix_bool_op op, const Matrix& a, const Complex& s) { int ar = a.rows (); int ac = a.columns (); @@ -404,7 +405,7 @@ /* 5 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, Matrix& a, Matrix& b) +mx_stupid_bool_op (Matrix_bool_op op, const Matrix& a, const Matrix& b) { if (! m_add_conform (a, b, 1)) return Matrix (); @@ -454,7 +455,7 @@ /* 6 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, Matrix& a, ComplexMatrix& b) +mx_stupid_bool_op (Matrix_bool_op op, const Matrix& a, const ComplexMatrix& b) { if (! m_add_conform (a, b, 1)) return Matrix (); @@ -503,7 +504,7 @@ /* 7 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, Complex& s, Matrix& a) +mx_stupid_bool_op (Matrix_bool_op op, const Complex& s, const Matrix& a) { int ar = a.rows (); int ac = a.columns (); @@ -550,7 +551,7 @@ /* 8 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, Complex& s, ComplexMatrix& a) +mx_stupid_bool_op (Matrix_bool_op op, const Complex& s, const ComplexMatrix& a) { int ar = a.rows (); int ac = a.columns (); @@ -597,7 +598,7 @@ /* 9 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, ComplexMatrix& a, double s) +mx_stupid_bool_op (Matrix_bool_op op, const ComplexMatrix& a, double s) { int ar = a.rows (); int ac = a.columns (); @@ -644,7 +645,7 @@ /* 10 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, ComplexMatrix& a, Complex& s) +mx_stupid_bool_op (Matrix_bool_op op, const ComplexMatrix& a, const Complex& s) { int ar = a.rows (); int ac = a.columns (); @@ -691,7 +692,7 @@ /* 11 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, ComplexMatrix& a, Matrix& b) +mx_stupid_bool_op (Matrix_bool_op op, const ComplexMatrix& a, const Matrix& b) { if (! m_add_conform (a, b, 1)) return Matrix (); @@ -740,7 +741,8 @@ /* 12 */ static Matrix -mx_stupid_bool_op (Matrix_bool_op op, ComplexMatrix& a, ComplexMatrix& b) +mx_stupid_bool_op (Matrix_bool_op op, const ComplexMatrix& a, + const ComplexMatrix& b) { if (! m_add_conform (a, b, 1)) return Matrix (); @@ -824,7 +826,7 @@ } tree_constant -do_unary_op (Matrix& a, tree::expression_type t) +do_unary_op (const Matrix& a, tree::expression_type t) { Matrix result; @@ -849,7 +851,7 @@ } tree_constant -do_unary_op (Complex& c, tree::expression_type t) +do_unary_op (const Complex& c, tree::expression_type t) { Complex result = 0.0; @@ -876,7 +878,7 @@ } tree_constant -do_unary_op (ComplexMatrix& a, tree::expression_type t) +do_unary_op (const ComplexMatrix& a, tree::expression_type t) { ComplexMatrix result; @@ -989,7 +991,7 @@ /* 2 */ tree_constant -do_binary_op (double a, Matrix& b, tree::expression_type t) +do_binary_op (double a, const Matrix& b, tree::expression_type t) { Matrix result; @@ -1060,7 +1062,7 @@ /* 3 */ tree_constant -do_binary_op (double a, Complex& b, tree::expression_type t) +do_binary_op (double a, const Complex& b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1151,7 +1153,7 @@ /* 4 */ tree_constant -do_binary_op (double a, ComplexMatrix& b, tree::expression_type t) +do_binary_op (double a, const ComplexMatrix& b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1242,7 +1244,7 @@ /* 5 */ tree_constant -do_binary_op (Matrix& a, double b, tree::expression_type t) +do_binary_op (const Matrix& a, double b, tree::expression_type t) { Matrix result; @@ -1311,7 +1313,7 @@ /* 6 */ tree_constant -do_binary_op (Matrix& a, Matrix& b, tree::expression_type t) +do_binary_op (const Matrix& a, const Matrix& b, tree::expression_type t) { Matrix result; @@ -1399,7 +1401,7 @@ /* 7 */ tree_constant -do_binary_op (Matrix& a, Complex& b, tree::expression_type t) +do_binary_op (const Matrix& a, const Complex& b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1489,7 +1491,7 @@ /* 8 */ tree_constant -do_binary_op (Matrix& a, ComplexMatrix& b, tree::expression_type t) +do_binary_op (const Matrix& a, const ComplexMatrix& b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1600,7 +1602,7 @@ /* 9 */ tree_constant -do_binary_op (Complex& a, double b, tree::expression_type t) +do_binary_op (const Complex& a, double b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1691,7 +1693,7 @@ /* 10 */ tree_constant -do_binary_op (Complex& a, Matrix& b, tree::expression_type t) +do_binary_op (const Complex& a, const Matrix& b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1713,8 +1715,9 @@ case tree::leftdiv: if (a == 0.0) DIVIDE_BY_ZERO_ERROR; - a = 1.0 / a; -// fall through... + result_type = RT_complex; + complex_result = b / a; + break; case tree::multiply: case tree::el_mul: result_type = RT_complex; @@ -1782,7 +1785,7 @@ /* 11 */ tree_constant -do_binary_op (Complex& a, Complex& b, tree::expression_type t) +do_binary_op (const Complex& a, const Complex& b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1873,7 +1876,8 @@ /* 12 */ tree_constant -do_binary_op (Complex& a, ComplexMatrix& b, tree::expression_type t) +do_binary_op (const Complex& a, const ComplexMatrix& b, + tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -1895,8 +1899,9 @@ case tree::leftdiv: if (a == 0.0) DIVIDE_BY_ZERO_ERROR; - a = 1.0 / a; -// fall through... + result_type = RT_complex; + complex_result = b / a; + break; case tree::multiply: case tree::el_mul: result_type = RT_complex; @@ -1964,7 +1969,7 @@ /* 13 */ tree_constant -do_binary_op (ComplexMatrix& a, double b, tree::expression_type t) +do_binary_op (const ComplexMatrix& a, double b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -2054,7 +2059,7 @@ /* 14 */ tree_constant -do_binary_op (ComplexMatrix& a, Matrix& b, tree::expression_type t) +do_binary_op (const ComplexMatrix& a, const Matrix& b, tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -2165,7 +2170,8 @@ /* 15 */ tree_constant -do_binary_op (ComplexMatrix& a, Complex& b, tree::expression_type t) +do_binary_op (const ComplexMatrix& a, const Complex& b, + tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown; @@ -2255,7 +2261,8 @@ /* 16 */ tree_constant -do_binary_op (ComplexMatrix& a, ComplexMatrix& b, tree::expression_type t) +do_binary_op (const ComplexMatrix& a, const ComplexMatrix& b, + tree::expression_type t) { enum RT { RT_unknown, RT_real, RT_complex }; RT result_type = RT_unknown;
--- a/src/arith-ops.h +++ b/src/arith-ops.h @@ -29,67 +29,70 @@ #pragma interface #endif -#include "tree-const.h" - -extern tree_constant -do_unary_op (double d, tree::expression_type t); +#include "tree-base.h" -extern tree_constant -do_unary_op (Matrix& a, tree::expression_type t); +class Complex; +class Matrix; +class ComplexMatrix; +class tree_constant; -extern tree_constant -do_unary_op (Complex& c, tree::expression_type t); +extern tree_constant do_unary_op (double d, tree::expression_type t); -extern tree_constant -do_unary_op (ComplexMatrix& a, tree::expression_type t); +extern tree_constant do_unary_op (const Matrix& a, tree::expression_type t); + +extern tree_constant do_unary_op (const Complex& c, tree::expression_type t); -extern tree_constant -do_binary_op (double a, double b, tree::expression_type t); +extern tree_constant do_unary_op (const ComplexMatrix& a, + tree::expression_type t); -extern tree_constant -do_binary_op (double a, Matrix& b, tree::expression_type t); +extern tree_constant do_binary_op (double a, double b, + tree::expression_type t); + +extern tree_constant do_binary_op (double a, const Matrix& b, + tree::expression_type t); -extern tree_constant -do_binary_op (double a, Complex& b, tree::expression_type t); +extern tree_constant do_binary_op (double a, const Complex& b, + tree::expression_type t); -extern tree_constant -do_binary_op (double a, ComplexMatrix& b, tree::expression_type t); +extern tree_constant do_binary_op (double a, const ComplexMatrix& b, + tree::expression_type t); -extern tree_constant -do_binary_op (Matrix& a, double b, tree::expression_type t); +extern tree_constant do_binary_op (const Matrix& a, double b, + tree::expression_type t); -extern tree_constant -do_binary_op (Matrix& a, Matrix& b, tree::expression_type t); +extern tree_constant do_binary_op (const Matrix& a, const Matrix& b, + tree::expression_type t); -extern tree_constant -do_binary_op (Matrix& a, Complex& b, tree::expression_type t); +extern tree_constant do_binary_op (const Matrix& a, const Complex& b, + tree::expression_type t); -extern tree_constant -do_binary_op (Matrix& a, ComplexMatrix& b, tree::expression_type t); +extern tree_constant do_binary_op (const Matrix& a, const ComplexMatrix& b, + tree::expression_type t); -extern tree_constant -do_binary_op (Complex& a, double b, tree::expression_type t); +extern tree_constant do_binary_op (const Complex& a, double b, + tree::expression_type t); -extern tree_constant -do_binary_op (Complex& a, Matrix& b, tree::expression_type t); +extern tree_constant do_binary_op (const Complex& a, const Matrix& b, + tree::expression_type t); -extern tree_constant -do_binary_op (Complex& a, Complex& b, tree::expression_type t); +extern tree_constant do_binary_op (const Complex& a, const Complex& b, + tree::expression_type t); -extern tree_constant -do_binary_op (Complex& a, ComplexMatrix& b, tree::expression_type t); +extern tree_constant do_binary_op (const Complex& a, const ComplexMatrix& b, + tree::expression_type t); -extern tree_constant -do_binary_op (ComplexMatrix& a, double b, tree::expression_type t); +extern tree_constant do_binary_op (const ComplexMatrix& a, double b, + tree::expression_type t); -extern tree_constant -do_binary_op (ComplexMatrix& a, Matrix& b, tree::expression_type t); +extern tree_constant do_binary_op (const ComplexMatrix& a, const Matrix& b, + tree::expression_type t); -extern tree_constant -do_binary_op (ComplexMatrix& a, Complex& b, tree::expression_type t); +extern tree_constant do_binary_op (const ComplexMatrix& a, const Complex& b, + tree::expression_type t); -extern tree_constant -do_binary_op (ComplexMatrix& a, ComplexMatrix& b, tree::expression_type t); +extern tree_constant do_binary_op (const ComplexMatrix& a, + const ComplexMatrix& b, + tree::expression_type t); #endif
--- a/src/builtins.cc +++ b/src/builtins.cc @@ -37,6 +37,7 @@ #include "octave.h" #include "utils.h" #include "tree.h" +#include "help.h" #include "mappers.h" #include "user-prefs.h" #include "variables.h" @@ -666,8 +667,8 @@ { NULL, NULL, NULL, NULL, }, }; -void -make_eternal (char *s) +static void +make_eternal (const char *s) { symbol_record *sym_rec = curr_sym_tab->lookup (s, 0, 0); if (sym_rec != (symbol_record *) NULL) @@ -896,7 +897,7 @@ } int -is_text_function_name (char *s) +is_text_function_name (const char *s) { int retval = 0;
--- a/src/builtins.h +++ b/src/builtins.h @@ -28,9 +28,8 @@ #pragma interface #endif -#include <Complex.h> - -#include "help.h" +class Complex; +struct help_list; #ifndef MAPPER_FCN_TYPEDEFS #define MAPPER_FCN_TYPEDEFS 1 @@ -77,7 +76,7 @@ }; extern void install_builtins (void); -extern int is_text_function_name (char *s); +extern int is_text_function_name (const char *s); extern help_list *builtin_mapper_functions_help (void); extern help_list *builtin_general_functions_help (void);
--- a/src/dynamic-ld.cc +++ b/src/dynamic-ld.cc @@ -38,7 +38,7 @@ #include "error.h" void -octave_dld_tc2_unlink_by_symbol (char *name, int hard = 1) +octave_dld_tc2_unlink_by_symbol (const char *name, int hard = 1) { char *mangled_fcn_name = strconcat (name, "__FP13tree_constantii"); int status = dld_unlink_by_symbol (mangled_fcn_name, hard); @@ -48,7 +48,7 @@ } void -octave_dld_tc2_unlink_by_file (char *name, int hard = 1) +octave_dld_tc2_unlink_by_file (const char *name, int hard = 1) { int status = dld_unlink_by_file (name, hard); if (status != 0) @@ -86,7 +86,7 @@ * try to load the remaining undefined symbols. */ static int -octave_dld_link (char *object) +octave_dld_link (const char *object) { char *file = file_in_path (object, (char *) NULL); int status = dld_link (file); @@ -98,7 +98,7 @@ } int -octave_dld_tc2_link (char *object) +octave_dld_tc2_link (const char *object) { int status = octave_dld_link (object); if (status == 0) @@ -111,7 +111,7 @@ } builtin_fcn_ptr -octave_dld_tc2 (char *name, char *fcn, char *object) +octave_dld_tc2 (const char *name, const char *fcn, const char *object) { builtin_fcn_ptr retval = (builtin_fcn_ptr) NULL; @@ -142,7 +142,7 @@ tree_constant * octave_dld_tc2_and_go (tree_constant *args, int nargin, int nargout, - char *name, char *fcn, char *object) + const char *name, const char *fcn, const char *object) { tree_constant *retval = NULL_TREE_CONST;
--- a/src/dynamic-ld.h +++ b/src/dynamic-ld.h @@ -32,16 +32,19 @@ typedef tree_constant* (*builtin_fcn_ptr) (tree_constant*, int, int); -extern void octave_dld_tc2_unlink_by_symbol (char *name, int hard = 1); +extern void octave_dld_tc2_unlink_by_symbol (const char *name, int hard = 1); + +extern void octave_dld_tc2_unlink_by_file (const char *name, int hard = 1); -extern void octave_dld_tc2_unlink_by_file (char *name, int hard = 1); - -extern builtin_fcn_ptr octave_dld_tc2 (char *name, char *fcn, char *object); +extern builtin_fcn_ptr octave_dld_tc2 (const char *name, + const char *fcn, + const char *object); extern tree_constant *octave_dld_tc2_and_go (tree_constant *args, int nargin, int nargout, - char *name, char *fcn, - char *object); + const char *name, + const char *fcn, + const char *object); #endif
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -54,7 +54,7 @@ { public: File_info (void); - File_info (int num, char *nm, FILE *t, char *md); + File_info (int num, const char *nm, FILE *t, const char *md); File_info (const File_info& f); File_info& operator = (const File_info& f); @@ -106,7 +106,7 @@ delete [] _mode; } -File_info::File_info (int n, char *nm, FILE *t, char *md) +File_info::File_info (int n, const char *nm, FILE *t, const char *md) { _number = n; _name = strsave (nm); @@ -143,7 +143,7 @@ static DLList <File_info> file_list; void -initialize_file_io () +initialize_file_io (void) { File_info _stdin (0, "stdin", stdin, "r"); File_info _stdout (1, "stdout", stdout, "w"); @@ -157,7 +157,7 @@ } Pix -return_valid_file (tree_constant& arg) +return_valid_file (const tree_constant& arg) { if (arg.is_string_type ()) { @@ -198,7 +198,7 @@ } static Pix -fopen_file_for_user (tree_constant& arg, char *mode) +fopen_file_for_user (const tree_constant& arg, const char *mode) { char *file_name = arg.string_value (); @@ -226,7 +226,7 @@ tree_constant * -fclose_internal (tree_constant *args) +fclose_internal (const tree_constant *args) { tree_constant *retval = NULL_TREE_CONST; @@ -260,7 +260,7 @@ } tree_constant * -fflush_internal (tree_constant *args) +fflush_internal (const tree_constant *args) { tree_constant *retval = NULL_TREE_CONST; @@ -296,7 +296,7 @@ } static int -valid_mode (char *mode) +valid_mode (const char *mode) { if (mode != (char *) NULL) { @@ -311,7 +311,7 @@ } tree_constant * -fgets_internal (tree_constant *args, int nargout) +fgets_internal (const tree_constant *args, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -375,7 +375,7 @@ } tree_constant * -fopen_internal (tree_constant *args) +fopen_internal (const tree_constant *args) { tree_constant *retval = NULL_TREE_CONST; Pix p; @@ -440,7 +440,7 @@ } tree_constant * -freport_internal () +freport_internal (void) { tree_constant *retval = NULL_TREE_CONST; Pix p = file_list.first (); @@ -463,7 +463,7 @@ } tree_constant * -frewind_internal (tree_constant *args) +frewind_internal (const tree_constant *args) { tree_constant *retval = NULL_TREE_CONST; @@ -478,7 +478,7 @@ } tree_constant * -fseek_internal (tree_constant *args, int nargin) +fseek_internal (const tree_constant *args, int nargin) { tree_constant *retval = NULL_TREE_CONST; @@ -532,7 +532,7 @@ } tree_constant * -ftell_internal (tree_constant *args) +ftell_internal (const tree_constant *args) { tree_constant *retval = NULL_TREE_CONST; Pix p = return_valid_file (args[1]); @@ -552,7 +552,7 @@ } void -close_files () +close_files (void) { Pix p = file_list.first (); @@ -570,8 +570,8 @@ } static int -process_printf_format (char *s, tree_constant *args, ostrstream& sb, - char *type, int nargin) +process_printf_format (const char *s, const tree_constant *args, + ostrstream& sb, const char *type, int nargin) { ostrstream fmt; @@ -769,7 +769,8 @@ tree_constant * -do_printf (char *type, tree_constant *args, int nargin, int nargout) +do_printf (const char *type, const tree_constant *args, int nargin, + int nargout) { tree_constant *retval = NULL_TREE_CONST; fmt_arg_count = 1; @@ -889,9 +890,9 @@ } static int -process_scanf_format (char *s, tree_constant *args, ostrstream& fmt, - char *type, int nargout, FILE* fptr, - tree_constant *values) +process_scanf_format (const char *s, const tree_constant *args, + ostrstream& fmt, const char *type, int nargout, + FILE* fptr, tree_constant *values) { fmt << "%"; @@ -1050,7 +1051,7 @@ } tree_constant * -do_scanf (char *type, tree_constant *args, int nargin, int nargout) +do_scanf (const char *type, const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; char *scanf_fmt = (char *) NULL;
--- a/src/file-io.h +++ b/src/file-io.h @@ -30,37 +30,29 @@ #pragma interface #endif -#include "tree-const.h" -#include "utils.h" #include <Pix.h> -#include <stdio.h> -extern Pix return_valid_file (tree_constant& arg); - -extern tree_constant *fclose_internal (tree_constant *args); +class tree_constant; -extern tree_constant *fflush_internal (tree_constant *args); - -extern tree_constant *fgets_internal (tree_constant *args, int nargout); +extern Pix return_valid_file (const tree_constant& arg); -extern tree_constant *fopen_internal (tree_constant *args); - -extern tree_constant *freport_internal (); - -extern tree_constant *frewind_internal (tree_constant *args); - -extern tree_constant *fseek_internal (tree_constant *args, int nargin); +extern tree_constant *fclose_internal (const tree_constant *args); +extern tree_constant *fflush_internal (const tree_constant *args); +extern tree_constant *fgets_internal (const tree_constant *args, int nargout); +extern tree_constant *fopen_internal (const tree_constant *args); +extern tree_constant *freport_internal (void); +extern tree_constant *frewind_internal (const tree_constant *args); +extern tree_constant *fseek_internal (const tree_constant *args, int nargin); +extern tree_constant *ftell_internal (const tree_constant *args); -extern tree_constant *ftell_internal (tree_constant *args); - -extern void initialize_file_io (); +extern void initialize_file_io (void); -extern void close_files (); +extern void close_files (void); -extern tree_constant *do_printf (char *type, tree_constant *args, +extern tree_constant *do_printf (const char *type, const tree_constant *args, int nargin, int nargout); -extern tree_constant *do_scanf (char *type, tree_constant *args, +extern tree_constant *do_scanf (const char *type, const tree_constant *args, int nargin, int nargout); #endif
--- a/src/g-builtins.cc +++ b/src/g-builtins.cc @@ -127,7 +127,7 @@ * Are all elements of a constant nonzero? */ tree_constant * -builtin_all (tree_constant *args, int nargin, int nargout) +builtin_all (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -147,7 +147,7 @@ * Are any elements of a constant nonzero? */ tree_constant * -builtin_any (tree_constant *args, int nargin, int nargout) +builtin_any (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -167,7 +167,7 @@ * Balancing for eigenvalue problems */ tree_constant * -builtin_balance (tree_constant *args, int nargin, int nargout) +builtin_balance (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin <= 1 || nargin > 4 || nargout < 1 || nargout > 4) @@ -185,7 +185,7 @@ * Clear the screen? */ tree_constant * -builtin_clc (tree_constant *args, int nargin, int nargout) +builtin_clc (const tree_constant *args, int nargin, int nargout) { rl_beg_of_line (); rl_kill_line (1); @@ -197,7 +197,7 @@ * Time in a vector. */ tree_constant * -builtin_clock (tree_constant *args, int nargin, int nargout) +builtin_clock (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -225,7 +225,7 @@ * Close the stream to the plotter. */ tree_constant * -builtin_closeplot (tree_constant *args, int nargin, int nargout) +builtin_closeplot (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; close_plot_stream (); @@ -236,7 +236,7 @@ * Collocation roots and weights. */ tree_constant * -builtin_colloc (tree_constant *args, int nargin, int nargout) +builtin_colloc (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -253,7 +253,7 @@ * Cumulative sums and products. */ tree_constant * -builtin_cumprod (tree_constant *args, int nargin, int nargout) +builtin_cumprod (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -270,7 +270,7 @@ } tree_constant * -builtin_cumsum (tree_constant *args, int nargin, int nargout) +builtin_cumsum (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -304,7 +304,7 @@ } tree_constant * -builtin_dassl (tree_constant *args, int nargin, int nargout) +builtin_dassl (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = new tree_constant [2]; @@ -321,7 +321,7 @@ * Time in a string. */ tree_constant * -builtin_date (tree_constant *args, int nargin, int nargout) +builtin_date (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -345,7 +345,7 @@ * Determinant of a matrix. */ tree_constant * -builtin_det (tree_constant *args, int nargin, int nargout) +builtin_det (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -365,7 +365,7 @@ * Diagonal elements of a matrix. */ tree_constant * -builtin_diag (tree_constant *args, int nargin, int nargout) +builtin_diag (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -405,7 +405,7 @@ * Compute eigenvalues and eigenvectors. */ tree_constant * -builtin_eig (tree_constant *args, int nargin, int nargout) +builtin_eig (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -441,7 +441,7 @@ * Evaluate text argument as octave source. */ tree_constant * -builtin_eval (tree_constant *args, int nargin, int nargout) +builtin_eval (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin == 2) @@ -459,7 +459,7 @@ * Check if variable or file exists. */ tree_constant * -builtin_exist (tree_constant *args, int nargin, int nargout) +builtin_exist (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin == 2 && args[1].is_string_type ()) @@ -477,7 +477,7 @@ * Matrix exponential. */ tree_constant * -builtin_expm (tree_constant *args, int nargin, int nargout) +builtin_expm (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -497,7 +497,7 @@ * Identity matrix. */ tree_constant * -builtin_eye (tree_constant *args, int nargin, int nargout) +builtin_eye (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -523,7 +523,7 @@ * Closing a file */ tree_constant * -builtin_fclose (tree_constant *args, int nargin, int nargout) +builtin_fclose (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -537,7 +537,7 @@ * Evaluate first argument as a function. */ tree_constant * -builtin_feval (tree_constant *args, int nargin, int nargout) +builtin_feval (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin > 1) @@ -551,7 +551,7 @@ * Flushing output to a file */ tree_constant * -builtin_fflush (tree_constant *args, int nargin, int nargout) +builtin_fflush (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -565,7 +565,7 @@ * Fast Fourier Transform */ tree_constant * -builtin_fft (tree_constant *args, int nargin, int nargout) +builtin_fft (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -585,7 +585,7 @@ * get a string from a file */ tree_constant * -builtin_fgets (tree_constant *args, int nargin, int nargout) +builtin_fgets (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 3 && nargout < 3) @@ -600,7 +600,7 @@ * do_fortran_indexing is true... */ tree_constant * -builtin_find (tree_constant *args, int nargin, int nargout) +builtin_find (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin == 2) @@ -617,7 +617,7 @@ * Don\'t really count floating point operations. */ tree_constant * -builtin_flops (tree_constant *args, int nargin, int nargout) +builtin_flops (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin > 2) @@ -633,7 +633,7 @@ * Opening a file. */ tree_constant * -builtin_fopen (tree_constant *args, int nargin, int nargout) +builtin_fopen (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 3) @@ -657,7 +657,7 @@ * Formatted printing to a file. */ tree_constant * -builtin_fprintf (tree_constant *args, int nargin, int nargout) +builtin_fprintf (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin < 3) @@ -671,7 +671,7 @@ * rewind a file */ tree_constant * -builtin_frewind (tree_constant *args, int nargin, int nargout) +builtin_frewind (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -685,7 +685,7 @@ * report on open files */ tree_constant * -builtin_freport (tree_constant *args, int nargin, int nargout) +builtin_freport (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin > 1) @@ -698,7 +698,7 @@ * Formatted reading from a file. */ tree_constant * -builtin_fscanf (tree_constant *args, int nargin, int nargout) +builtin_fscanf (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2 && nargin != 3) @@ -712,7 +712,7 @@ * seek a point in a file for reading and/or writing */ tree_constant * -builtin_fseek (tree_constant *args, int nargin, int nargout) +builtin_fseek (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 3 && nargin != 4) @@ -734,7 +734,7 @@ } tree_constant * -builtin_fsolve (tree_constant *args, int nargin, int nargout) +builtin_fsolve (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -765,7 +765,7 @@ } tree_constant * -builtin_fsqp (tree_constant *args, int nargin, int nargout) +builtin_fsqp (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -788,7 +788,7 @@ * tell current position of file */ tree_constant * -builtin_ftell (tree_constant *args, int nargin, int nargout) +builtin_ftell (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -802,7 +802,7 @@ * Get the value of an environment variable. */ tree_constant * -builtin_getenv (tree_constant *args, int nargin, int nargout) +builtin_getenv (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin == 2 && args[1].is_string_type ()) @@ -823,7 +823,7 @@ * Inverse Fast Fourier Transform */ tree_constant * -builtin_ifft (tree_constant *args, int nargin, int nargout) +builtin_ifft (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -843,7 +843,7 @@ * Inverse of a square matrix. */ tree_constant * -builtin_inv (tree_constant *args, int nargin, int nargout) +builtin_inv (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -863,7 +863,7 @@ * Prompt user for input. */ tree_constant * -builtin_input (tree_constant *args, int nargin, int nargout) +builtin_input (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -882,7 +882,7 @@ * Is the argument a string? */ tree_constant * -builtin_isstr (tree_constant *args, int nargin, int nargout) +builtin_isstr (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -902,7 +902,7 @@ * Maybe help in debugging. */ tree_constant * -builtin_keyboard (tree_constant *args, int nargin, int nargout) +builtin_keyboard (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -921,7 +921,7 @@ * Matrix logarithm. */ tree_constant * -builtin_logm (tree_constant *args, int nargin, int nargout) +builtin_logm (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -943,7 +943,7 @@ } tree_constant * -builtin_lpsolve (tree_constant *args, int nargin, int nargout) +builtin_lpsolve (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -981,7 +981,7 @@ } tree_constant * -builtin_lsode (tree_constant *args, int nargin, int nargout) +builtin_lsode (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -998,7 +998,7 @@ * LU factorization. */ tree_constant * -builtin_lu (tree_constant *args, int nargin, int nargout) +builtin_lu (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1015,7 +1015,7 @@ * Max values. */ tree_constant * -builtin_max (tree_constant *args, int nargin, int nargout) +builtin_max (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1032,7 +1032,7 @@ * Min values. */ tree_constant * -builtin_min (tree_constant *args, int nargin, int nargout) +builtin_min (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1071,7 +1071,7 @@ } tree_constant * -builtin_npsol (tree_constant *args, int nargin, int nargout) +builtin_npsol (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1101,7 +1101,7 @@ * A matrix of ones. */ tree_constant * -builtin_ones (tree_constant *args, int nargin, int nargout) +builtin_ones (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1126,7 +1126,7 @@ * You guessed it. */ tree_constant * -builtin_pause (tree_constant *args, int nargin, int nargout) +builtin_pause (const tree_constant *args, int nargin, int nargout) { if (! (nargin == 1 || nargin == 2)) { @@ -1148,7 +1148,7 @@ * Delete turds from /tmp. */ tree_constant * -builtin_purge_tmp_files (tree_constant *, int, int) +builtin_purge_tmp_files (const tree_constant *, int, int) { cleanup_tmp_files (); return NULL_TREE_CONST; @@ -1158,7 +1158,7 @@ * Formatted printing. */ tree_constant * -builtin_printf (tree_constant *args, int nargin, int nargout) +builtin_printf (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin < 2) @@ -1172,7 +1172,7 @@ * Product. */ tree_constant * -builtin_prod (tree_constant *args, int nargin, int nargout) +builtin_prod (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -1192,7 +1192,7 @@ * Print name of current working directory. */ tree_constant * -builtin_pwd (tree_constant *args, int nargin, int nargout) +builtin_pwd (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; char *directory; @@ -1242,7 +1242,7 @@ } tree_constant * -builtin_qpsol (tree_constant *args, int nargin, int nargout) +builtin_qpsol (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1271,7 +1271,7 @@ * QR factorization. */ tree_constant * -builtin_qr (tree_constant *args, int nargin, int nargout) +builtin_qr (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1288,7 +1288,7 @@ * generalized eigenvalues via qz */ tree_constant * -builtin_qzval (tree_constant *args, int nargin, int nargout) +builtin_qzval (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1306,7 +1306,7 @@ * Random numbers. */ tree_constant * -builtin_quad (tree_constant *args, int nargin, int nargout) +builtin_quad (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1325,7 +1325,7 @@ * I'm outta here. */ tree_constant * -builtin_quit (tree_constant *args, int nargin, int nargout) +builtin_quit (const tree_constant *args, int nargin, int nargout) { quitting_gracefully = 1; clean_up_and_exit (0); @@ -1336,7 +1336,7 @@ * Random numbers. */ tree_constant * -builtin_rand (tree_constant *args, int nargin, int nargout) +builtin_rand (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1360,7 +1360,7 @@ * Replot current plot. */ tree_constant * -builtin_replot (tree_constant *args, int nargin, int nargout) +builtin_replot (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1376,7 +1376,7 @@ * Formatted reading. */ tree_constant * -builtin_scanf (tree_constant *args, int nargin, int nargout) +builtin_scanf (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -1409,7 +1409,7 @@ * Execute a shell command. */ tree_constant * -builtin_shell_command (tree_constant *args, int nargin, int nargout) +builtin_shell_command (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1447,7 +1447,7 @@ * Report rows and columns. */ tree_constant * -builtin_size (tree_constant *args, int nargin, int nargout) +builtin_size (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1484,7 +1484,7 @@ * Sort columns. */ tree_constant * -builtin_sort (tree_constant *args, int nargin, int nargout) +builtin_sort (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1500,7 +1500,7 @@ * Formatted printing to a string. */ tree_constant * -builtin_sprintf (tree_constant *args, int nargin, int nargout) +builtin_sprintf (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin < 2) @@ -1514,7 +1514,7 @@ * Matrix sqrt. */ tree_constant * -builtin_sqrtm (tree_constant *args, int nargin, int nargout) +builtin_sqrtm (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1530,7 +1530,7 @@ * Formatted reading from a string. */ tree_constant * -builtin_sscanf (tree_constant *args, int nargin, int nargout) +builtin_sscanf (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 3) @@ -1544,7 +1544,7 @@ * Sum. */ tree_constant * -builtin_sum (tree_constant *args, int nargin, int nargout) +builtin_sum (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -1564,7 +1564,7 @@ * Sum of squares. */ tree_constant * -builtin_sumsq (tree_constant *args, int nargin, int nargout) +builtin_sumsq (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; if (nargin != 2) @@ -1584,7 +1584,7 @@ * Singluar value decomposition. */ tree_constant * -builtin_svd (tree_constant *args, int nargin, int nargout) +builtin_svd (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1601,7 +1601,7 @@ * Sylvester equation solver. */ tree_constant * -builtin_syl (tree_constant *args, int nargin, int nargout) +builtin_syl (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1618,7 +1618,7 @@ * Schur Decomposition */ tree_constant * -builtin_schur (tree_constant *args, int nargin, int nargout) +builtin_schur (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1643,7 +1643,7 @@ * Givens rotation */ tree_constant * -builtin_givens (tree_constant *args, int nargin, int nargout) +builtin_givens (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1659,7 +1659,7 @@ * Hessenberg Decomposition */ tree_constant * -builtin_hess (tree_constant *args, int nargin, int nargout) +builtin_hess (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -1676,7 +1676,7 @@ * Copying information. */ tree_constant * -builtin_warranty (tree_constant *args, int nargin, int nargout) +builtin_warranty (const tree_constant *args, int nargin, int nargout) { ostrstream output_buf; output_buf << "\n Octave, version " << version_string @@ -1704,7 +1704,7 @@ * A matrix of zeros. */ tree_constant * -builtin_zeros (tree_constant *args, int nargin, int nargout) +builtin_zeros (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST;
--- a/src/g-builtins.h +++ b/src/g-builtins.h @@ -39,85 +39,86 @@ char *help_string; }; -extern tree_constant *builtin_all (tree_constant *, int, int); -extern tree_constant *builtin_any (tree_constant *, int, int); -extern tree_constant *builtin_balance (tree_constant *, int, int); -extern tree_constant *builtin_clc (tree_constant *, int, int); -extern tree_constant *builtin_clock (tree_constant *, int, int); -extern tree_constant *builtin_closeplot (tree_constant *, int, int); -extern tree_constant *builtin_colloc (tree_constant *, int, int); -extern tree_constant *builtin_cumprod (tree_constant *, int, int); -extern tree_constant *builtin_cumsum (tree_constant *, int, int); -extern tree_constant *builtin_dassl (tree_constant *, int, int); -extern tree_constant *builtin_date (tree_constant *, int, int); -extern tree_constant *builtin_det (tree_constant *, int, int); -extern tree_constant *builtin_diag (tree_constant *, int, int); +extern tree_constant *builtin_all (const tree_constant *, int, int); +extern tree_constant *builtin_any (const tree_constant *, int, int); +extern tree_constant *builtin_balance (const tree_constant *, int, int); +extern tree_constant *builtin_clc (const tree_constant *, int, int); +extern tree_constant *builtin_clock (const tree_constant *, int, int); +extern tree_constant *builtin_closeplot (const tree_constant *, int, int); +extern tree_constant *builtin_colloc (const tree_constant *, int, int); +extern tree_constant *builtin_cumprod (const tree_constant *, int, int); +extern tree_constant *builtin_cumsum (const tree_constant *, int, int); +extern tree_constant *builtin_dassl (const tree_constant *, int, int); +extern tree_constant *builtin_date (const tree_constant *, int, int); +extern tree_constant *builtin_det (const tree_constant *, int, int); +extern tree_constant *builtin_diag (const tree_constant *, int, int); extern tree_constant *builtin_disp (tree_constant *, int, int); -extern tree_constant *builtin_eig (tree_constant *, int, int); +extern tree_constant *builtin_eig (const tree_constant *, int, int); extern tree_constant *builtin_error (tree_constant *, int, int); -extern tree_constant *builtin_eval (tree_constant *, int, int); -extern tree_constant *builtin_exist (tree_constant *, int, int); -extern tree_constant *builtin_expm (tree_constant *, int, int); -extern tree_constant *builtin_eye (tree_constant *, int, int); -extern tree_constant *builtin_fclose (tree_constant *, int, int); -extern tree_constant *builtin_feval (tree_constant *, int, int); -extern tree_constant *builtin_fflush (tree_constant *, int, int); -extern tree_constant *builtin_fft (tree_constant *, int, int); -extern tree_constant *builtin_fgets (tree_constant *, int, int); -extern tree_constant *builtin_find (tree_constant *, int, int); -extern tree_constant *builtin_flops (tree_constant *, int, int); -extern tree_constant *builtin_fopen (tree_constant *, int, int); -extern tree_constant *builtin_fprintf (tree_constant *, int, int); -extern tree_constant *builtin_frewind (tree_constant *, int, int); -extern tree_constant *builtin_freport (tree_constant *, int, int); -extern tree_constant *builtin_fscanf (tree_constant *, int, int); -extern tree_constant *builtin_fseek (tree_constant *, int, int); -extern tree_constant *builtin_fsolve (tree_constant *, int, int); -extern tree_constant *builtin_fsqp (tree_constant *, int, int); -extern tree_constant *builtin_ftell (tree_constant *, int, int); -extern tree_constant *builtin_getenv (tree_constant *, int, int); -extern tree_constant *builtin_givens (tree_constant *, int, int); -extern tree_constant *builtin_hess (tree_constant *, int, int); -extern tree_constant *builtin_input (tree_constant *, int, int); -extern tree_constant *builtin_ifft (tree_constant *, int, int); -extern tree_constant *builtin_inv (tree_constant *, int, int); -extern tree_constant *builtin_isstr (tree_constant *, int, int); -extern tree_constant *builtin_keyboard (tree_constant *, int, int); -extern tree_constant *builtin_logm (tree_constant *, int, int); -extern tree_constant *builtin_lpsolve (tree_constant *, int, int); -extern tree_constant *builtin_lsode (tree_constant *, int, int); -extern tree_constant *builtin_lu (tree_constant *, int, int); -extern tree_constant *builtin_max (tree_constant *, int, int); -extern tree_constant *builtin_min (tree_constant *, int, int); -extern tree_constant *builtin_npsol (tree_constant *, int, int); -extern tree_constant *builtin_ones (tree_constant *, int, int); -extern tree_constant *builtin_pause (tree_constant *, int, int); -extern tree_constant *builtin_purge_tmp_files (tree_constant *, int, int); -extern tree_constant *builtin_printf (tree_constant *, int, int); -extern tree_constant *builtin_prod (tree_constant *, int, int); -extern tree_constant *builtin_pwd (tree_constant *, int, int); -extern tree_constant *builtin_qpsol (tree_constant *, int, int); -extern tree_constant *builtin_qr (tree_constant *, int, int); -extern tree_constant *builtin_quad (tree_constant *, int, int); -extern tree_constant *builtin_quit (tree_constant *, int, int); -extern tree_constant *builtin_qzval (tree_constant *, int, int); -extern tree_constant *builtin_rand (tree_constant *, int, int); -extern tree_constant *builtin_replot (tree_constant *, int, int); +extern tree_constant *builtin_eval (const tree_constant *, int, int); +extern tree_constant *builtin_exist (const tree_constant *, int, int); +extern tree_constant *builtin_expm (const tree_constant *, int, int); +extern tree_constant *builtin_eye (const tree_constant *, int, int); +extern tree_constant *builtin_fclose (const tree_constant *, int, int); +extern tree_constant *builtin_feval (const tree_constant *, int, int); +extern tree_constant *builtin_fflush (const tree_constant *, int, int); +extern tree_constant *builtin_fft (const tree_constant *, int, int); +extern tree_constant *builtin_fgets (const tree_constant *, int, int); +extern tree_constant *builtin_find (const tree_constant *, int, int); +extern tree_constant *builtin_flops (const tree_constant *, int, int); +extern tree_constant *builtin_fopen (const tree_constant *, int, int); +extern tree_constant *builtin_fprintf (const tree_constant *, int, int); +extern tree_constant *builtin_frewind (const tree_constant *, int, int); +extern tree_constant *builtin_freport (const tree_constant *, int, int); +extern tree_constant *builtin_fscanf (const tree_constant *, int, int); +extern tree_constant *builtin_fseek (const tree_constant *, int, int); +extern tree_constant *builtin_fsolve (const tree_constant *, int, int); +extern tree_constant *builtin_fsqp (const tree_constant *, int, int); +extern tree_constant *builtin_ftell (const tree_constant *, int, int); +extern tree_constant *builtin_getenv (const tree_constant *, int, int); +extern tree_constant *builtin_givens (const tree_constant *, int, int); +extern tree_constant *builtin_hess (const tree_constant *, int, int); +extern tree_constant *builtin_input (const tree_constant *, int, int); +extern tree_constant *builtin_ifft (const tree_constant *, int, int); +extern tree_constant *builtin_inv (const tree_constant *, int, int); +extern tree_constant *builtin_isstr (const tree_constant *, int, int); +extern tree_constant *builtin_keyboard (const tree_constant *, int, int); +extern tree_constant *builtin_logm (const tree_constant *, int, int); +extern tree_constant *builtin_lpsolve (const tree_constant *, int, int); +extern tree_constant *builtin_lsode (const tree_constant *, int, int); +extern tree_constant *builtin_lu (const tree_constant *, int, int); +extern tree_constant *builtin_max (const tree_constant *, int, int); +extern tree_constant *builtin_min (const tree_constant *, int, int); +extern tree_constant *builtin_npsol (const tree_constant *, int, int); +extern tree_constant *builtin_ones (const tree_constant *, int, int); +extern tree_constant *builtin_pause (const tree_constant *, int, int); +extern tree_constant *builtin_purge_tmp_files (const tree_constant *, + int, int); +extern tree_constant *builtin_printf (const tree_constant *, int, int); +extern tree_constant *builtin_prod (const tree_constant *, int, int); +extern tree_constant *builtin_pwd (const tree_constant *, int, int); +extern tree_constant *builtin_qpsol (const tree_constant *, int, int); +extern tree_constant *builtin_qr (const tree_constant *, int, int); +extern tree_constant *builtin_quad (const tree_constant *, int, int); +extern tree_constant *builtin_quit (const tree_constant *, int, int); +extern tree_constant *builtin_qzval (const tree_constant *, int, int); +extern tree_constant *builtin_rand (const tree_constant *, int, int); +extern tree_constant *builtin_replot (const tree_constant *, int, int); extern tree_constant *builtin_setstr (tree_constant *, int, int); -extern tree_constant *builtin_scanf (tree_constant *, int, int); -extern tree_constant *builtin_schur (tree_constant *, int, int); -extern tree_constant *builtin_shell_command (tree_constant *, int, int); -extern tree_constant *builtin_size (tree_constant *, int, int); -extern tree_constant *builtin_sort (tree_constant *, int, int); -extern tree_constant *builtin_sprintf (tree_constant *, int, int); -extern tree_constant *builtin_sqrtm (tree_constant *, int, int); -extern tree_constant *builtin_sscanf (tree_constant *, int, int); -extern tree_constant *builtin_sum (tree_constant *, int, int); -extern tree_constant *builtin_sumsq (tree_constant *, int, int); -extern tree_constant *builtin_svd (tree_constant *, int, int); -extern tree_constant *builtin_syl (tree_constant *, int, int); -extern tree_constant *builtin_warranty (tree_constant *, int, int); -extern tree_constant *builtin_zeros (tree_constant *, int, int); +extern tree_constant *builtin_scanf (const tree_constant *, int, int); +extern tree_constant *builtin_schur (const tree_constant *, int, int); +extern tree_constant *builtin_shell_command (const tree_constant *, int, int); +extern tree_constant *builtin_size (const tree_constant *, int, int); +extern tree_constant *builtin_sort (const tree_constant *, int, int); +extern tree_constant *builtin_sprintf (const tree_constant *, int, int); +extern tree_constant *builtin_sqrtm (const tree_constant *, int, int); +extern tree_constant *builtin_sscanf (const tree_constant *, int, int); +extern tree_constant *builtin_sum (const tree_constant *, int, int); +extern tree_constant *builtin_sumsq (const tree_constant *, int, int); +extern tree_constant *builtin_svd (const tree_constant *, int, int); +extern tree_constant *builtin_syl (const tree_constant *, int, int); +extern tree_constant *builtin_warranty (const tree_constant *, int, int); +extern tree_constant *builtin_zeros (const tree_constant *, int, int); #endif
--- a/src/input.cc +++ b/src/input.cc @@ -83,7 +83,7 @@ #include "builtins.h" // Global pointer for eval(). -char *current_eval_string = (char *) NULL; +const char *current_eval_string = (char *) NULL; // Nonzero means get input from current_eval_string. int get_input_from_eval_string = 0;
--- a/src/input.h +++ b/src/input.h @@ -41,7 +41,7 @@ extern void initialize_readline (void); // Global pointer for eval(). -extern char *current_eval_string; +extern const char *current_eval_string; // Nonzero means get input from current_eval_string. extern int get_input_from_eval_string;
--- a/src/mappers.cc +++ b/src/mappers.cc @@ -26,6 +26,7 @@ #endif #include <float.h> +#include <Complex.h> #include "mappers.h" #include "utils.h"
--- a/src/mappers.h +++ b/src/mappers.h @@ -28,7 +28,7 @@ #pragma interface #endif -#include <Complex.h> +class Complex; #include "missing-math.h"
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -139,7 +139,7 @@ } static double -pr_max_internal (Matrix& m) +pr_max_internal (const Matrix& m) { int nr = m.rows (); int nc = m.columns (); @@ -160,7 +160,7 @@ } static double -pr_min_internal (Matrix& m) +pr_min_internal (const Matrix& m) { int nr = m.rows (); int nc = m.columns (); @@ -272,7 +272,7 @@ } static void -set_format (Matrix& m, int& fw) +set_format (const Matrix& m, int& fw) { curr_real_fmt = (char *) NULL; curr_imag_fmt = (char *) NULL; @@ -379,14 +379,14 @@ } static inline void -set_format (Matrix& m) +set_format (const Matrix& m) { int fw; set_format (m, fw); } static void -set_format (Complex& c, int& r_fw, int& i_fw) +set_format (const Complex& c, int& r_fw, int& i_fw) { curr_real_fmt = (char *) NULL; curr_imag_fmt = (char *) NULL; @@ -518,14 +518,14 @@ } static inline void -set_format (Complex& c) +set_format (const Complex& c) { int r_fw, i_fw; set_format (c, r_fw, i_fw); } static void -set_format (ComplexMatrix& cm, int& r_fw, int& i_fw) +set_format (const ComplexMatrix& cm, int& r_fw, int& i_fw) { curr_real_fmt = (char *) NULL; curr_imag_fmt = (char *) NULL; @@ -656,7 +656,7 @@ } static int -all_elements_are_ints (Range& r) +all_elements_are_ints (const Range& r) { // If the base and increment are ints, the final value in the range // will also be an integer, even if the limit is not. @@ -668,14 +668,14 @@ } static inline void -set_format (ComplexMatrix& cm) +set_format (const ComplexMatrix& cm) { int r_fw, i_fw; set_format (cm, r_fw, i_fw); } static void -set_format (Range& r, int& fw) +set_format (const Range& r, int& fw) { curr_real_fmt = (char *) NULL; curr_imag_fmt = (char *) NULL; @@ -777,14 +777,14 @@ } static inline void -set_format (Range& r) +set_format (const Range& r) { int fw; set_format (r, fw); } static inline void -pr_any_float (char *fmt, ostrstream& os, double d, int fw = 0) +pr_any_float (const char *fmt, ostrstream& os, double d, int fw = 0) { if (d == -0.0) d = 0.0; @@ -831,7 +831,7 @@ } static inline void -pr_complex (ostrstream& os, Complex& c, int r_fw = 0, int i_fw = 0) +pr_complex (ostrstream& os, const Complex& c, int r_fw = 0, int i_fw = 0) { double r = c.real (); pr_float (os, r, r_fw); @@ -875,7 +875,7 @@ } void -octave_print_internal (ostrstream& os, Matrix& m) +octave_print_internal (ostrstream& os, const Matrix& m) { int nr = m.rows (); int nc = m.columns (); @@ -953,7 +953,7 @@ } void -octave_print_internal (ostrstream& os, Complex& c) +octave_print_internal (ostrstream& os, const Complex& c) { if (plus_format) { @@ -974,7 +974,7 @@ } void -octave_print_internal (ostrstream& os, ComplexMatrix& cm) +octave_print_internal (ostrstream& os, const ComplexMatrix& cm) { int nr = cm.rows (); int nc = cm.columns (); @@ -1056,7 +1056,7 @@ } void -octave_print_internal (ostrstream& os, Range& r) +octave_print_internal (ostrstream& os, const Range& r) { double b = r.base (); double increment = r.inc ();
--- a/src/pr-output.h +++ b/src/pr-output.h @@ -36,10 +36,10 @@ class Range; extern void octave_print_internal (ostrstream& os, double d); -extern void octave_print_internal (ostrstream& os, Matrix& m); -extern void octave_print_internal (ostrstream& os, Complex& c); -extern void octave_print_internal (ostrstream& os, ComplexMatrix& cm); -extern void octave_print_internal (ostrstream& os, Range& r); +extern void octave_print_internal (ostrstream& os, const Matrix& m); +extern void octave_print_internal (ostrstream& os, const Complex& c); +extern void octave_print_internal (ostrstream& os, const ComplexMatrix& cm); +extern void octave_print_internal (ostrstream& os, const Range& r); extern void set_format_style (int argc, char **argv);
--- a/src/pt-base.h +++ b/src/pt-base.h @@ -38,6 +38,7 @@ #include <time.h> #include <assert.h> +class ostream; class tree_constant; class tree_identifier; class tree_argument_list; @@ -94,19 +95,19 @@ virtual ~tree (void) { } // Only the finest cheese... - virtual int is_identifier (void) + virtual int is_identifier (void) const { return 0; } - virtual int is_constant (void) + virtual int is_constant (void) const { return 0; } - virtual int is_builtin (void) + virtual int is_builtin (void) const { return 0; } - virtual int is_index_expression (void) + virtual int is_index_expression (void) const { return 0; } - virtual int is_assignment_expression (void) + virtual int is_assignment_expression (void) const { return 0; } virtual tree *def (void) @@ -145,15 +146,15 @@ virtual tree_constant eval (int argc, char **argv, int print); - virtual tree_constant *eval (tree_constant *args, int n_in, int nout, + virtual tree_constant *eval (const tree_constant *args, int n_in, int nout, int print) { assert (0); return NULL_TREE_CONST; } virtual int save (ostream& os, int mark_as_global = 0) { assert (0); return 0; } - virtual int line (void) { return line_num; } - virtual int column (void) { return column_num; } + virtual int line (void) const { return line_num; } + virtual int column (void) const { return column_num; } protected: int line_num;
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -387,12 +387,6 @@ type_tag = string_constant; } -tree_constant_rep::tree_constant_rep (const String& s) -{ - string = strsave (s); - type_tag = string_constant; -} - tree_constant_rep::tree_constant_rep (double b, double l, double i) { range = new Range (b, l, i); @@ -655,7 +649,7 @@ } double -tree_constant_rep::to_scalar (void) +tree_constant_rep::to_scalar (void) const { tree_constant tmp = make_numeric (); @@ -702,7 +696,7 @@ } ColumnVector -tree_constant_rep::to_vector (void) +tree_constant_rep::to_vector (void) const { tree_constant tmp = make_numeric (); @@ -743,7 +737,7 @@ } Matrix -tree_constant_rep::to_matrix (void) +tree_constant_rep::to_matrix (void) const { tree_constant tmp = make_numeric (); @@ -829,7 +823,7 @@ } tree_constant -tree_constant_rep::make_numeric (int force_str_conv = 0) +tree_constant_rep::make_numeric (int force_str_conv = 0) const { tree_constant retval; switch (type_tag) @@ -1248,7 +1242,7 @@ } tree_constant * -tree_constant_rep::eval (tree_constant *args, int nargin, int nargout, +tree_constant_rep::eval (const tree_constant *args, int nargin, int nargout, int print) { if (error_state) @@ -1535,7 +1529,7 @@ } double -tree_constant_rep::double_value (void) +tree_constant_rep::double_value (void) const { switch (type_tag) { @@ -1560,7 +1554,7 @@ } Matrix -tree_constant_rep::matrix_value (void) +tree_constant_rep::matrix_value (void) const { switch (type_tag) { @@ -1585,7 +1579,7 @@ } Complex -tree_constant_rep::complex_value (void) +tree_constant_rep::complex_value (void) const { switch (type_tag) { @@ -1600,7 +1594,7 @@ } ComplexMatrix -tree_constant_rep::complex_matrix_value (void) +tree_constant_rep::complex_matrix_value (void) const { switch (type_tag) { @@ -1626,21 +1620,21 @@ } char * -tree_constant_rep::string_value (void) +tree_constant_rep::string_value (void) const { assert (type_tag == string_constant); return string; } Range -tree_constant_rep::range_value (void) +tree_constant_rep::range_value (void) const { assert (type_tag == range_constant); return *range; } int -tree_constant_rep::rows (void) +tree_constant_rep::rows (void) const { int retval = -1; switch (type_tag) @@ -1671,7 +1665,7 @@ } int -tree_constant_rep::columns (void) +tree_constant_rep::columns (void) const { int retval = -1; switch (type_tag) @@ -1706,7 +1700,7 @@ } tree_constant -tree_constant_rep::all (void) +tree_constant_rep::all (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -1752,7 +1746,7 @@ } tree_constant -tree_constant_rep::any (void) +tree_constant_rep::any (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -1798,10 +1792,10 @@ } tree_constant -tree_constant_rep::isstr (void) +tree_constant_rep::isstr (void) const { double status = 0.0; - if (const_type () == string_constant) + if (type_tag == string_constant) status = 1.0; tree_constant retval (status); return retval; @@ -1879,7 +1873,7 @@ } tree_constant -tree_constant_rep::cumprod (void) +tree_constant_rep::cumprod (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -1919,7 +1913,7 @@ } tree_constant -tree_constant_rep::cumsum (void) +tree_constant_rep::cumsum (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -1959,7 +1953,7 @@ } tree_constant -tree_constant_rep::prod (void) +tree_constant_rep::prod (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -1999,7 +1993,7 @@ } tree_constant -tree_constant_rep::sum (void) +tree_constant_rep::sum (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -2039,7 +2033,7 @@ } tree_constant -tree_constant_rep::sumsq (void) +tree_constant_rep::sumsq (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -2082,7 +2076,7 @@ } static tree_constant -make_diag (Matrix& v, int k) +make_diag (const Matrix& v, int k) { int nr = v.rows (); int nc = v.columns (); @@ -2124,7 +2118,7 @@ } static tree_constant -make_diag (ComplexMatrix& v, int k) +make_diag (const ComplexMatrix& v, int k) { int nr = v.rows (); int nc = v.columns (); @@ -2166,7 +2160,7 @@ } tree_constant -tree_constant_rep::diag (void) +tree_constant_rep::diag (void) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -2222,7 +2216,7 @@ } tree_constant -tree_constant_rep::diag (tree_constant& a) +tree_constant_rep::diag (const tree_constant& a) const { if (type_tag == string_constant || type_tag == range_constant) { @@ -2336,7 +2330,7 @@ } tree_constant -tree_constant_rep::mapper (Mapper_fcn& m_fcn, int print) +tree_constant_rep::mapper (Mapper_fcn& m_fcn, int print) const { tree_constant retval; @@ -2475,7 +2469,7 @@ * and/or gripe when appropriate. */ tree_constant * -vector_of_empties (int nargout, char *fcn_name) +vector_of_empties (int nargout, const char *fcn_name) { tree_constant *retval = NULL_TREE_CONST;
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -29,13 +29,13 @@ #endif #include <stdlib.h> -#include <String.h> -#include "Range.h" #include "builtins.h" -#include "Matrix.h" -#include "idx-vector.h" #include "tree-base.h" +#include "Matrix.h" // Needed for some inline functions. +#include "Range.h" // Ditto. + +class idx_vector; /* * How about a few macros? @@ -251,7 +251,6 @@ tree_constant_rep (const ComplexColumnVector& v, int pcv); tree_constant_rep (const char *s); - tree_constant_rep (const String& s); tree_constant_rep (double base, double limit, double inc); tree_constant_rep (const Range& r); @@ -273,54 +272,54 @@ void maybe_resize (int imax, force_orient fo = no_orient); void maybe_resize (int imax, int jmax); - int valid_as_scalar_index (void); + int valid_as_scalar_index (void) const; - int is_defined (void) + int is_defined (void) const { return type_tag != tree_constant_rep::unknown_constant; } - int is_undefined (void) + int is_undefined (void) const { return type_tag == tree_constant_rep::unknown_constant; } - int is_string_type (void) + int is_string_type (void) const { return type_tag == tree_constant_rep::string_constant; } - int is_scalar_type (void) + int is_scalar_type (void) const { return type_tag == scalar_constant || type_tag == complex_scalar_constant; } - int is_matrix_type (void) + int is_matrix_type (void) const { return type_tag == matrix_constant || type_tag == complex_matrix_constant; } - int is_real_type (void) + int is_real_type (void) const { return type_tag == scalar_constant || type_tag == matrix_constant || type_tag == range_constant; } - int is_complex_type (void) + int is_complex_type (void) const { return type_tag == complex_matrix_constant || type_tag == complex_scalar_constant; } - int is_numeric_type (void) + int is_numeric_type (void) const { return type_tag == scalar_constant || type_tag == matrix_constant || type_tag == complex_matrix_constant || type_tag == complex_scalar_constant; } - int is_numeric_or_range_type (void) + int is_numeric_or_range_type (void) const { return type_tag == scalar_constant || type_tag == matrix_constant || type_tag == complex_matrix_constant || type_tag == complex_scalar_constant || type_tag == range_constant; } - double to_scalar (void); - ColumnVector to_vector (void); - Matrix to_matrix (void); + double to_scalar (void) const; + ColumnVector to_vector (void) const; + Matrix to_matrix (void) const; tree_constant_rep::constant_type force_numeric (int force_str_conv = 0); - tree_constant make_numeric (int force_str_conv = 0); + tree_constant make_numeric (int force_str_conv = 0) const; friend tree_constant do_binary_op (tree_constant& a, tree_constant& b, tree::expression_type t); @@ -351,7 +350,8 @@ void vector_assignment (tree_constant& rhs, tree_constant& i_arg); - void check_vector_assign (int rhs_nr, int rhs_nc, int ilen, char *rm); + void check_vector_assign (int rhs_nr, int rhs_nc, int ilen, + const char *rm); void do_vector_assign (tree_constant& rhs, int i); void do_vector_assign (tree_constant& rhs, idx_vector& i); @@ -394,111 +394,124 @@ void eval (int print); - tree_constant *eval (tree_constant *args, int n_in, int n_out, int print); - - tree_constant do_scalar_index (tree_constant *args, int nargin); + tree_constant *eval (const tree_constant *args, int n_in, int n_out, + int print); - tree_constant do_matrix_index (tree_constant *args, int nargin); + tree_constant do_scalar_index (const tree_constant *args, + int nargin) const; - tree_constant do_matrix_index (tree_constant& i_arg); + tree_constant do_matrix_index (const tree_constant *args, int nargin) const; + + tree_constant do_matrix_index (const tree_constant& i_arg) const; - tree_constant do_matrix_index (tree_constant& i_arg, tree_constant& j_arg); + tree_constant do_matrix_index (const tree_constant& i_arg, + const tree_constant& j_arg) const; - tree_constant do_matrix_index (constant_type i); + tree_constant do_matrix_index (constant_type i) const; - tree_constant fortran_style_matrix_index (tree_constant& i_arg); - tree_constant fortran_style_matrix_index (Matrix& mi); + tree_constant fortran_style_matrix_index (const tree_constant& i_arg) const; + tree_constant fortran_style_matrix_index (const Matrix& mi) const; - tree_constant do_vector_index (tree_constant& i_arg); + tree_constant do_vector_index (const tree_constant& i_arg) const; - tree_constant do_matrix_index (int i, tree_constant& i_arg); - tree_constant do_matrix_index (idx_vector& i, tree_constant& i_arg); - tree_constant do_matrix_index (Range& i, int imax, tree_constant& i_arg); - tree_constant do_matrix_index (constant_type i, tree_constant& i_arg); + tree_constant do_matrix_index (int i, const tree_constant& i_arg) const; + tree_constant do_matrix_index (const idx_vector& i, + const tree_constant& i_arg) const; + tree_constant do_matrix_index (const Range& i, int imax, + const tree_constant& i_arg) const; + tree_constant do_matrix_index (constant_type i, + const tree_constant& i_arg) const; - tree_constant do_matrix_index (int i, int j); - tree_constant do_matrix_index (int i, idx_vector& j); - tree_constant do_matrix_index (int i, Range& j); - tree_constant do_matrix_index (int i, constant_type cj); + tree_constant do_matrix_index (int i, int j) const; + tree_constant do_matrix_index (int i, const idx_vector& j) const; + tree_constant do_matrix_index (int i, const Range& j) const; + tree_constant do_matrix_index (int i, constant_type cj) const; - tree_constant do_matrix_index (idx_vector& i, int j); - tree_constant do_matrix_index (idx_vector& i, idx_vector& j); - tree_constant do_matrix_index (idx_vector& i, Range& j); - tree_constant do_matrix_index (idx_vector& i, constant_type j); + tree_constant do_matrix_index (const idx_vector& i, int j) const; + tree_constant do_matrix_index (const idx_vector& i, + const idx_vector& j) const; + tree_constant do_matrix_index (const idx_vector& i, const Range& j) const; + tree_constant do_matrix_index (const idx_vector& i, constant_type j) const; - tree_constant do_matrix_index (Range& i, int j); - tree_constant do_matrix_index (Range& i, idx_vector& j); - tree_constant do_matrix_index (Range& i, Range& j); - tree_constant do_matrix_index (Range& i, constant_type j); + tree_constant do_matrix_index (const Range& i, int j) const; + tree_constant do_matrix_index (const Range& i, const idx_vector& j) const; + tree_constant do_matrix_index (const Range& i, const Range& j) const; + tree_constant do_matrix_index (const Range& i, constant_type j) const; - tree_constant do_matrix_index (constant_type i, int j); - tree_constant do_matrix_index (constant_type i, idx_vector& j); - tree_constant do_matrix_index (constant_type i, Range& j); - tree_constant do_matrix_index (constant_type i, constant_type j); + tree_constant do_matrix_index (constant_type i, int j) const; + tree_constant do_matrix_index (constant_type i, const idx_vector& j) const; + tree_constant do_matrix_index (constant_type i, const Range& j) const; + tree_constant do_matrix_index (constant_type i, constant_type j) const; int save (ostream& os, int mark_as_global); int save_three_d (ostream& os, int parametric); int load (istream& is); constant_type load (istream& is, constant_type t); - double double_value (void); - Matrix matrix_value (void); - Complex complex_value (void); - ComplexMatrix complex_matrix_value (void); - char *string_value (void); - Range range_value (void); + double double_value (void) const; + Matrix matrix_value (void) const; + Complex complex_value (void) const; + ComplexMatrix complex_matrix_value (void) const; + char *string_value (void) const; + Range range_value (void) const; - int rows (void); - int columns (void); + int rows (void) const; + int columns (void) const; - tree_constant all (void); - tree_constant any (void); - tree_constant isstr (void); + tree_constant all (void) const; + tree_constant any (void) const; + tree_constant isstr (void) const; tree_constant convert_to_str (void); - tree_constant cumprod (void); - tree_constant cumsum (void); - tree_constant prod (void); - tree_constant sum (void); - tree_constant sumsq (void); + tree_constant cumprod (void) const; + tree_constant cumsum (void) const; + tree_constant prod (void) const; + tree_constant sum (void) const; + tree_constant sumsq (void) const; - tree_constant diag (void); - tree_constant diag (tree_constant& a); + tree_constant diag (void) const; + tree_constant diag (const tree_constant& a) const; - friend tree_constant fill_matrix (tree_constant& a, double d, - char *warn_for); - friend tree_constant fill_matrix (tree_constant& a, tree_constant& b, - double d, char *warn_for); + friend tree_constant fill_matrix (const tree_constant& a, + double d, const char *warn_for); + friend tree_constant fill_matrix (const tree_constant& a, + const tree_constant& b, + double d, const char *warn_for); - friend tree_constant identity_matrix (tree_constant& a); - friend tree_constant identity_matrix (tree_constant& a, tree_constant& b); - - friend tree_constant find_nonzero_elem_idx (tree_constant& a); + friend tree_constant identity_matrix (const tree_constant& a); + friend tree_constant identity_matrix (const tree_constant& a, + const tree_constant& b); - friend tree_constant *matrix_log (tree_constant& a); - friend tree_constant *matrix_sqrt (tree_constant& a); + friend tree_constant find_nonzero_elem_idx (const tree_constant& a); - friend tree_constant *column_max (tree_constant *args, int nargin, + friend tree_constant *matrix_log (const tree_constant& a); + friend tree_constant *matrix_sqrt (const tree_constant& a); + + friend tree_constant *column_max (const tree_constant *args, int nargin, int nargout); - friend tree_constant *column_min (tree_constant *args, int nargin, + friend tree_constant *column_min (const tree_constant *args, int nargin, int nargout); - friend tree_constant *sort (tree_constant *args, int nargin, int nargout); + friend tree_constant *sort (const tree_constant *args, int nargin, + int nargout); - friend tree_constant *feval (tree_constant *args, int nargin, int nargout); + friend tree_constant *feval (const tree_constant *args, int nargin, + int nargout); - friend tree_constant eval_string (tree_constant& arg, int& parse_status); + friend tree_constant eval_string (const tree_constant& arg, int& + parse_status); - friend tree_constant get_user_input (tree_constant *args, int nargin, - int nargout, int debug = 0); + friend tree_constant get_user_input (const tree_constant *args, + int nargin, int nargout, + int debug = 0); void print_if_string (ostream& os, int warn); - constant_type const_type (void) { return type_tag; } + constant_type const_type (void) const { return type_tag; } - tree_constant mapper (Mapper_fcn& m_fcn, int print); + tree_constant mapper (Mapper_fcn& m_fcn, int print) const; private: int count; @@ -559,8 +572,6 @@ tree_constant (const char *s) { rep = new tree_constant_rep (s); rep->count = 1; } - tree_constant (const String& s) - { rep = new tree_constant_rep (s); rep->count = 1; } tree_constant (double base, double limit, double inc) { rep = new tree_constant_rep (base, limit, inc); rep->count = 1; } @@ -592,34 +603,35 @@ return *this; } - int is_constant (void) { return 1; } + int is_constant (void) const { return 1; } - int is_scalar_type (void) { return rep->is_scalar_type (); } - int is_matrix_type (void) { return rep->is_matrix_type (); } + int is_scalar_type (void) const { return rep->is_scalar_type (); } + int is_matrix_type (void) const { return rep->is_matrix_type (); } - int is_real_type (void) { return rep->is_real_type (); } - int is_complex_type (void) { return rep->is_complex_type (); } + int is_real_type (void) const { return rep->is_real_type (); } + int is_complex_type (void) const { return rep->is_complex_type (); } - int is_numeric_type (void) { return rep->is_numeric_type (); } + int is_numeric_type (void) const { return rep->is_numeric_type (); } - int is_numeric_or_range_type (void) + int is_numeric_or_range_type (void) const { return rep->is_numeric_or_range_type (); } - int is_string_type (void) { return rep->is_string_type (); } + int is_string_type (void) const { return rep->is_string_type (); } - int valid_as_scalar_index (void) { return rep->valid_as_scalar_index (); } + int valid_as_scalar_index (void) const + { return rep->valid_as_scalar_index (); } - int is_defined (void) { return rep->is_defined (); } - int is_undefined (void) { return rep->is_undefined (); } + int is_defined (void) const { return rep->is_defined (); } + int is_undefined (void) const { return rep->is_undefined (); } - double to_scalar (void) { return rep->to_scalar (); } - ColumnVector to_vector (void) { return rep->to_vector (); } - Matrix to_matrix (void) { return rep->to_matrix (); } + double to_scalar (void) const { return rep->to_scalar (); } + ColumnVector to_vector (void) const { return rep->to_vector (); } + Matrix to_matrix (void) const { return rep->to_matrix (); } tree_constant_rep::constant_type force_numeric (int force_str_conv = 0) { return rep->force_numeric (force_str_conv); } - tree_constant make_numeric (int force_str_conv = 0) + tree_constant make_numeric (int force_str_conv = 0) const { if (is_numeric_type ()) return *this; @@ -627,7 +639,7 @@ return rep->make_numeric (force_str_conv); } - tree_constant make_numeric_or_range (void) + tree_constant make_numeric_or_range (void) const { if (is_numeric_type () || rep->type_tag == tree_constant_rep::range_constant) @@ -636,7 +648,7 @@ return rep->make_numeric (); } - tree_constant make_numeric_or_magic (void) + tree_constant make_numeric_or_magic (void) const { if (is_numeric_type () || rep->type_tag == tree_constant_rep::magic_colon) @@ -645,7 +657,7 @@ return rep->make_numeric (); } - tree_constant make_numeric_or_range_or_magic (void) + tree_constant make_numeric_or_range_or_magic (void) const { if (is_numeric_type () || rep->type_tag == tree_constant_rep::magic_colon @@ -677,41 +689,41 @@ (istream& is, tree_constant_rep::constant_type t) { return rep->load (is, t); } - double double_value (void) { return rep->double_value (); } - Matrix matrix_value (void) { return rep->matrix_value (); } - Complex complex_value (void) { return rep->complex_value (); } - ComplexMatrix complex_matrix_value (void) + double double_value (void) const { return rep->double_value (); } + Matrix matrix_value (void) const { return rep->matrix_value (); } + Complex complex_value (void) const { return rep->complex_value (); } + ComplexMatrix complex_matrix_value (void) const { return rep->complex_matrix_value (); } - char *string_value (void) { return rep->string_value (); } - Range range_value (void) { return rep->range_value (); } + char *string_value (void) const { return rep->string_value (); } + Range range_value (void) const { return rep->range_value (); } - int rows (void) { return rep->rows (); } - int columns (void) { return rep->columns (); } + int rows (void) const { return rep->rows (); } + int columns (void) const { return rep->columns (); } - int is_empty (void) { return (rows () == 0 || columns () == 0); } + int is_empty (void) const { return (rows () == 0 || columns () == 0); } - tree_constant all (void) { return rep->all (); } - tree_constant any (void) { return rep->any (); } - tree_constant isstr (void) { return rep->isstr (); } + tree_constant all (void) const { return rep->all (); } + tree_constant any (void) const { return rep->any (); } + tree_constant isstr (void) const { return rep->isstr (); } tree_constant convert_to_str (void) { return rep->convert_to_str (); } - tree_constant cumprod (void) { return rep->cumprod (); } - tree_constant cumsum (void) { return rep->cumsum (); } - tree_constant prod (void) { return rep->prod (); } - tree_constant sum (void) { return rep->sum (); } - tree_constant sumsq (void) { return rep->sumsq (); } + tree_constant cumprod (void) const { return rep->cumprod (); } + tree_constant cumsum (void) const { return rep->cumsum (); } + tree_constant prod (void) const { return rep->prod (); } + tree_constant sum (void) const { return rep->sum (); } + tree_constant sumsq (void) const { return rep->sumsq (); } - tree_constant diag (void) { return rep->diag (); } - tree_constant diag (tree_constant& a) { return rep->diag (a); } + tree_constant diag (void) const { return rep->diag (); } + tree_constant diag (const tree_constant& a) const { return rep->diag (a); } void print_if_string (ostream& os, int warn) { rep->print_if_string (os, warn); } - tree_constant_rep::constant_type const_type (void) + tree_constant_rep::constant_type const_type (void) const { return rep->const_type (); } - tree_constant mapper (Mapper_fcn& m_fcn, int print) + tree_constant mapper (Mapper_fcn& m_fcn, int print) const { return rep->mapper (m_fcn, print); } void bump_value (tree::expression_type et) @@ -737,7 +749,8 @@ return retval; } - tree_constant *eval (tree_constant *args, int n_in, int n_out, int print) + tree_constant *eval (const tree_constant *args, int n_in, int n_out, + int print) { return rep->eval (args, n_in, n_out, print); } private: @@ -749,7 +762,7 @@ * class but that don't need to be class members or friends. */ -extern tree_constant *vector_of_empties (int nargout, char *fcn_name); +extern tree_constant *vector_of_empties (int nargout, const char *fcn_name); #endif
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -101,19 +101,19 @@ } tree * -symbol_def::def (void) +symbol_def::def (void) const { return definition; } char * -symbol_def::help (void) +symbol_def::help (void) const { return help_string; } void -symbol_def::document (char *h) +symbol_def::document (const char *h) { delete [] help_string; help_string = strsave (h); @@ -139,7 +139,7 @@ next_elem = (symbol_record *) NULL; } -symbol_record::symbol_record (char *n) +symbol_record::symbol_record (const char *n) { nm = strsave (n); formal_param = 0; @@ -150,7 +150,7 @@ next_elem = (symbol_record *) NULL; } -symbol_record::symbol_record (char *n, symbol_record *nxt) +symbol_record::symbol_record (const char *n, symbol_record *nxt) { nm = strsave (n); formal_param = 0; @@ -173,13 +173,13 @@ } char * -symbol_record::name (void) +symbol_record::name (void) const { return nm; } char * -symbol_record::help (void) +symbol_record::help (void) const { if (var != (symbol_def *) NULL) return var->help (); @@ -190,7 +190,7 @@ } tree * -symbol_record::def (void) +symbol_record::def (void) const { if (var != (symbol_def *) NULL) return var->def (); @@ -201,19 +201,19 @@ } int -symbol_record::is_function (void) +symbol_record::is_function (void) const { return (var == (symbol_def *) NULL && fcn != (symbol_def *) NULL); } int -symbol_record::is_variable (void) +symbol_record::is_variable (void) const { return (var != (symbol_def *) NULL); } int -symbol_record::is_defined (void) +symbol_record::is_defined (void) const { return (var != (symbol_def *) NULL || fcn != (symbol_def *) NULL); } @@ -356,7 +356,7 @@ } void -symbol_record::document (char *h) +symbol_record::document (const char *h) { if (var != (symbol_def *) NULL) var->document (h); @@ -487,7 +487,7 @@ } int -symbol_record::is_formal_parameter (void) +symbol_record::is_formal_parameter (void) const { return formal_param; } @@ -499,7 +499,7 @@ } int -symbol_record::is_forced_global (void) +symbol_record::is_forced_global (void) const { return forced_global; } @@ -534,7 +534,7 @@ } symbol_record * -symbol_record::next (void) +symbol_record::next (void) const { return next_elem; } @@ -548,7 +548,7 @@ } symbol_record * -symbol_table::lookup (char *nm, int insert = 0, int warn = 0) +symbol_table::lookup (const char *nm, int insert = 0, int warn = 0) { int index = hash (nm) & HASH_MASK; @@ -605,7 +605,7 @@ } int -symbol_table::clear (char *nm) +symbol_table::clear (const char *nm) { int index = hash (nm) & HASH_MASK; @@ -691,7 +691,7 @@ } int -symbol_table::save (ostream& os, char *name, int mark_as_global = 0) +symbol_table::save (ostream& os, const char *name, int mark_as_global = 0) { int status = 0; symbol_record *sr = lookup (name, 0, 0); @@ -701,7 +701,7 @@ } int -symbol_table::size (void) +symbol_table::size (void) const { int count = 0; for (int i = 0; i < HASH_TABLE_SIZE; i++) @@ -717,28 +717,28 @@ } char ** -symbol_table::list (void) +symbol_table::list (void) const { int count; return list (count); } char ** -symbol_table::var_list (void) +symbol_table::var_list (void) const { int count; return var_list (count); } char ** -symbol_table::fcn_list (void) +symbol_table::fcn_list (void) const { int count; return fcn_list (count); } char ** -symbol_table::list (int& count) +symbol_table::list (int& count) const { count = 0; int n = size (); @@ -761,7 +761,7 @@ } char ** -symbol_table::var_list (int& count) +symbol_table::var_list (int& count) const { count = 0; int n = size (); @@ -785,7 +785,7 @@ } char ** -symbol_table::fcn_list (int& count) +symbol_table::fcn_list (int& count) const { count = 0; int n = size (); @@ -815,28 +815,28 @@ } char ** -symbol_table::sorted_list (void) +symbol_table::sorted_list (void) const { int count = 0; return sorted_list (count); } char ** -symbol_table::sorted_var_list (void) +symbol_table::sorted_var_list (void) const { int count = 0; return sorted_var_list (count); } char ** -symbol_table::sorted_fcn_list (void) +symbol_table::sorted_fcn_list (void) const { int count = 0; return sorted_fcn_list (count); } char ** -symbol_table::sorted_list (int& count) +symbol_table::sorted_list (int& count) const { char **symbols = list (count); if (symbols != (char **) NULL) @@ -846,7 +846,7 @@ } char ** -symbol_table::sorted_var_list (int& count) +symbol_table::sorted_var_list (int& count) const { char **symbols = var_list (count); if (symbols != (char **) NULL) @@ -856,7 +856,7 @@ } char ** -symbol_table::sorted_fcn_list (int& count) +symbol_table::sorted_fcn_list (int& count) const { char **symbols = fcn_list (count); if (symbols != (char **) NULL)
--- a/src/symtab.h +++ b/src/symtab.h @@ -92,9 +92,9 @@ void define (tree_builtin *t); void define (tree_function *t); - tree *def (void); - char *help (void); - void document (char *h); + tree *def (void) const; + char *help (void) const; + void document (const char *h); int save (ostream& os, int mark_as_global); @@ -122,19 +122,19 @@ public: symbol_record (void); - symbol_record (char *n); - symbol_record (char *n, symbol_record *nxt); + symbol_record (const char *n); + symbol_record (const char *n, symbol_record *nxt); ~symbol_record (void); - char *name (void); - char *help (void); - tree *def (void); + char *name (void) const; + char *help (void) const; + tree *def (void) const; - int is_function (void); - int is_variable (void); + int is_function (void) const; + int is_variable (void) const; - int is_defined (void); + int is_defined (void) const; void set_sv_function (sv_Function f); @@ -146,7 +146,7 @@ int define (tree_function *t); int define_as_fcn (tree_constant *t); - void document (char *h); + void document (const char *h); void protect (void); void unprotect (void); @@ -159,14 +159,14 @@ void undefine (void); void mark_as_formal_parameter (void); - int is_formal_parameter (void); + int is_formal_parameter (void) const; void mark_as_forced_global (void); - int is_forced_global (void); + int is_forced_global (void) const; void alias (symbol_record *s, int force = 0); - symbol_record *next (void); + symbol_record *next (void) const; private: @@ -192,34 +192,34 @@ symbol_table (void); - symbol_record *lookup (char *nm, int insert = 0, int warn = 0); + symbol_record *lookup (const char *nm, int insert = 0, int warn = 0); void clear (void); - int clear (char *nm); + int clear (const char *nm); void undefine (void); void bind_globals (void); int save (ostream& os, int mark_as_global = 0); - int save (ostream& os, char *name, int mark_as_global = 0); + int save (ostream& os, const char *name, int mark_as_global = 0); - int size (void); + int size (void) const; - char **list (void); - char **var_list (void); - char **fcn_list (void); + char **list (void) const; + char **var_list (void) const; + char **fcn_list (void) const; - char **list (int& count); - char **var_list (int& count); - char **fcn_list (int& count); + char **list (int& count) const; + char **var_list (int& count) const; + char **fcn_list (int& count) const; - char **sorted_list (void); - char **sorted_var_list (void); - char **sorted_fcn_list (void); + char **sorted_list (void) const; + char **sorted_var_list (void) const; + char **sorted_fcn_list (void) const; - char **sorted_list (int& count); - char **sorted_var_list (int& count); - char **sorted_fcn_list (int& count); + char **sorted_list (int& count) const; + char **sorted_var_list (int& count) const; + char **sorted_fcn_list (int& count) const; private:
--- a/src/tc-assign.cc +++ b/src/tc-assign.cc @@ -25,11 +25,12 @@ #pragma implementation #endif +#include "idx-vector.h" #include "user-prefs.h" -#include "error.h" +#include "tree-const.h" +#include "utils.h" #include "gripes.h" -#include "utils.h" -#include "tree-const.h" +#include "error.h" #include "tc-inlines.cc" @@ -372,7 +373,7 @@ void tree_constant_rep::check_vector_assign (int rhs_nr, int rhs_nc, - int ilen, char *rm) + int ilen, const char *rm) { int nr = rows (); int nc = columns (); @@ -437,6 +438,8 @@ int ilen = iv.capacity (); check_vector_assign (rhs_nr, rhs_nc, ilen, "matrix"); + if (error_state) + return; force_orient f_orient = no_orient; if (rhs_nr == 1 && rhs_nc != 1) @@ -472,6 +475,8 @@ int ilen = ri.nelem (); check_vector_assign (rhs_nr, rhs_nc, ilen, "range"); + if (error_state) + return; force_orient f_orient = no_orient; if (rhs_nr == 1 && rhs_nc != 1)
--- a/src/tc-extras.cc +++ b/src/tc-extras.cc @@ -89,7 +89,8 @@ } static void -get_dimensions (tree_constant& a, char *warn_for, int& nr, int& nc) +get_dimensions (const tree_constant& a, const char *warn_for, + int& nr, int& nc) { tree_constant tmpa = a.make_numeric (); @@ -108,8 +109,8 @@ } static void -get_dimensions (tree_constant& a, tree_constant& b, char *warn_for, - int& nr, int& nc) +get_dimensions (const tree_constant& a, const tree_constant& b, + const char *warn_for, int& nr, int& nc) { tree_constant tmpa = a.make_numeric (); tree_constant tmpb = b.make_numeric (); @@ -126,7 +127,7 @@ } tree_constant -fill_matrix (tree_constant& a, double val, char *warn_for) +fill_matrix (const tree_constant& a, double val, const char *warn_for) { int nr, nc; get_dimensions (a, warn_for, nr, nc); @@ -140,7 +141,8 @@ } tree_constant -fill_matrix (tree_constant& a, tree_constant& b, double val, char *warn_for) +fill_matrix (const tree_constant& a, const tree_constant& b, + double val, const char *warn_for) { int nr, nc; get_dimensions (a, b, warn_for, nr, nc); // May set error_state. @@ -154,7 +156,7 @@ } tree_constant -identity_matrix (tree_constant& a) +identity_matrix (const tree_constant& a) { int nr, nc; get_dimensions (a, "eye", nr, nc); // May set error_state. @@ -175,7 +177,7 @@ } tree_constant -identity_matrix (tree_constant& a, tree_constant& b) +identity_matrix (const tree_constant& a, const tree_constant& b) { int nr, nc; get_dimensions (a, b, "eye", nr, nc); // May set error_state. @@ -289,7 +291,7 @@ } tree_constant -find_nonzero_elem_idx (tree_constant& a) +find_nonzero_elem_idx (const tree_constant& a) { tree_constant retval; @@ -339,7 +341,7 @@ // one... tree_constant * -matrix_log (tree_constant& a) +matrix_log (const tree_constant& a) { tree_constant *retval = new tree_constant [2]; @@ -450,7 +452,7 @@ } tree_constant * -matrix_sqrt (tree_constant& a) +matrix_sqrt (const tree_constant& a) { tree_constant *retval = new tree_constant [2]; @@ -561,7 +563,7 @@ } tree_constant * -column_max (tree_constant *args, int nargin, int nargout) +column_max (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -634,7 +636,7 @@ } tree_constant * -column_min (tree_constant *args, int nargin, int nargout) +column_min (const tree_constant *args, int nargin, int nargout) { tree_constant *retval = NULL_TREE_CONST; @@ -841,7 +843,7 @@ } tree_constant * -sort (tree_constant *args, int nargin, int nargout) +sort (const tree_constant *args, int nargin, int nargout) { // Assumes that we have been given the correct number of arguments. @@ -936,7 +938,7 @@ } tree_constant * -feval (tree_constant *args, int nargin, int nargout) +feval (const tree_constant *args, int nargin, int nargout) { // Assumes that we have been given the correct number of arguments. @@ -957,7 +959,7 @@ } tree_constant -eval_string (char *string, int print, int ans_assign, +eval_string (const char *string, int print, int ans_assign, int& parse_status) { begin_unwind_frame ("eval_string"); @@ -1004,7 +1006,7 @@ } tree_constant -eval_string (tree_constant& arg, int& parse_status) +eval_string (const tree_constant& arg, int& parse_status) { if (! arg.is_string_type ()) { @@ -1020,13 +1022,13 @@ } static int -match_sans_spaces (char *standard, char *test) +match_sans_spaces (const char *standard, const char *test) { - char *tp = test; + const char *tp = test; while (*tp == ' ' || *tp == '\t') tp++; - char *ep = test + strlen (test) - 1; + const char *ep = test + strlen (test) - 1; while (*ep == ' ' || *ep == '\t') ep--; @@ -1036,7 +1038,8 @@ } tree_constant -get_user_input (tree_constant *args, int nargin, int nargout, int debug = 0) +get_user_input (const tree_constant *args, int nargin, int nargout, + int debug = 0) { tree_constant retval;
--- a/src/tc-index.cc +++ b/src/tc-index.cc @@ -25,16 +25,17 @@ #pragma implementation #endif +#include "idx-vector.h" #include "user-prefs.h" -#include "error.h" +#include "tree-const.h" +#include "utils.h" #include "gripes.h" -#include "utils.h" -#include "tree-const.h" +#include "error.h" #include "tc-inlines.cc" int -tree_constant_rep::valid_as_scalar_index (void) +tree_constant_rep::valid_as_scalar_index (void) const { int valid = type_tag == magic_colon || (type_tag == scalar_constant && NINT (scalar) == 1) @@ -45,7 +46,8 @@ } tree_constant -tree_constant_rep::do_scalar_index (tree_constant *args, int nargs) +tree_constant_rep::do_scalar_index (const tree_constant *args, + int nargs) const { if (valid_scalar_indices (args, nargs)) { @@ -141,7 +143,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (tree_constant *args, int nargin) +tree_constant_rep::do_matrix_index (const tree_constant *args, + int nargin) const { tree_constant retval; @@ -174,7 +177,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (tree_constant& i_arg) +tree_constant_rep::do_matrix_index (const tree_constant& i_arg) const { tree_constant retval; @@ -192,7 +195,8 @@ } tree_constant -tree_constant_rep::fortran_style_matrix_index (tree_constant& i_arg) +tree_constant_rep::fortran_style_matrix_index + (const tree_constant& i_arg) const { tree_constant retval; @@ -252,7 +256,7 @@ } tree_constant -tree_constant_rep::fortran_style_matrix_index (Matrix& mi) +tree_constant_rep::fortran_style_matrix_index (const Matrix& mi) const { assert (is_matrix_type ()); @@ -337,7 +341,7 @@ } tree_constant -tree_constant_rep::do_vector_index (tree_constant& i_arg) +tree_constant_rep::do_vector_index (const tree_constant& i_arg) const { tree_constant retval; @@ -452,7 +456,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (tree_constant& i_arg, tree_constant& j_arg) +tree_constant_rep::do_matrix_index (const tree_constant& i_arg, + const tree_constant& j_arg) const { tree_constant retval; @@ -516,7 +521,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (int i, tree_constant& j_arg) +tree_constant_rep::do_matrix_index (int i, const tree_constant& j_arg) const { tree_constant retval; @@ -593,7 +598,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (idx_vector& iv, tree_constant& j_arg) +tree_constant_rep::do_matrix_index (const idx_vector& iv, + const tree_constant& j_arg) const { tree_constant retval; @@ -670,7 +676,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (Range& ri, int imax, tree_constant& j_arg) +tree_constant_rep::do_matrix_index (const Range& ri, int imax, + const tree_constant& j_arg) const { tree_constant retval; @@ -746,7 +753,7 @@ tree_constant tree_constant_rep::do_matrix_index (tree_constant_rep::constant_type mci, - tree_constant& j_arg) + const tree_constant& j_arg) const { tree_constant retval; @@ -821,7 +828,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (int i, int j) +tree_constant_rep::do_matrix_index (int i, int j) const { tree_constant retval; @@ -834,7 +841,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (int i, idx_vector& jv) +tree_constant_rep::do_matrix_index (int i, const idx_vector& jv) const { tree_constant retval; @@ -853,7 +860,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (int i, Range& rj) +tree_constant_rep::do_matrix_index (int i, const Range& rj) const { tree_constant retval; @@ -876,8 +883,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (int i, - tree_constant_rep::constant_type mcj) +tree_constant_rep::do_matrix_index + (int i, tree_constant_rep::constant_type mcj) const { assert (mcj == magic_colon); @@ -898,7 +905,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (idx_vector& iv, int j) +tree_constant_rep::do_matrix_index (const idx_vector& iv, int j) const { tree_constant retval; @@ -918,7 +925,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (idx_vector& iv, idx_vector& jv) +tree_constant_rep::do_matrix_index (const idx_vector& iv, + const idx_vector& jv) const { tree_constant retval; @@ -943,7 +951,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (idx_vector& iv, Range& rj) +tree_constant_rep::do_matrix_index (const idx_vector& iv, + const Range& rj) const { tree_constant retval; @@ -972,8 +981,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (idx_vector& iv, - tree_constant_rep::constant_type mcj) +tree_constant_rep::do_matrix_index + (const idx_vector& iv, tree_constant_rep::constant_type mcj) const { assert (mcj == magic_colon); @@ -999,7 +1008,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (Range& ri, int j) +tree_constant_rep::do_matrix_index (const Range& ri, int j) const { tree_constant retval; @@ -1022,7 +1031,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (Range& ri, idx_vector& jv) +tree_constant_rep::do_matrix_index (const Range& ri, + const idx_vector& jv) const { tree_constant retval; @@ -1050,7 +1060,7 @@ } tree_constant -tree_constant_rep::do_matrix_index (Range& ri, Range& rj) +tree_constant_rep::do_matrix_index (const Range& ri, const Range& rj) const { tree_constant retval; @@ -1083,8 +1093,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (Range& ri, - tree_constant_rep::constant_type mcj) +tree_constant_rep::do_matrix_index + (const Range& ri, tree_constant_rep::constant_type mcj) const { assert (mcj == magic_colon); @@ -1116,7 +1126,7 @@ tree_constant tree_constant_rep::do_matrix_index (tree_constant_rep::constant_type mci, - int j) + int j) const { assert (mci == magic_colon); @@ -1138,7 +1148,7 @@ tree_constant tree_constant_rep::do_matrix_index (tree_constant_rep::constant_type mci, - idx_vector& jv) + const idx_vector& jv) const { assert (mci == magic_colon); @@ -1165,7 +1175,7 @@ tree_constant tree_constant_rep::do_matrix_index (tree_constant_rep::constant_type mci, - Range& rj) + const Range& rj) const { assert (mci == magic_colon); @@ -1196,7 +1206,7 @@ tree_constant tree_constant_rep::do_matrix_index (tree_constant_rep::constant_type mci, - tree_constant_rep::constant_type mcj) + tree_constant_rep::constant_type mcj) const { assert (mci == magic_colon && mcj == magic_colon); @@ -1204,7 +1214,8 @@ } tree_constant -tree_constant_rep::do_matrix_index (tree_constant_rep::constant_type mci) +tree_constant_rep::do_matrix_index + (tree_constant_rep::constant_type mci) const { assert (mci == magic_colon);
--- a/src/tc-inlines.h +++ b/src/tc-inlines.h @@ -143,7 +143,7 @@ } static inline int -valid_scalar_indices (tree_constant *args, int nargs) +valid_scalar_indices (const tree_constant *args, int nargs) { int valid = args != NULL_TREE_CONST && ((nargs == 3 && args[2].valid_as_scalar_index ()
--- a/src/tree.h.old +++ b/src/tree.h.old @@ -46,7 +46,7 @@ #define TREE_FCN_TYPEDEFS 1 typedef tree_constant (*Text_fcn)(int, char **); -typedef tree_constant* (*General_fcn)(tree_constant *, int, int); +typedef tree_constant* (*General_fcn)(const tree_constant *, int, int); #endif @@ -140,7 +140,7 @@ ~tree_builtin (void); - int is_builtin (void); + int is_builtin (void) const; tree_constant eval (int print); @@ -148,7 +148,8 @@ tree_constant eval (int argc, char **argv, int print); - tree_constant *eval (tree_constant *args, int n_in, int n_out, int print); + tree_constant *eval (const tree_constant *args, int n_in, int n_out, + int print); tree *def (void); char *name (void); @@ -180,7 +181,7 @@ ~tree_identifier (void); - int is_identifier (void); + int is_identifier (void) const; tree *def (void); char *name (void); @@ -210,7 +211,8 @@ tree_constant eval (int argc, char **argv, int print); - tree_constant *eval (tree_constant *args, int n_in, int n_out, int print); + tree_constant *eval (const tree_constant *args, int n_in, int n_out, + int print); void eval_undefined_error (void); @@ -249,7 +251,8 @@ tree_constant eval (int argc, char **argv, int print); - tree_constant *eval (tree_constant *args, int n_in, int n_out, int print); + tree_constant *eval (const tree_constant *args, int n_in, int n_out, + int print); int max_expected_args (void); @@ -383,7 +386,7 @@ tree_constant eval (int print); - int is_assignment_expression (void); + int is_assignment_expression (void) const; }; /* @@ -473,7 +476,7 @@ ~tree_index_expression (void); - int is_index_expression (void); + int is_index_expression (void) const; tree_identifier *ident (void);
--- a/src/unwind-prot.h +++ b/src/unwind-prot.h @@ -28,8 +28,6 @@ #pragma interface #endif -#include <stddef.h> - typedef void (*cleanup_func)(void *ptr); void add_unwind_protect (cleanup_func fptr, void *ptr);
--- a/src/utils.cc +++ b/src/utils.cc @@ -183,7 +183,7 @@ } void -check_dimensions (int& nr, int& nc, char *warnfor) +check_dimensions (int& nr, int& nc, const char *warnfor) { if (nr < 0 || nc < 0) { @@ -456,7 +456,7 @@ * See if the given file is in the path. */ char * -file_in_path (char *name, char *suffix) +file_in_path (const char *name, const char *suffix) { char *nm = strconcat ("/", name); char *tmp = nm; @@ -500,7 +500,7 @@ * to the file. */ char * -m_file_in_path (char *name) +m_file_in_path (const char *name) { return file_in_path (name, ".m"); } @@ -529,7 +529,7 @@ * Return 1 if STRING contains an absolute pathname, else 0. */ int -absolute_pathname (char *string) +absolute_pathname (const char *string) { if (!string || !*string) return 0; @@ -555,7 +555,7 @@ * look up through $PATH. */ int -absolute_program (char *string) +absolute_program (const char *string) { return (strchr (string, '/') != (char *)NULL); } @@ -583,7 +583,7 @@ * the string contained a bad number. */ int -read_octal (char *string) +read_octal (const char *string) { int result = 0; int digits = 0; @@ -646,7 +646,7 @@ * \\ a backslash */ char * -decode_prompt_string (char *string) +decode_prompt_string (const char *string) { int result_size = PROMPT_GROWTH; int result_index = 0; @@ -849,7 +849,7 @@ /* * Remove the last N directories from PATH. Do not PATH blank. - * PATH must contain enoung space for MAXPATHLEN characters. + * PATH must contain enough space for MAXPATHLEN characters. */ void pathname_backup (char *path, int n) @@ -880,7 +880,7 @@ * begin with. */ char * -make_absolute (char *string, char *dot_path) +make_absolute (const char *string, const char *dot_path) { static char current_path[MAXPATHLEN]; register char *cp; @@ -942,7 +942,7 @@ * FOR_WHOM is the name of the caller for error printing. */ char * -get_working_directory (char *for_whom) +get_working_directory (const char *for_whom) { if (!follow_symbolic_links) { @@ -975,7 +975,7 @@ * link following, etc. */ int -change_to_directory (char *newdir) +change_to_directory (const char *newdir) { char *t; @@ -1031,7 +1031,7 @@ * stat on a fails returns -1 */ int -is_newer (char *fa, time_t t) +is_newer (const char *fa, time_t t) { struct stat fa_sb; register int fa_stat; @@ -1188,7 +1188,7 @@ } int -almost_match (char *std, char *s, int min_match_len = 1) +almost_match (const char *std, const char *s, int min_match_len = 1) { int stdlen = strlen (std); int slen = strlen (s); @@ -1199,7 +1199,7 @@ } char ** -get_m_file_names (int& num, char *dir, int no_suffix) +get_m_file_names (int& num, const char *dir, int no_suffix) { static int num_max = 256; char **retval = new char * [num_max];
--- a/src/utils.h +++ b/src/utils.h @@ -37,37 +37,38 @@ extern char *strsave (const char *); extern char *strconcat (const char *, const char *); extern void discard_until (istream&, char); -extern void check_dimensions (int& nr, int& nc, char *warnfor); +extern void check_dimensions (int& nr, int& nc, const char *warnfor); extern void raw_mode (int); extern int kbhit (void); extern char **pathstring_to_vector (char *); extern char *default_path (void); extern char *get_site_defaults (void); extern char *default_pager (void); -extern char *file_in_path (char *, char *); -extern char *m_file_in_path (char *); -extern char *polite_directory_format (char *); -extern int absolute_pathname (char *); -extern int absolute_program (char *); +extern char *file_in_path (const char *, const char *); +extern char *m_file_in_path (const char *); +extern char *polite_directory_format (const char *); +extern int absolute_pathname (const char *); +extern int absolute_program (const char *); extern char *base_pathname (char *); -extern int read_octal (char *); +extern int read_octal (const char *); extern char *sub_append_string (char *, char *, int *, int *); -extern char *decode_prompt_string (char *); +extern char *decode_prompt_string (const char *); extern void pathname_backup (char *, int); -extern char *make_absolute (char *, char *); -extern char *get_working_directory (char *); -extern int change_to_directory (char *); -extern int is_newer (char *, time_t); +extern char *make_absolute (const char *, const char *); +extern char *get_working_directory (const char *); +extern int change_to_directory (const char *); +extern int is_newer (const char *, time_t); extern void volatile jump_to_top_level (void); extern char *s_plural (int); extern char *es_plural (int); -extern char *save_in_tmp_file (tree_constant& t, int nd = 2, int para = 0); +extern char *save_in_tmp_file (tree_constant& t, int nd = 2, int para = 0); extern void mark_for_deletion (const char *); extern void cleanup_tmp_files (void); extern int send_to_plot_stream (const char *cmd); extern void close_plot_stream (void); -extern int almost_match (char *std, char *s, int min_match_len = 1); -extern char **get_m_file_names (int& mfl_len, char *dir, int no_suffix); +extern int almost_match (const char *std, const char *s, + int min_match_len = 1); +extern char **get_m_file_names (int& mfl_len, const char *dir, int no_suffix); extern char **get_m_file_names (int& mfl_len, int no_suffix); extern int NINT (double x); extern double D_NINT (double x);
--- a/src/variables.cc +++ b/src/variables.cc @@ -39,6 +39,7 @@ #include "error.h" #include "utils.h" #include "tree.h" +#include "help.h" // Symbol table for symbols at the top level. symbol_table *top_level_sym_tab;
--- a/src/xdiv.cc +++ b/src/xdiv.cc @@ -26,8 +26,12 @@ #endif #include <assert.h> +#include <Complex.h> + +#include "xdiv.h" +#include "Matrix.h" +#include "tree-const.h" #include "error.h" -#include "xdiv.h" static inline int result_ok (int info, double rcond, int warn = 1) @@ -80,7 +84,7 @@ /* 1 */ tree_constant -xdiv (Matrix& a, Matrix& b) +xdiv (const Matrix& a, const Matrix& b) { if (! mx_div_conform (b.rows (), b.columns (), a.columns ())) return tree_constant (); @@ -105,7 +109,7 @@ /* 2 */ tree_constant -xdiv (Matrix& a, ComplexMatrix& b) +xdiv (const Matrix& a, const ComplexMatrix& b) { if (! mx_div_conform (b.rows (), b.columns (), a.columns ())) return tree_constant (); @@ -130,7 +134,7 @@ /* 3 */ tree_constant -xdiv (ComplexMatrix& a, Matrix& b) +xdiv (const ComplexMatrix& a, const Matrix& b) { if (! mx_div_conform (b.rows (), b.columns (), a.columns ())) return tree_constant (); @@ -155,7 +159,7 @@ /* 4 */ tree_constant -xdiv (ComplexMatrix& a, ComplexMatrix& b) +xdiv (const ComplexMatrix& a, const ComplexMatrix& b) { if (! mx_div_conform (b.rows (), b.columns (), a.columns ())) return tree_constant (); @@ -190,7 +194,7 @@ */ tree_constant -x_el_div (double a, Matrix& b) +x_el_div (double a, const Matrix& b) { int nr = b.rows (); int nc = b.columns (); @@ -205,7 +209,7 @@ } tree_constant -x_el_div (double a, ComplexMatrix& b) +x_el_div (double a, const ComplexMatrix& b) { int nr = b.rows (); int nc = b.columns (); @@ -220,7 +224,7 @@ } tree_constant -x_el_div (Complex a, Matrix& b) +x_el_div (const Complex a, const Matrix& b) { int nr = b.rows (); int nc = b.columns (); @@ -235,7 +239,7 @@ } tree_constant -x_el_div (Complex a, ComplexMatrix& b) +x_el_div (const Complex a, const ComplexMatrix& b) { int nr = b.rows (); int nc = b.columns (); @@ -262,7 +266,7 @@ /* 1 */ tree_constant -xleftdiv (Matrix& a, Matrix& b) +xleftdiv (const Matrix& a, const Matrix& b) { if (! mx_leftdiv_conform (a.rows (), a.columns (), b.rows ())) return tree_constant (); @@ -284,7 +288,7 @@ /* 2 */ tree_constant -xleftdiv (Matrix& a, ComplexMatrix& b) +xleftdiv (const Matrix& a, const ComplexMatrix& b) { if (! mx_leftdiv_conform (a.rows (), a.columns (), b.rows ())) return tree_constant (); @@ -306,7 +310,7 @@ /* 3 */ tree_constant -xleftdiv (ComplexMatrix& a, Matrix& b) +xleftdiv (const ComplexMatrix& a, const Matrix& b) { if (! mx_leftdiv_conform (a.rows (), a.columns (), b.rows ())) return tree_constant (); @@ -328,7 +332,7 @@ /* 4 */ tree_constant -xleftdiv (ComplexMatrix& a, ComplexMatrix& b) +xleftdiv (const ComplexMatrix& a, const ComplexMatrix& b) { if (! mx_leftdiv_conform (a.rows (), a.columns (), b.rows ())) return tree_constant ();
--- a/src/xdiv.h +++ b/src/xdiv.h @@ -28,26 +28,25 @@ #pragma interface #endif -#include <Complex.h> +class Complex; +class Matrix; +class ComplexMatrix; +class tree_constant; -#include "Matrix.h" - -#include "tree-const.h" +extern tree_constant xdiv (const Matrix& a, const Matrix& b); +extern tree_constant xdiv (const Matrix& a, const ComplexMatrix& b); +extern tree_constant xdiv (const ComplexMatrix& a, const Matrix& b); +extern tree_constant xdiv (const ComplexMatrix& a, const ComplexMatrix& b); -extern tree_constant xdiv (Matrix& a, Matrix& b); -extern tree_constant xdiv (Matrix& a, ComplexMatrix& b); -extern tree_constant xdiv (ComplexMatrix& a, Matrix& b); -extern tree_constant xdiv (ComplexMatrix& a, ComplexMatrix& b); +extern tree_constant x_el_div (double a, const Matrix& b); +extern tree_constant x_el_div (double a, const ComplexMatrix& b); +extern tree_constant x_el_div (const Complex a, const Matrix& b); +extern tree_constant x_el_div (const Complex a, const ComplexMatrix& b); -extern tree_constant x_el_div (double a, Matrix& b); -extern tree_constant x_el_div (double a, ComplexMatrix& b); -extern tree_constant x_el_div (Complex a, Matrix& b); -extern tree_constant x_el_div (Complex a, ComplexMatrix& b); - -extern tree_constant xleftdiv (Matrix& a, Matrix& b); -extern tree_constant xleftdiv (Matrix& a, ComplexMatrix& b); -extern tree_constant xleftdiv (ComplexMatrix& a, Matrix& b); -extern tree_constant xleftdiv (ComplexMatrix& a, ComplexMatrix& b); +extern tree_constant xleftdiv (const Matrix& a, const Matrix& b); +extern tree_constant xleftdiv (const Matrix& a, const ComplexMatrix& b); +extern tree_constant xleftdiv (const ComplexMatrix& a, const Matrix& b); +extern tree_constant xleftdiv (const ComplexMatrix& a, const ComplexMatrix& b); #endif
--- a/src/xpow.cc +++ b/src/xpow.cc @@ -26,8 +26,12 @@ #endif #include <assert.h> +#include <Complex.h> + +#include "xpow.h" +#include "Matrix.h" +#include "tree-const.h" #include "error.h" -#include "xpow.h" // This function also appears in tree-const.cc. Maybe it should be a // member function of the Matrix class. @@ -74,7 +78,7 @@ } tree_constant -xpow (double a, Matrix& b) +xpow (double a, const Matrix& b) { tree_constant retval; @@ -107,7 +111,7 @@ } tree_constant -xpow (double a, Complex& b) +xpow (double a, const Complex& b) { Complex result; Complex atmp (a); @@ -116,7 +120,7 @@ } tree_constant -xpow (double a, ComplexMatrix& b) +xpow (double a, const ComplexMatrix& b) { tree_constant retval; @@ -149,7 +153,7 @@ } tree_constant -xpow (Matrix& a, double b) +xpow (const Matrix& a, double b) { tree_constant retval; @@ -209,7 +213,7 @@ } tree_constant -xpow (Matrix& a, Complex& b) +xpow (const Matrix& a, const Complex& b) { int nr = a.rows (); int nc = a.columns (); @@ -235,7 +239,7 @@ } tree_constant -xpow (Complex& a, double b) +xpow (const Complex& a, double b) { Complex result; result = pow (a, b); @@ -243,7 +247,7 @@ } tree_constant -xpow (Complex& a, Matrix& b) +xpow (const Complex& a, const Matrix& b) { tree_constant retval; @@ -278,7 +282,7 @@ } tree_constant -xpow (Complex& a, Complex& b) +xpow (const Complex& a, const Complex& b) { Complex result; result = pow (a, b); @@ -286,7 +290,7 @@ } tree_constant -xpow (Complex& a, ComplexMatrix& b) +xpow (const Complex& a, const ComplexMatrix& b) { tree_constant retval; @@ -319,7 +323,7 @@ } tree_constant -xpow (ComplexMatrix& a, double b) +xpow (const ComplexMatrix& a, double b) { tree_constant retval; @@ -379,7 +383,7 @@ } tree_constant -xpow (ComplexMatrix& a, Complex& b) +xpow (const ComplexMatrix& a, const Complex& b) { int nr = a.rows (); int nc = a.columns (); @@ -422,7 +426,7 @@ */ tree_constant -elem_xpow (double a, Matrix& b) +elem_xpow (double a, const Matrix& b) { tree_constant retval; @@ -454,7 +458,7 @@ } tree_constant -elem_xpow (double a, ComplexMatrix& b) +elem_xpow (double a, const ComplexMatrix& b) { int nr = b.rows (); int nc = b.columns (); @@ -468,7 +472,7 @@ } tree_constant -elem_xpow (Matrix& a, double b) +elem_xpow (const Matrix& a, double b) { tree_constant retval; @@ -501,7 +505,7 @@ } tree_constant -elem_xpow (Matrix& a, Matrix& b) +elem_xpow (const Matrix& a, const Matrix& b) { int nr = a.rows (); int nc = a.columns (); @@ -550,7 +554,7 @@ } tree_constant -elem_xpow (Matrix& a, Complex& b) +elem_xpow (const Matrix& a, const Complex& b) { int nr = a.rows (); int nc = a.columns (); @@ -564,7 +568,7 @@ } tree_constant -elem_xpow (Matrix& a, ComplexMatrix& b) +elem_xpow (const Matrix& a, const ComplexMatrix& b) { int nr = a.rows (); int nc = a.columns (); @@ -580,7 +584,7 @@ } tree_constant -elem_xpow (Complex& a, Matrix& b) +elem_xpow (const Complex& a, const Matrix& b) { int nr = b.rows (); int nc = b.columns (); @@ -594,7 +598,7 @@ } tree_constant -elem_xpow (Complex& a, ComplexMatrix& b) +elem_xpow (const Complex& a, const ComplexMatrix& b) { int nr = b.rows (); int nc = b.columns (); @@ -608,7 +612,7 @@ } tree_constant -elem_xpow (ComplexMatrix& a, double b) +elem_xpow (const ComplexMatrix& a, double b) { int nr = a.rows (); int nc = a.columns (); @@ -622,7 +626,7 @@ } tree_constant -elem_xpow (ComplexMatrix& a, Matrix& b) +elem_xpow (const ComplexMatrix& a, const Matrix& b) { int nr = a.rows (); int nc = a.columns (); @@ -638,7 +642,7 @@ } tree_constant -elem_xpow (ComplexMatrix& a, Complex& b) +elem_xpow (const ComplexMatrix& a, const Complex& b) { int nr = a.rows (); int nc = a.columns (); @@ -652,7 +656,7 @@ } tree_constant -elem_xpow (ComplexMatrix& a, ComplexMatrix& b) +elem_xpow (const ComplexMatrix& a, const ComplexMatrix& b) { int nr = a.rows (); int nc = a.columns ();
--- a/src/xpow.h +++ b/src/xpow.h @@ -28,43 +28,43 @@ #pragma interface #endif -#include <Complex.h> - -#include "Matrix.h" - -#include "tree-const.h" +class Complex; +class Matrix; +class ComplexMatrix; +class tree_constant; extern tree_constant xpow (double a, double b); -extern tree_constant xpow (double a, Matrix& b); -extern tree_constant xpow (double a, Complex& b); -extern tree_constant xpow (double a, ComplexMatrix& b); +extern tree_constant xpow (double a, const Matrix& b); +extern tree_constant xpow (double a, const Complex& b); +extern tree_constant xpow (double a, const ComplexMatrix& b); -extern tree_constant xpow (Matrix& a, double b); -extern tree_constant xpow (Matrix& a, Complex& b); +extern tree_constant xpow (const Matrix& a, double b); +extern tree_constant xpow (const Matrix& a, const Complex& b); -extern tree_constant xpow (Complex& a, double b); -extern tree_constant xpow (Complex& a, Matrix& b); -extern tree_constant xpow (Complex& a, Complex& b); -extern tree_constant xpow (Complex& a, ComplexMatrix& b); +extern tree_constant xpow (const Complex& a, double b); +extern tree_constant xpow (const Complex& a, const Matrix& b); +extern tree_constant xpow (const Complex& a, const Complex& b); +extern tree_constant xpow (const Complex& a, const ComplexMatrix& b); -extern tree_constant xpow (ComplexMatrix& a, double b); -extern tree_constant xpow (ComplexMatrix& a, Complex& b); +extern tree_constant xpow (const ComplexMatrix& a, double b); +extern tree_constant xpow (const ComplexMatrix& a, const Complex& b); -extern tree_constant elem_xpow (double a, Matrix& b); -extern tree_constant elem_xpow (double a, ComplexMatrix& b); +extern tree_constant elem_xpow (double a, const Matrix& b); +extern tree_constant elem_xpow (double a, const ComplexMatrix& b); -extern tree_constant elem_xpow (Matrix& a, double b); -extern tree_constant elem_xpow (Matrix& a, Matrix& b); -extern tree_constant elem_xpow (Matrix& a, Complex& b); -extern tree_constant elem_xpow (Matrix& a, ComplexMatrix& b); +extern tree_constant elem_xpow (const Matrix& a, double b); +extern tree_constant elem_xpow (const Matrix& a, const Matrix& b); +extern tree_constant elem_xpow (const Matrix& a, const Complex& b); +extern tree_constant elem_xpow (const Matrix& a, const ComplexMatrix& b); -extern tree_constant elem_xpow (Complex& a, Matrix& b); -extern tree_constant elem_xpow (Complex& a, ComplexMatrix& b); +extern tree_constant elem_xpow (const Complex& a, const Matrix& b); +extern tree_constant elem_xpow (const Complex& a, const ComplexMatrix& b); -extern tree_constant elem_xpow (ComplexMatrix& a, double b); -extern tree_constant elem_xpow (ComplexMatrix& a, Matrix& b); -extern tree_constant elem_xpow (ComplexMatrix& a, Complex& b); -extern tree_constant elem_xpow (ComplexMatrix& a, ComplexMatrix& b); +extern tree_constant elem_xpow (const ComplexMatrix& a, double b); +extern tree_constant elem_xpow (const ComplexMatrix& a, const Matrix& b); +extern tree_constant elem_xpow (const ComplexMatrix& a, const Complex& b); +extern tree_constant elem_xpow (const ComplexMatrix& a, + const ComplexMatrix& b); #endif