Mercurial > octave
changeset 13482:0daa1ac62b00
Merge with Savannah
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Mon, 25 Apr 2011 20:34:31 -0500 |
parents | e643b9393eba (current diff) 83fa84ef63ca (diff) |
children | 799c03ea7004 |
files | scripts/elfun/lcm.m |
diffstat | 7 files changed, 74 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/faq/OctaveFAQ.texi Sat Apr 23 20:14:08 2011 -0500 +++ b/doc/faq/OctaveFAQ.texi Mon Apr 25 20:34:31 2011 -0500 @@ -63,7 +63,7 @@ * Getting Octave:: * Installation:: * Common problems:: -* How do I ...?:: +* Using Octave:: * @sc{Matlab} compatibility:: * Index:: @end menu @@ -785,6 +785,7 @@ @menu * How do I set the number of displayed decimals?:: +* How does Octave solve linear systems?:: @end menu @cindex Tips and tricks @@ -804,9 +805,8 @@ @end group @end example -@menu -* How does Octave solve linear systems? -@end menu +@node How does Octave solve linear systems? +@section How does Octave solve linear systems? @cindex backslash operator @@ -814,7 +814,7 @@ Octave manual contains a complete high-level description of the algorithm that Octave uses to decide how to solve a particular linear system, e.g. how the backslash operator @code{A\x} will be interpreted. -Sections ``Techniques used for Linear Algebra'' and ``Linear Algebra on +Sections ``Techniques Used for Linear Algebra'' and ``Linear Algebra on Sparse Matrices'' from the manual describe this procedure. @node @sc{Matlab} compatibility
--- a/scripts/elfun/lcm.m Sat Apr 23 20:14:08 2011 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -## Copyright (C) 1994-2011 John W. Eaton -## -## 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 3 of the License, 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, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Mapping Function} {} lcm (@var{x}, @var{y}) -## @deftypefnx {Mapping Function} {} lcm (@var{x}, @var{y}, @dots{}) -## Compute the least common multiple of @var{x} and @var{y}, -## or of the list of all arguments. All elements must be the same size or -## scalar. -## @seealso{factor, gcd} -## @end deftypefn - -## Author: KH <Kurt.Hornik@wu-wien.ac.at> -## Created: 16 September 1994 -## Adapted-By: jwe - -function l = lcm (varargin) - - if (nargin > 1) - if (common_size (varargin{:}) != 0) - error ("lcm: all args must be of the same size or scalar"); - elseif (! all (cellfun (@isnumeric, varargin))) - error ("lcm: all arguments must be numeric"); - endif - - l = varargin{1}; - for i = 2:nargin - x = varargin{i}; - msk = l == 0 & x == 0; - l .*= x ./ gcd (l, x); - l(msk) = 0; - endfor - else - print_usage (); - endif - -endfunction - -%!assert(lcm (3, 5, 7, 15) == 105); - -%!error lcm (); - -%!test -%! s.a = 1; -%! fail("lcm (s)"); -
--- a/scripts/elfun/module.mk Sat Apr 23 20:14:08 2011 -0500 +++ b/scripts/elfun/module.mk Mon Apr 25 20:34:31 2011 -0500 @@ -20,7 +20,6 @@ elfun/csc.m \ elfun/cscd.m \ elfun/csch.m \ - elfun/lcm.m \ elfun/sec.m \ elfun/secd.m \ elfun/sech.m \
--- a/scripts/miscellaneous/ls.m Sat Apr 23 20:14:08 2011 -0500 +++ b/scripts/miscellaneous/ls.m Mon Apr 25 20:34:31 2011 -0500 @@ -63,7 +63,7 @@ retval = strvcat (regexp (output, '\S+', 'match'){:}); endif else - error ("ls: command exited abnormally with status %d", status); + error ("ls: command exited abnormally with status %d\n", status); endif else
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/specfun/lcm.m Mon Apr 25 20:34:31 2011 -0500 @@ -0,0 +1,61 @@ +## Copyright (C) 1994-2011 John W. Eaton +## +## 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 3 of the License, 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, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Mapping Function} {} lcm (@var{x}, @var{y}) +## @deftypefnx {Mapping Function} {} lcm (@var{x}, @var{y}, @dots{}) +## Compute the least common multiple of @var{x} and @var{y}, +## or of the list of all arguments. All elements must be the same size or +## scalar. +## @seealso{factor, gcd} +## @end deftypefn + +## Author: KH <Kurt.Hornik@wu-wien.ac.at> +## Created: 16 September 1994 +## Adapted-By: jwe + +function l = lcm (varargin) + + if (nargin > 1) + if (common_size (varargin{:}) != 0) + error ("lcm: all args must be of the same size or scalar"); + elseif (! all (cellfun (@isnumeric, varargin))) + error ("lcm: all arguments must be numeric"); + endif + + l = varargin{1}; + for i = 2:nargin + x = varargin{i}; + msk = l == 0 & x == 0; + l .*= x ./ gcd (l, x); + l(msk) = 0; + endfor + else + print_usage (); + endif + +endfunction + +%!assert(lcm (3, 5, 7, 15) == 105); + +%!error lcm (); + +%!test +%! s.a = 1; +%! fail("lcm (s)"); +
--- a/scripts/specfun/module.mk Sat Apr 23 20:14:08 2011 -0500 +++ b/scripts/specfun/module.mk Mon Apr 25 20:34:31 2011 -0500 @@ -7,6 +7,7 @@ specfun/factor.m \ specfun/factorial.m \ specfun/isprime.m \ + specfun/lcm.m \ specfun/legendre.m \ specfun/nchoosek.m \ specfun/nthroot.m \
--- a/scripts/startup/module.mk Sat Apr 23 20:14:08 2011 -0500 +++ b/scripts/startup/module.mk Mon Apr 25 20:34:31 2011 -0500 @@ -3,24 +3,22 @@ startup_FCN_FILES = \ startup/__finish__.m +LOCAL_STARTUP_FILE_SRC = startup/local-rcfile + SYSTEM_STARTUP_FILE_SRC = startup/main-rcfile SYSTEM_INPUTRC_FILE_SRC = startup/inputrc -LOCAL_STARTUP_FILE_SRC = startup/local-rcfile - STARTUP_FILE_SRC = \ + $(LOCAL_STARTUP_FILE_SRC) \ $(SYSTEM_STARTUP_FILE_SRC) \ - $(SYSTEM_INPUTRC_FILE_SRC) \ - $(LOCAL_STARTUP_FILE_SRC) + $(SYSTEM_INPUTRC_FILE_SRC) FCN_FILES += \ - $(startup_FCN_FILES) \ - $(SYSTEM_STARTUP_FILE_SRC) \ - $(LOCAL_STARTUP_FILE_SRC) + $(startup_FCN_FILES) EXTRA_DIST += \ - $(SYSTEM_INPUTRC_FILE_SRC) + $(STARTUP_FILE_SRC) PKG_ADD_FILES += startup/PKG_ADD