# HG changeset patch # User jwe # Date 1068829739 0 # Node ID 02d2fcf835fc7c9f587a8937fc8033dd947731a9 # Parent ac4e4807acc5f1586a7e65c7fa6c28adcfb768f4 [project @ 2003-11-14 17:08:59 by jwe] diff -r ac4e4807acc5 -r 02d2fcf835fc scripts/ChangeLog --- a/scripts/ChangeLog Fri Nov 14 16:15:41 2003 +0000 +++ b/scripts/ChangeLog Fri Nov 14 17:08:59 2003 +0000 @@ -4,6 +4,8 @@ * linear-algebra/krylovb.m: Fix typo in usage message. + * general/isdefinite.m: New function. + 2003-10-29 John W. Eaton * general/reshape: Delete. diff -r ac4e4807acc5 -r 02d2fcf835fc scripts/general/isdefinite.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/general/isdefinite.m Fri Nov 14 17:08:59 2003 +0000 @@ -0,0 +1,57 @@ +## Copyright (C) 2003 Gabriele Pannocchia +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, write to the Free +## Software Foundation, 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} isdefinite (@var{x},@var{tol}) +## Return 1 if @var{x} is symmetric positive definite within the +## tolerance specified by @var{tol} or 0 if @var{x} is symmetric +## positive semidefinite. Otherwise, return -1. If @var{tol} +## is omitted, use a tolerance equal to 100 times the machine precision. +## @end deftypefn +## @seealso{issymmetric} + +## Author: Gabriele Pannocchia +## Created: November 2003 +## Adapted-By: jwe + +function retval = isdefinite (x, tol) + + if (nargin == 1 || nargin == 2) + if (nargin == 1) + tol = 100*eps; + endif + sym = issymmetric (x, tol); + if (sym > 0) + ## Matrix is symmetric, check eigenvalues. + mineig = min (eig (x)); + if (mineig > tol) + retval = 1; + elseif (mineig > -tol) + retval = 0; + else + retval = -1; + end + else + error ("isdefinite: matrix x must be symmetric"); + endif + else + usage ("isdefinite (x,tol)"); + endif + +endfunction diff -r ac4e4807acc5 -r 02d2fcf835fc src/ChangeLog --- a/src/ChangeLog Fri Nov 14 16:15:41 2003 +0000 +++ b/src/ChangeLog Fri Nov 14 17:08:59 2003 +0000 @@ -1,5 +1,9 @@ 2003-11-13 John W. Eaton + * utils.cc (Fisvarname): Pass correct name to make_argv. + + * ov-cell.cc (Fiscellstr): New function. + * ov-file.h (octave_file::all, octave_file::any, octave_file::dims, octave_file::is_real_type, octave_file::ist_real_scalar): New functions. diff -r ac4e4807acc5 -r 02d2fcf835fc src/file-io.cc --- a/src/file-io.cc Fri Nov 14 16:15:41 2003 +0000 +++ b/src/file-io.cc Fri Nov 14 17:08:59 2003 +0000 @@ -1181,6 +1181,7 @@ \n\ @item \"unsigned char\"\n\ @itemx \"uchar\"\n\ +@itemx \"uint8\"\n\ Unsigned character.\n\ \n\ @item \"short\"\n\ @@ -1216,11 +1217,17 @@ \n\ @item \"integer*2\"\n\ @itemx \"int16\"\n\ -Two byte integer.\n\ +Two byte signed integer.\n\ \n\ @item \"integer*4\"\n\ @itemx \"int32\"\n\ -Four byte integer.\n\ +Four byte signed integer.\n\ +\n\ +@item \"uint16\"\n\ +Two byte unsigned integer.\n\ +\n\ +@item \"uint32\"\n\ +Four byte unsigned integer.\n\ @end table\n\ \n\ @noindent\n\ diff -r ac4e4807acc5 -r 02d2fcf835fc src/ov-cell.cc --- a/src/ov-cell.cc Fri Nov 14 16:15:41 2003 +0000 +++ b/src/ov-cell.cc Fri Nov 14 17:08:59 2003 +0000 @@ -506,6 +506,46 @@ return retval; } +DEFUN (iscellstr, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} iscellstr (@var{cell})\n\ +Return true if every element of the cell array @var{cell} is a\n\ +character string\n\ +@end deftypefn") +{ + octave_value retval = true; + + if (args.length () == 1) + { + octave_value arg = args (0); + + if (arg.is_cell ()) + { + Cell c = args(0).cell_value (); + + if (! error_state) + { + for (int i = 0; i < c.length (); i++) + { + if (! c(i).is_string ()) + { + retval = false; + break; + } + } + } + else + error ("iscellstr: expecting argument to be a cell"); + } + else + retval = false; + } + else + print_usage ("iscellstr"); + + return retval; +} + /* ;;; Local Variables: *** ;;; mode: C++ *** diff -r ac4e4807acc5 -r 02d2fcf835fc src/utils.cc --- a/src/utils.cc Fri Nov 14 16:15:41 2003 +0000 +++ b/src/utils.cc Fri Nov 14 17:08:59 2003 +0000 @@ -107,7 +107,7 @@ int argc = args.length () + 1; - string_vector argv = args.make_argv ("help"); + string_vector argv = args.make_argv ("isvarname"); if (error_state) return retval;