[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[changeset] make str2mat an alias of char
From: |
Thorsten Meyer |
Subject: |
[changeset] make str2mat an alias of char |
Date: |
Sat, 29 Nov 2008 23:56:23 +0100 |
User-agent: |
Mozilla-Thunderbird 2.0.0.17 (X11/20081018) |
Hi,
attached is a changeset that removes the str2mat.m function file and makes
str2mat an alias of char.
The two functions do the same as far as I can see. Only the internal char
function is of course much
faster than the str2mat.m function file. To me, it looks like str2mat is a
leftover from a time
when char() was less permissive with respect to its input arguments.
regards
Thorsten
# HG changeset patch
# User Thorsten Meyer <address@hidden>
# Date 1227996430 -3600
# Node ID ab802d7d5acf6e674ab64f9e497c648c8a0c437b
# Parent 837027b45d3b3ccddb8ec0b9199da727a1a83d71
make str2mat an alias to char
diff -r 837027b45d3b -r ab802d7d5acf scripts/ChangeLog
--- a/scripts/ChangeLog Sat Nov 29 23:03:16 2008 +0100
+++ b/scripts/ChangeLog Sat Nov 29 23:07:10 2008 +0100
@@ -1,3 +1,7 @@
+2008-11-29 Thorsten Meyer <address@hidden>
+
+ * strings/str2mat.m: Make an alias of the char function
+
2008-11-29 Thorsten Meyer <address@hidden>
* miscellaneous/gzip.m: Remove @seealso reference to __xzip__,
diff -r 837027b45d3b -r ab802d7d5acf scripts/strings/Makefile.in
--- a/scripts/strings/Makefile.in Sat Nov 29 23:03:16 2008 +0100
+++ b/scripts/strings/Makefile.in Sat Nov 29 23:07:10 2008 +0100
@@ -35,7 +35,7 @@
SOURCES = base2dec.m bin2dec.m blanks.m deblank.m dec2base.m \
dec2bin.m dec2hex.m findstr.m hex2dec.m index.m isletter.m isstrprop.m \
- lower.m mat2str.m regexptranslate.m rindex.m split.m str2double.m str2mat.m \
+ lower.m mat2str.m regexptranslate.m rindex.m split.m str2double.m \
str2num.m strcat.m cstrcat.m strcmpi.m strfind.m strjust.m strmatch.m \
strncmpi.m strrep.m strtok.m strtrim.m strtrunc.m strvcat.m \
substr.m upper.m validatestring.m
diff -r 837027b45d3b -r ab802d7d5acf scripts/strings/str2mat.m
--- a/scripts/strings/str2mat.m Sat Nov 29 23:03:16 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-## Copyright (C) 1996, 1998, 1999, 2000, 2002, 2004, 2005, 2006, 2007
-## Kurt Hornik
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING. If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} str2mat (@var{s_1}, @dots{}, @var{s_n})
-## Return a matrix containing the strings @var{s_1}, @dots{}, @var{s_n} as
-## its rows. Each string is padded with blanks in order to form a valid
-## matrix.
-##
-## This function is modelled after @sc{Matlab}. In Octave, you can create
-## a matrix of strings by @address@hidden; @dots{}; @var{s_n}]} even if
-## the strings are not all the same length.
-## @end deftypefn
-
-## Author: Kurt Hornik <address@hidden>
-## Adapted-By: jwe
-
-function retval = str2mat (varargin)
-
- if (nargin == 0)
- print_usage ();
- endif
-
- nc = 0;
- nr = 0;
-
- nr = zeros (nargin, 1);
- nc = zeros (nargin, 1);
- for k = 1 : nargin
- s = varargin{k};
- if (! ischar (s))
- s = char (s);
- endif
- [nr(k), nc(k)] = size (s);
- endfor
-
- tmp = find (nr == 0);
-
- if (! isempty (tmp))
- nr(tmp) = 1;
- endif
-
- retval_nr = sum (nr);
- retval_nc = max (nc);
-
- retval = char (ones (retval_nr, retval_nc) * toascii (" "));
-
- row_offset = 0;
- for k = 1 : nargin
- s = varargin{k};
- if (! ischar (s))
- s = char (s);
- endif
- if (nc(k) > 0)
- retval ((row_offset + 1) : (row_offset + nr(k)), 1:nc(k)) = s;
- endif
- row_offset = row_offset + nr(k);
- endfor
-
-endfunction
-
-%!assert(strcmp (str2mat ("a", "bb", "ccc"), ["a "; "bb "; "ccc"]));
-
-%!error str2mat ();
-
-%!assert(all (str2mat (1, 2, 3) == setstr ([1; 2; 3])));
-
diff -r 837027b45d3b -r ab802d7d5acf src/strfns.cc
--- a/src/strfns.cc Sat Nov 29 23:03:16 2008 +0100
+++ b/src/strfns.cc Sat Nov 29 23:07:10 2008 +0100
@@ -151,6 +151,7 @@
%!assert (all(char (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"]))
*/
+DEFALIAS (str2mat, char);
DEFUN (ischar, args, ,
"-*- texinfo -*-\n\
- [changeset] make str2mat an alias of char,
Thorsten Meyer <=