annotate scripts/miscellaneous/computer.m @ 13929:9cae456085c2

Grammarcheck of documentation before 3.6.0 release. * accumarray.m, blkdiag.m, nargoutchk.m, nthargout.m, profexplore.m, profile.m, computer.m, orderfields.m, recycle.m, version.m, sqp.m, matlabroot.m, __plt_get_axis_arg__.m, isonormals.m, isosurface.m, __fltk_file_filter__.m, __is_function__.m, __uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiobject_split_args__.m, __uiputfile_fltk__.m, uicontextmenu.m, uiresume.m, uiwait.m, mkpp.m, ppder.m, residue.m, addpref.m, getpref.m, ispref.m, loadprefs.m, prefsfile.m, saveprefs.m, rmpref.m, setpref.m, fftshift.m, bicg.m, bicgstab.m, cgs.m, gmres.m, __sprand_impl__.m, quantile.m, deblank.m, strsplit.m, addtodate.m, bsxfun.cc, kron.cc, regexp.cc, data.cc, file-io.cc, graphics.cc, load-save.cc, mappers.cc: Grammarcheck of documentation before 3.6.0 release.
author Rik <octave@nomad.inbox5.com>
date Wed, 23 Nov 2011 08:38:19 -0800
parents 9bebb2322c4e
children 72c96de7a403
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10821
diff changeset
1 ## Copyright (C) 2004-2011 John W. Eaton
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
2 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
4 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
8 ## your option) any later version.
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
9 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
14 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
17 ## <http://www.gnu.org/licenses/>.
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
18
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13117
diff changeset
20 ## @deftypefn {Function File} {[@var{c}, @var{maxsize}, @var{endian}] =} computer ()
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
21 ## @deftypefnx {Function File} {@var{arch} =} computer ("arch")
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
22 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os}
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
23 ## that identifies the kind of computer Octave is running on. If invoked
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
24 ## with an output argument, the value is returned instead of printed. For
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
25 ## example:
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
26 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
27 ## @example
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
28 ## @group
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
29 ## computer ()
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
30 ## @print{} i586-pc-linux-gnu
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
31 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
32 ## x = computer ()
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
33 ## @result{} x = "i586-pc-linux-gnu"
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
34 ## @end group
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
35 ## @end example
5427
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
36 ##
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
37 ## If two output arguments are requested, also return the maximum number
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
38 ## of elements for an array.
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
39 ##
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
40 ## If three output arguments are requested, also return the byte order
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
41 ## of the current system as a character (@code{"B"} for big-endian or
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
42 ## @code{"L"} for little-endian).
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
43 ##
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
44 ## If the argument @code{"arch"} is specified, return a string
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
45 ## indicating the architecture of the computer on which Octave is
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
46 ## running.
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
47 ## @end deftypefn
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
48
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
49 function [c, maxsize, endian] = computer (a)
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
50
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
51 if (nargin == 1 && ischar (a) && strcmpi (a, "arch"))
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
52 tmp = strsplit (octave_config_info ("canonical_host_type"), "-");
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
53 if (numel (tmp) == 4)
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
54 c = sprintf ("%s-%s-%s", tmp{4}, tmp{3}, tmp{1});
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
55 else
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
56 c = sprintf ("%s-%s", tmp{3}, tmp{1});
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
57 endif
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
58 elseif (nargin == 0)
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
59 msg = octave_config_info ("canonical_host_type");
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
60
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
61 if (strcmp (msg, "unknown"))
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
62 msg = "Hi Dave, I'm a HAL-9000";
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
63 endif
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
64
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
65 if (nargout == 0)
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
66 printf ("%s\n", msg);
5427
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
67 else
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
68 c = msg;
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
69 if (strcmp (octave_config_info ("USE_64_BIT_IDX_T"), "true"))
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
70 maxsize = 2^63-1;
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
71 else
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
72 maxsize = 2^31-1;
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
73 endif
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
74 if (octave_config_info ("words_big_endian"))
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
75 endian = "B";
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
76 elseif (octave_config_info ("words_little_endian"))
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
77 endian = "L";
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
78 else
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
79 endian = "?";
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
80 endif
5427
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
81 endif
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
82 else
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
83 print_usage ();
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
84 endif
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
85
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
86 endfunction
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
87
7768
a2d9f325b65a Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents: 7411
diff changeset
88 %!assert((ischar (computer ())
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
89 %! && computer () == octave_config_info ("canonical_host_type")));
13117
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
90 %!assert(ischar (computer ("arch")));
9bebb2322c4e computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
91 %!error computer (2);