Mercurial > hg > octave-lyh
changeset 760:b284388e8999
[project @ 1994-10-02 16:22:35 by jwe]
author | jwe |
---|---|
date | Sun, 02 Oct 1994 16:22:35 +0000 |
parents | 3fc1ccd5a9db |
children | f0133cd32852 |
files | src/data.cc src/pt-const.h src/tc-rep.cc src/tc-rep.h |
diffstat | 4 files changed, 120 insertions(+), 255 deletions(-) [+] |
line wrap: on
line diff
--- a/src/data.cc +++ b/src/data.cc @@ -221,8 +221,30 @@ int nargin = args.length (); - if (nargin == 1 && args(0).is_defined ()) - retval = args(0).cumprod (); + if (nargin == 1) + { + tree_constant arg = args(0); + + if (arg.is_real_type ()) + { + Matrix tmp = arg.matrix_value (); + + if (! error_state) + retval(0) = tmp.cumprod (); + } + else if (arg.is_complex_type ()) + { + ComplexMatrix tmp = arg.complex_matrix_value (); + + if (! error_state) + retval(0) = tmp.cumprod (); + } + else + { + gripe_wrong_type_arg ("cumprod", arg); + return retval; + } + } else print_usage ("cumprod"); @@ -236,8 +258,30 @@ int nargin = args.length (); - if (nargin == 1 && args(0).is_defined ()) - retval = args(0).cumsum (); + if (nargin == 1) + { + tree_constant arg = args(0); + + if (arg.is_real_type ()) + { + Matrix tmp = arg.matrix_value (); + + if (! error_state) + retval(0) = tmp.cumsum (); + } + else if (arg.is_complex_type ()) + { + ComplexMatrix tmp = arg.complex_matrix_value (); + + if (! error_state) + retval(0) = tmp.cumsum (); + } + else + { + gripe_wrong_type_arg ("cumsum", arg); + return retval; + } + } else print_usage ("cumsum"); @@ -283,8 +327,30 @@ int nargin = args.length (); - if (nargin == 1 && args(0).is_defined ()) - retval = args(0).prod (); + if (nargin == 1) + { + tree_constant arg = args(0); + + if (arg.is_real_type ()) + { + Matrix tmp = arg.matrix_value (); + + if (! error_state) + retval(0) = tmp.prod (); + } + else if (arg.is_complex_type ()) + { + ComplexMatrix tmp = arg.complex_matrix_value (); + + if (! error_state) + retval(0) = tmp.prod (); + } + else + { + gripe_wrong_type_arg ("prod", arg); + return retval; + } + } else print_usage ("prod"); @@ -345,8 +411,30 @@ int nargin = args.length (); - if (nargin == 1 && args(0).is_defined ()) - retval = args(0).sum (); + if (nargin == 1) + { + tree_constant arg = args(0); + + if (arg.is_real_type ()) + { + Matrix tmp = arg.matrix_value (); + + if (! error_state) + retval(0) = tmp.sum (); + } + else if (arg.is_complex_type ()) + { + ComplexMatrix tmp = arg.complex_matrix_value (); + + if (! error_state) + retval(0) = tmp.sum (); + } + else + { + gripe_wrong_type_arg ("sum", arg); + return retval; + } + } else print_usage ("sum"); @@ -360,8 +448,30 @@ int nargin = args.length (); - if (nargin == 1 && args(0).is_defined ()) - retval = args(0).sumsq (); + if (nargin == 1) + { + tree_constant arg = args(0); + + if (arg.is_real_type ()) + { + Matrix tmp = arg.matrix_value (); + + if (! error_state) + retval(0) = tmp.sumsq (); + } + else if (arg.is_complex_type ()) + { + ComplexMatrix tmp = arg.complex_matrix_value (); + + if (! error_state) + retval(0) = tmp.sumsq (); + } + else + { + gripe_wrong_type_arg ("sumsq", arg); + return retval; + } + } else print_usage ("sumsq");
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -363,12 +363,6 @@ // These may not need to be member functions. - 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) const { return rep->diag (); } tree_constant diag (const tree_constant& a) const { return rep->diag (a); }
--- a/src/tc-rep.cc +++ b/src/tc-rep.cc @@ -2124,239 +2124,6 @@ return ans; } -tree_constant -TC_REP::cumprod (void) const -{ - if (type_tag == string_constant || type_tag == range_constant) - { - tree_constant tmp = make_numeric (); - return tmp.cumprod (); - } - - tree_constant retval; - - switch (type_tag) - { - case scalar_constant: - retval = tree_constant (scalar); - break; - - case matrix_constant: - { - Matrix m = matrix->cumprod (); - retval = tree_constant (m); - } - break; - - case complex_scalar_constant: - retval = tree_constant (*complex_scalar); - break; - - case complex_matrix_constant: - { - ComplexMatrix m = complex_matrix->cumprod (); - retval = tree_constant (m); - } - break; - - case string_constant: - case range_constant: - case magic_colon: - default: - panic_impossible (); - break; - } - - return retval; -} - -tree_constant -TC_REP::cumsum (void) const -{ - if (type_tag == string_constant || type_tag == range_constant) - { - tree_constant tmp = make_numeric (); - return tmp.cumsum (); - } - - tree_constant retval; - - switch (type_tag) - { - case scalar_constant: - retval = tree_constant (scalar); - break; - - case matrix_constant: - { - Matrix m = matrix->cumsum (); - retval = tree_constant (m); - } - break; - - case complex_scalar_constant: - retval = tree_constant (*complex_scalar); - break; - - case complex_matrix_constant: - { - ComplexMatrix m = complex_matrix->cumsum (); - retval = tree_constant (m); - } - break; - - case string_constant: - case range_constant: - case magic_colon: - default: - panic_impossible (); - break; - } - - return retval; -} - -tree_constant -TC_REP::prod (void) const -{ - if (type_tag == string_constant || type_tag == range_constant) - { - tree_constant tmp = make_numeric (); - return tmp.prod (); - } - - tree_constant retval; - - switch (type_tag) - { - case scalar_constant: - retval = tree_constant (scalar); - break; - - case matrix_constant: - { - Matrix m = matrix->prod (); - retval = tree_constant (m); - } - break; - - case complex_scalar_constant: - retval = tree_constant (*complex_scalar); - break; - - case complex_matrix_constant: - { - ComplexMatrix m = complex_matrix->prod (); - retval = tree_constant (m); - } - break; - - case string_constant: - case range_constant: - case magic_colon: - default: - panic_impossible (); - break; - } - - return retval; -} - -tree_constant -TC_REP::sum (void) const -{ - if (type_tag == string_constant || type_tag == range_constant) - { - tree_constant tmp = make_numeric (); - return tmp.sum (); - } - - tree_constant retval; - - switch (type_tag) - { - case scalar_constant: - retval = tree_constant (scalar); - break; - - case matrix_constant: - { - Matrix m = matrix->sum (); - retval = tree_constant (m); - } - break; - - case complex_scalar_constant: - retval = tree_constant (*complex_scalar); - break; - - case complex_matrix_constant: - { - ComplexMatrix m = complex_matrix->sum (); - retval = tree_constant (m); - } - break; - - case string_constant: - case range_constant: - case magic_colon: - default: - panic_impossible (); - break; - } - - return retval; -} - -tree_constant -TC_REP::sumsq (void) const -{ - if (type_tag == string_constant || type_tag == range_constant) - { - tree_constant tmp = make_numeric (); - return tmp.sumsq (); - } - - tree_constant retval; - - switch (type_tag) - { - case scalar_constant: - retval = tree_constant (scalar * scalar); - break; - - case matrix_constant: - { - Matrix m = matrix->sumsq (); - retval = tree_constant (m); - } - break; - - case complex_scalar_constant: - { - Complex c (*complex_scalar); - retval = tree_constant (c * c); - } - break; - - case complex_matrix_constant: - { - ComplexMatrix m = complex_matrix->sumsq (); - retval = tree_constant (m); - } - break; - - case string_constant: - case range_constant: - case magic_colon: - default: - panic_impossible (); - break; - } - - return retval; -} - static tree_constant make_diag (const Matrix& v, int k) {
--- a/src/tc-rep.h +++ b/src/tc-rep.h @@ -223,12 +223,6 @@ // These may not need to be member functions. - 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) const; tree_constant diag (const tree_constant& a) const;