Mercurial > hg > octave-nkf
annotate scripts/deprecated/com2str.m @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 1cdb42b372e8 |
children |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1998, 2004, 2005, 2006, 2007, 2008 |
7017 | 2 ## Auburn University. All rights reserved. |
4878 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7016 | 7 ## under the terms of the GNU General Public License as published by |
8 ## the Free Software Foundation; either version 3 of the License, or (at | |
9 ## your option) any later version. | |
4878 | 10 ## |
7016 | 11 ## Octave is distributed in the hope that it will be useful, but |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
4878 | 15 ## |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
4878 | 19 |
20 ## -*- texinfo -*- | |
21 ## @deftypefn {Function File} {} com2str (@var{zz}, @var{flg}) | |
22 ## This function has been deprecated. Use num2str instead. | |
23 ## | |
24 ## Convert complex number to a string. | |
25 ## @strong{Inputs} | |
26 ## @table @var | |
27 ## @item zz | |
28 ## complex number | |
29 ## @item flg | |
30 ## format flag | |
31 ## 0 (default): -1, 0, 1, 1i, 1 + 0.5i | |
32 ## 1 (for use with zpout): -1, 0, + 1, + 1i, + 1 + 0.5i | |
33 ## @end table | |
34 ## @end deftypefn | |
35 | |
7693
8e5371d47da6
note version when functions were deprecated
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
36 ## Deprecated in version 3.0 |
8e5371d47da6
note version when functions were deprecated
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
37 |
4878 | 38 function retval = com2str (zz, flg) |
39 | |
7696
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
40 persistent warned = false; |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
41 if (! warned) |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
42 warned = true; |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
43 warning ("Octave:deprecated-function", |
7704
1cdb42b372e8
don't embed newline in warning messages in deprecated functions
John W. Eaton <jwe@octave.org>
parents:
7696
diff
changeset
|
44 "com2str is obsolete and will be removed from a future version of Octave; please use num2str instead"); |
7696
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
45 endif |
0a362fa8f3c8
Add warning to rest of deprecated functions
David Bateman <dbateman@free.fr>
parents:
7693
diff
changeset
|
46 |
4878 | 47 if (nargin < 1 || nargin > 2) |
6046 | 48 print_usage (); |
4878 | 49 endif |
50 if (nargin == 1) | |
51 flg = 0; | |
52 endif | |
53 | |
54 if (! (isscalar (zz) && isscalar (flg))) | |
55 error ("com2str: arguments must be a scalar"); | |
56 endif | |
57 | |
58 if (flg != 0 && flg != 1) | |
59 error ("invalid flg value: %d", flg); | |
60 endif | |
61 | |
62 sgns = "+-"; | |
63 rz = real (zz); | |
64 iz = imag (zz); | |
65 az = abs (zz); | |
66 if (iz == 0) | |
67 ## strictly a real number | |
68 switch (flg) | |
69 case(0) | |
70 retval = num2str (rz); | |
71 case(1) | |
72 retval = [sgns(1+(rz<0)), " ", num2str(abs(rz))]; | |
73 endswitch | |
74 elseif (rz == 0) | |
75 ## strictly an imaginary number | |
76 switch (flg) | |
77 case(0) | |
4898 | 78 retval = [num2str(iz), "i"]; |
4878 | 79 case(1) |
80 retval = [sgns(1+(iz<0)), " ", num2str(abs(iz)), "i"]; | |
81 endswitch | |
82 else | |
83 ## complex number | |
84 ## strictly an imaginary number | |
85 switch (flg) | |
86 case(0) | |
87 retval = [num2str(rz), " ", com2str(i*iz,1)]; | |
88 case(1) | |
89 retval = [sgns(1+(rz<0)), " ", num2str(abs(rz)), " ", com2str(i*iz,1)]; | |
90 endswitch | |
91 endif | |
92 | |
93 endfunction |