Mercurial > hg > octave-nkf
annotate scripts/specfun/lcm.m @ 20263:ac59136f1f10
update fltk uimenu position when adding to figure
* libinterp/dldfcn/__init_fltk__.cc
(fltk_uimenu::update_position): new function
(fltk_uimenu::add_to_menu): delay creating menus with pos <= 0, assign position value based on number of menus created.
* scripts/gui/uimenu.m:
assert position of 0 instead of 9
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Wed, 08 Apr 2015 21:07:04 -0400 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19292
diff
changeset
|
1 ## Copyright (C) 1994-2015 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
1026 | 18 |
3321 | 19 ## -*- texinfo -*- |
11028 | 20 ## @deftypefn {Mapping Function} {} lcm (@var{x}, @var{y}) |
21 ## @deftypefnx {Mapping Function} {} lcm (@var{x}, @var{y}, @dots{}) | |
19292 | 22 ## Compute the least common multiple of @var{x} and @var{y}, or of the list of |
23 ## all arguments. | |
24 ## | |
25 ## All elements must be numeric and of the same size or scalar. | |
26 ## @seealso{factor, gcd, isprime} | |
3321 | 27 ## @end deftypefn |
2311 | 28 |
5428 | 29 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
2312 | 30 ## Created: 16 September 1994 |
31 ## Adapted-By: jwe | |
32 | |
4870 | 33 function l = lcm (varargin) |
904 | 34 |
19292 | 35 if (nargin < 2) |
11028 | 36 print_usage (); |
715 | 37 endif |
2325 | 38 |
19292 | 39 if (common_size (varargin{:}) != 0) |
40 error ("lcm: all args must be the same size or scalar"); | |
41 elseif (! all (cellfun ("isnumeric", varargin))) | |
42 error ("lcm: all arguments must be numeric"); | |
43 endif | |
44 | |
45 l = varargin{1}; | |
46 for i = 2:nargin | |
47 x = varargin{i}; | |
48 msk = (l == 0 & x == 0); | |
49 l .*= x ./ gcd (l, x); | |
50 l(msk) = 0; | |
51 endfor | |
52 | |
715 | 53 endfunction |
7385 | 54 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 %!assert (lcm (3, 5, 7, 15), 105) |
7385 | 57 |
19292 | 58 %!error lcm () |
59 %!error lcm (1) | |
60 %!error <same size or scalar> lcm ([1 2], [1 2 3]) | |
61 %!error <arguments must be numeric> lcm ([1 2], {1 2}) | |
7385 | 62 |