Mercurial > hg > octave-nkf
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 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2004-2011 John W. Eaton |
4691 | 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. | |
4691 | 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/>. | |
4691 | 18 |
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 | 22 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os} |
23 ## that identifies the kind of computer Octave is running on. If invoked | |
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 | 26 ## |
27 ## @example | |
28 ## @group | |
29 ## computer () | |
30 ## @print{} i586-pc-linux-gnu | |
31 ## | |
32 ## x = computer () | |
33 ## @result{} x = "i586-pc-linux-gnu" | |
34 ## @end group | |
35 ## @end example | |
5427 | 36 ## |
37 ## If two output arguments are requested, also return the maximum number | |
38 ## of elements for an array. | |
39 ## | |
40 ## If three output arguments are requested, also return the byte order | |
41 ## of the current system as a character (@code{"B"} for big-endian or | |
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 | 47 ## @end deftypefn |
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 | 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 | 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 | 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 | 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 | 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 | 84 endif |
85 | |
86 endfunction | |
7411 | 87 |
7768
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7411
diff
changeset
|
88 %!assert((ischar (computer ()) |
7411 | 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); |