Mercurial > hg > octave-terminal
changeset 2267:4028b7c79927
[project @ 1996-05-24 00:39:30 by jwe]
author | jwe |
---|---|
date | Fri, 24 May 1996 00:41:42 +0000 |
parents | 68c75296c582 |
children | ee5ec3133ed3 |
files | src/mappers.cc src/pt-fvc.cc src/strfns.cc |
diffstat | 3 files changed, 74 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mappers.cc +++ b/src/mappers.cc @@ -408,6 +408,24 @@ return isxdigit (c); } +int +xtoascii (int c) +{ + return toascii (c); +} + +int +xtolower (int c) +{ + return tolower (c); +} + +int +xtoupper (int c) +{ + return toupper (c); +} + void install_mapper_functions (void) { @@ -549,6 +567,15 @@ DEFUN_MAPPER (tanh, 0, tanh, 0, tanh, 0.0, 0.0, 0, "tanh (X): compute tanh (X) for each element of X"); + DEFUN_MAPPER (toascii, xtoascii, 0, 0, 0, 0.0, 0.0, 1, + "toascii (STRING): return ASCII representation of STRING in a matrix"); + + DEFUN_MAPPER (tolower, xtolower, 0, 0, 0, 0.0, 0.0, 2, + "tolower (STRING): convert upper case characters to lower case in STRING"); + + DEFUN_MAPPER (toupper, xtoupper, 0, 0, 0, 0.0, 0.0, 2, + "toupper (STRING): convert lower case characters to upper case in STRING"); + DEFALIAS (gammaln, lgamma); }
--- a/src/pt-fvc.cc +++ b/src/pt-fvc.cc @@ -658,17 +658,54 @@ int nr = chm.rows (); int nc = chm.cols (); - Matrix result (nr, nc); + switch (m_fcn.flag) + { + case 0: + { + Matrix result (nr, nc); + + // islapha and friends can return any nonzero value + // to mean true, but we want to return 1 or 0 only. - // islapha and friends can return any nonzero value to - // mean true. + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) + result.elem (i, j) + = (*m_fcn.ch_mapper) (chm.elem (i, j)) ? 1 : 0; + + retval = result; + } + break; + + case 1: + { + Matrix result (nr, nc); - for (int j = 0; j < nc; j++) - for (int i = 0; i < nr; i++) - result.elem (i, j) - = (*m_fcn.ch_mapper) (chm.elem (i, j)) ? 1 : 0; + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) + result.elem (i, j) + = (*m_fcn.ch_mapper) (chm.elem (i, j)); + + retval = result; + } + break; + + case 2: + { + charMatrix result (nr, nc); - retval = result; + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) + result.elem (i, j) + = (*m_fcn.ch_mapper) (chm.elem (i, j)); + + retval = octave_value (result, true); + } + break; + + default: + panic_impossible (); + break; + } } } } @@ -680,7 +717,7 @@ { double d = arg.double_value (); - if (m_fcn.can_return_complex_for_real_arg + if (m_fcn.flag && (d < m_fcn.lower_limit || d > m_fcn.upper_limit)) { if (m_fcn.c_c_mapper) @@ -702,7 +739,7 @@ if (error_state) return retval; - if (m_fcn.can_return_complex_for_real_arg + if (m_fcn.flag && (any_element_less_than (m, m_fcn.lower_limit) || any_element_greater_than (m, m_fcn.upper_limit))) {
--- a/src/strfns.cc +++ b/src/strfns.cc @@ -66,32 +66,6 @@ return retval; } -DEFUN (toascii, args, , - "toascii (STRING): return ASCII representation of STRING in a matrix") -{ - octave_value_list retval; - - int nargin = args.length (); - - if (nargin == 1) - { - octave_value arg = args(0); - - if (arg.is_string ()) - { - charMatrix chm = args(0).all_strings (); - - retval = Matrix (chm); - } - else - gripe_wrong_type_arg ("toascii", arg); - } - else - print_usage ("toascii"); - - return retval; -} - /* ;;; Local Variables: *** ;;; mode: C++ ***