# HG changeset patch # User jwe # Date 753101493 0 # Node ID 7947b7a6b6dae3f35d0a3b9fc852023c6552bc38 # Parent 5869adaa6aea0dad8b850d8eb61982c89b46bf4d [project @ 1993-11-12 10:51:10 by jwe] diff -r 5869adaa6aea -r 7947b7a6b6da liboctave/Matrix.cc --- a/liboctave/Matrix.cc Fri Nov 12 10:44:40 1993 +0000 +++ b/liboctave/Matrix.cc Fri Nov 12 10:51:33 1993 +0000 @@ -1822,6 +1822,28 @@ } ColumnVector +Matrix::row_min_loc (void) const +{ + ColumnVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nr); + + for (int i = 0; i < nr; i++) + { + int res = 0; + for (int j = 0; j < nc; j++) + if (elem (i, j) < elem (i, res)) + res = j; + result.elem (i) = (double) (res + 1); + } + } + + return result; +} + +ColumnVector Matrix::row_max (void) const { ColumnVector result; @@ -1843,6 +1865,28 @@ return result; } +ColumnVector +Matrix::row_max_loc (void) const +{ + ColumnVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nr); + + for (int i = 0; i < nr; i++) + { + int res = 0; + for (int j = 0; j < nc; j++) + if (elem (i, j) > elem (i, res)) + res = j; + result.elem (i) = (double) (res + 1); + } + } + + return result; +} + RowVector Matrix::column_min (void) const { @@ -1864,6 +1908,28 @@ return result; } +RowVector +Matrix::column_min_loc (void) const +{ + RowVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nc); + + for (int j = 0; j < nc; j++) + { + int res = 0.0; + for (int i = 0; i < nr; i++) + if (elem (i, j) < elem (res, j)) + res = i; + result.elem (j) = (double) (res + 1); + } + } + + return result; +} + RowVector Matrix::column_max (void) const @@ -1887,6 +1953,28 @@ return result; } +RowVector +Matrix::column_max_loc (void) const +{ + RowVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nc); + + for (int j = 0; j < nc; j++) + { + int res = 0; + for (int i = 0; i < nr; i++) + if (elem (i, j) > elem (res, j)) + res = i; + result.elem (j) = (double) (res + 1); + } + } + + return result; +} + ostream& operator << (ostream& os, const Matrix& a) { @@ -4126,6 +4214,32 @@ } ComplexColumnVector +ComplexMatrix::row_min_loc (void) const +{ + ComplexColumnVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nr); + + for (int i = 0; i < nr; i++) + { + Complex res = 0; + double absres = abs (elem (i, 0)); + for (int j = 0; j < nc; j++) + if (abs (elem (i, j)) < absres) + { + res = j; + absres = abs (elem (i, j)); + } + result.elem (i) = res + 1; + } + } + + return result; +} + +ComplexColumnVector ComplexMatrix::row_max (void) const { ComplexColumnVector result; @@ -4151,6 +4265,32 @@ return result; } +ComplexColumnVector +ComplexMatrix::row_max_loc (void) const +{ + ComplexColumnVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nr); + + for (int i = 0; i < nr; i++) + { + Complex res = 0; + double absres = abs (elem (i, 0)); + for (int j = 0; j < nc; j++) + if (abs (elem (i, j)) > absres) + { + res = j; + absres = abs (elem (i, j)); + } + result.elem (i) = res + 1; + } + } + + return result; +} + ComplexRowVector ComplexMatrix::column_min (void) const { @@ -4178,6 +4318,32 @@ } ComplexRowVector +ComplexMatrix::column_min_loc (void) const +{ + ComplexRowVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nc); + + for (int j = 0; j < nc; j++) + { + Complex res = 0; + double absres = abs (elem (0, j)); + for (int i = 0; i < nr; i++) + if (abs (elem (i, j)) < absres) + { + res = i; + absres = abs (elem (i, j)); + } + result.elem (j) = res + 1; + } + } + + return result; +} + +ComplexRowVector ComplexMatrix::column_max (void) const { ComplexRowVector result; @@ -4203,6 +4369,32 @@ return result; } +ComplexRowVector +ComplexMatrix::column_max_loc (void) const +{ + ComplexRowVector result; + + if (nr > 0 && nc > 0) + { + result.resize (nc); + + for (int j = 0; j < nc; j++) + { + Complex res = 0; + double absres = abs (elem (0, j)); + for (int i = 0; i < nr; i++) + if (abs (elem (i, j)) > absres) + { + res = i; + absres = abs (elem (i, j)); + } + result.elem (j) = res + 1; + } + } + + return result; +} + // i/o ostream& diff -r 5869adaa6aea -r 7947b7a6b6da liboctave/Matrix.h --- a/liboctave/Matrix.h Fri Nov 12 10:44:40 1993 +0000 +++ b/liboctave/Matrix.h Fri Nov 12 10:51:33 1993 +0000 @@ -512,10 +512,16 @@ ColumnVector diag (int k) const; ColumnVector row_min (void) const; + ColumnVector row_min_loc (void) const; + ColumnVector row_max (void) const; + ColumnVector row_max_loc (void) const; RowVector column_min (void) const; + RowVector column_min_loc (void) const; + RowVector column_max (void) const; + RowVector column_max_loc (void) const; // i/o @@ -1349,10 +1355,16 @@ ComplexColumnVector diag (int k) const; ComplexColumnVector row_min (void) const; + ComplexColumnVector row_min_loc (void) const; + ComplexColumnVector row_max (void) const; + ComplexColumnVector row_max_loc (void) const; ComplexRowVector column_min (void) const; + ComplexRowVector column_min_loc (void) const; + ComplexRowVector column_max (void) const; + ComplexRowVector column_max_loc (void) const; // i/o diff -r 5869adaa6aea -r 7947b7a6b6da src/builtins.cc --- a/src/builtins.cc Fri Nov 12 10:44:40 1993 +0000 +++ b/src/builtins.cc Fri Nov 12 10:51:33 1993 +0000 @@ -429,10 +429,6 @@ { "min", 3, 2, builtin_min, "min (x): minimum value(s) of a vector (matrix)", }, - { "get_next_arg", 1, 1, builtin_get_next_arg, - "get_next_arg (): return next argument in function taking varible\n\ -number of parameters", }, - { "npsol", 11, 3, builtin_npsol, #if defined (NPSOL_MISSING) "This function requires NPSOL, which is not freely\n\ @@ -565,6 +561,14 @@ { "syl", 4, 1, builtin_syl, "X = syl (A, B, C): solve the Sylvester equation A X + X B + C = 0", }, + { "va_arg", 1, 1, builtin_va_arg, + "va_arg (): return next argument in function taking varible\n\ +number of parameters", }, + + { "va_start", 1, 0, builtin_va_start, + "va_start (): reset the pointer to the list of optional arguments\n\ +to the beginning", }, + { "warranty", 1, 0, builtin_warranty, "warranty (): describe copying conditions", }, diff -r 5869adaa6aea -r 7947b7a6b6da src/g-builtins.cc --- a/src/g-builtins.cc Fri Nov 12 10:44:40 1993 +0000 +++ b/src/g-builtins.cc Fri Nov 12 10:51:33 1993 +0000 @@ -818,35 +818,6 @@ } /* - * Variable argument lists. - */ -tree_constant * -builtin_get_next_arg (const tree_constant *args, int nargin, int nargout) -{ - tree_constant *retval = NULL_TREE_CONST; - if (nargin == 1) - { - if (curr_function != (tree_function *) NULL) - { - if (curr_function->takes_varargs ()) - { - retval = new tree_constant [2]; - retval[0] = curr_function->get_next_arg (); - } - else - error ("next_arg only valid within function taking\ - variable number of arguments"); - } - else - error ("next_arg only valid within function body"); - } - else - print_usage ("get_next_arg"); - - return retval; -} - -/* * Get the value of an environment variable. */ tree_constant * @@ -1688,6 +1659,58 @@ } /* + * Variable argument lists. + */ +tree_constant * +builtin_va_arg (const tree_constant *args, int nargin, int nargout) +{ + tree_constant *retval = NULL_TREE_CONST; + if (nargin == 1) + { + if (curr_function != (tree_function *) NULL) + { + if (curr_function->takes_varargs ()) + { + retval = new tree_constant [2]; + retval[0] = curr_function->va_arg (); + } + else + error ("va_arg only valid within function taking\ + variable number of arguments"); + } + else + error ("va_arg only valid within function body"); + } + else + print_usage ("va_arg"); + + return retval; +} + +tree_constant * +builtin_va_start (const tree_constant *args, int nargin, int nargout) +{ + tree_constant *retval = NULL_TREE_CONST; + if (nargin == 1) + { + if (curr_function != (tree_function *) NULL) + { + if (curr_function->takes_varargs ()) + curr_function->va_start (); + else + error ("va_start only valid within function taking\ + variable number of arguments"); + } + else + error ("va_start only valid within function body"); + } + else + print_usage ("va_start"); + + return retval; +} + +/* * Copying information. */ tree_constant * diff -r 5869adaa6aea -r 7947b7a6b6da src/g-builtins.h --- a/src/g-builtins.h Fri Nov 12 10:44:40 1993 +0000 +++ b/src/g-builtins.h Fri Nov 12 10:51:33 1993 +0000 @@ -76,7 +76,6 @@ 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_get_next_arg (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); @@ -120,6 +119,8 @@ 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_va_arg (const tree_constant *, int, int); +extern tree_constant *builtin_va_start (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); diff -r 5869adaa6aea -r 7947b7a6b6da src/tree.h.old --- a/src/tree.h.old Fri Nov 12 10:44:40 1993 +0000 +++ b/src/tree.h.old Fri Nov 12 10:51:33 1993 +0000 @@ -252,7 +252,8 @@ int is_system_m_file (void) const; int takes_varargs (void) const; - tree_constant get_next_arg (void); + void va_start (void); + tree_constant va_arg (void); void stash_function_name (char *s); char *function_name (void); @@ -281,6 +282,7 @@ time_t t_parsed; int system_m_file; int varargs_ok; + int num_named_args; const tree_constant *args_passed; int num_args_passed; int curr_arg_number;