Mercurial > octave-antonio
annotate scripts/miscellaneous/computer.m @ 20164:df437a52bcaf stable
doc: Update more docstrings to have one sentence summary as first line.
Reviewed miscellaneous, sparse, strings in scripts directory.
* scripts/miscellaneous/bzip2.m, scripts/miscellaneous/citation.m,
scripts/miscellaneous/compare_versions.m, scripts/miscellaneous/computer.m,
scripts/miscellaneous/debug.m, scripts/miscellaneous/dir.m,
scripts/miscellaneous/edit.m, scripts/miscellaneous/error_ids.m,
scripts/miscellaneous/fileattrib.m, scripts/miscellaneous/fullfile.m,
scripts/miscellaneous/genvarname.m, scripts/miscellaneous/gzip.m,
scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/news.m,
scripts/miscellaneous/open.m, scripts/miscellaneous/parseparams.m,
scripts/miscellaneous/recycle.m, scripts/miscellaneous/run.m,
scripts/miscellaneous/swapbytes.m, scripts/miscellaneous/tar.m,
scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m,
scripts/miscellaneous/what.m, scripts/sparse/bicg.m, scripts/sparse/bicgstab.m,
scripts/sparse/cgs.m, scripts/sparse/colperm.m, scripts/sparse/eigs.m,
scripts/sparse/etreeplot.m, scripts/sparse/gmres.m, scripts/sparse/gplot.m,
scripts/sparse/ichol.m, scripts/sparse/ilu.m, scripts/sparse/pcg.m,
scripts/sparse/pcr.m, scripts/sparse/qmr.m, scripts/sparse/spaugment.m,
scripts/sparse/spconvert.m, scripts/sparse/spdiags.m, scripts/sparse/spfun.m,
scripts/sparse/spones.m, scripts/sparse/sprandsym.m, scripts/sparse/spstats.m,
scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/sparse/treelayout.m,
scripts/sparse/treeplot.m, scripts/strings/base2dec.m,
scripts/strings/bin2dec.m, scripts/strings/blanks.m, scripts/strings/cstrcat.m,
scripts/strings/deblank.m, scripts/strings/dec2base.m,
scripts/strings/dec2bin.m, scripts/strings/dec2hex.m,
scripts/strings/findstr.m, scripts/strings/hex2dec.m, scripts/strings/index.m,
scripts/strings/isletter.m, scripts/strings/isstrprop.m,
scripts/strings/mat2str.m, scripts/strings/ostrsplit.m,
scripts/strings/regexptranslate.m, scripts/strings/rindex.m,
scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strchr.m,
scripts/strings/strjoin.m, scripts/strings/strjust.m,
scripts/strings/strmatch.m, scripts/strings/strsplit.m,
scripts/strings/strtok.m, scripts/strings/strtrim.m,
scripts/strings/strtrunc.m, scripts/strings/substr.m,
scripts/strings/untabify.m, scripts/time/datenum.m:
Update more docstrings to have one sentence summary as first line.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 May 2015 14:22:02 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19190
diff
changeset
|
1 ## Copyright (C) 2004-2015 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 -*- | |
19190 | 20 ## @deftypefn {Function File} {} computer () |
21 ## @deftypefnx {Function File} {@var{c} =} computer () | |
22 ## @deftypefnx {Function File} {[@var{c}, @var{maxsize}] =} computer () | |
23 ## @deftypefnx {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
|
24 ## @deftypefnx {Function File} {@var{arch} =} computer ("arch") |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
25 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os} that |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
26 ## identifies the type of computer that Octave is running on. |
19190 | 27 ## |
28 ## If invoked with an output argument, the value is returned instead of | |
29 ## printed. For example: | |
4691 | 30 ## |
31 ## @example | |
32 ## @group | |
33 ## computer () | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
34 ## @print{} i586-pc-linux-gnu |
4691 | 35 ## |
19190 | 36 ## mycomp = computer () |
37 ## @result{} mycomp = "i586-pc-linux-gnu" | |
4691 | 38 ## @end group |
39 ## @end example | |
5427 | 40 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
41 ## If two output arguments are requested, also return the maximum number of |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
42 ## elements for an array. This will depend on whether Octave has been |
19190 | 43 ## compiled with 32-bit or 64-bit index vectors. |
5427 | 44 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
45 ## If three output arguments are requested, also return the byte order of the |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
46 ## current system as a character (@qcode{"B"} for big-endian or @qcode{"L"} |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
47 ## for little-endian). |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
48 ## |
19190 | 49 ## If the argument @qcode{"arch"} is specified, return a string indicating the |
50 ## architecture of the computer on which Octave is running. | |
51 ## @seealso{isunix, ismac, ispc} | |
4691 | 52 ## @end deftypefn |
53 | |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
54 function [c, maxsize, endian] = computer (a) |
4691 | 55 |
19190 | 56 if (nargin > 1) |
57 print_usage (); | |
58 elseif (nargin == 1 && ! strcmpi (a, "arch")) | |
59 error ('computer: "arch" is only valid argument'); | |
60 endif | |
61 | |
62 if (nargin == 0) | |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
63 msg = octave_config_info ("canonical_host_type"); |
4691 | 64 |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
65 if (strcmp (msg, "unknown")) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
66 msg = "Hi Dave, I'm a HAL-9000"; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
67 endif |
4691 | 68 |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
69 if (nargout == 0) |
19190 | 70 disp (msg); |
5427 | 71 else |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
72 c = msg; |
19190 | 73 if (isargout (2)) |
74 if (strcmp (octave_config_info ("USE_64_BIT_IDX_T"), "true")) | |
75 maxsize = 2^63-1; | |
76 else | |
77 maxsize = 2^31-1; | |
78 endif | |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
79 endif |
19190 | 80 if (isargout (3)) |
81 if (octave_config_info ("words_big_endian")) | |
82 endian = "B"; | |
83 elseif (octave_config_info ("words_little_endian")) | |
84 endian = "L"; | |
85 else | |
86 endian = "?"; | |
87 endif | |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
88 endif |
5427 | 89 endif |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
90 else |
19190 | 91 ## "arch" argument asked for |
92 tmp = ostrsplit (octave_config_info ("canonical_host_type"), "-"); | |
93 if (numel (tmp) == 4) | |
94 c = sprintf ("%s-%s-%s", tmp{4}, tmp{3}, tmp{1}); | |
95 else | |
96 c = sprintf ("%s-%s", tmp{3}, tmp{1}); | |
97 endif | |
98 | |
4691 | 99 endif |
100 | |
101 endfunction | |
7411 | 102 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
103 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
104 %!assert (ischar (computer ())) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
105 %!assert (computer (), octave_config_info ("canonical_host_type")) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
106 %!assert (ischar (computer ("arch"))) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
107 |
19190 | 108 %!error computer (1,2) |
109 %!error <"arch" is only valid argument> computer ("xyz") | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
110 |