3914
|
1 ## Copyright (C) 2000 Paul Kienzle |
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} repmat (@var{A}, @var{m}, @var{n}) |
|
22 ## @deftypefnx {Function File} {} repmat (@var{A}, [@var{m} @var{n}]) |
|
23 ## Form a block matrix of size @var{m} by @var{n}, with a copy of matrix |
|
24 ## @var{A} as each element. If @var{n} is not specified, form an |
|
25 ## @var{m} by @var{m} block matrix. |
|
26 ## @end deftypefn |
|
27 |
|
28 ## Author: Paul Kienzle <pkienzle@kienzle.powernet.co.uk> |
|
29 ## Created: July 2000 |
|
30 |
3915
|
31 function x = repmat (a, m, n) |
|
32 |
3914
|
33 if (nargin < 2 || nargin > 3) |
|
34 usage ("repmat (a, m, n)"); |
|
35 endif |
|
36 |
|
37 if (nargin == 2) |
4030
|
38 if (isscalar (m)) |
3914
|
39 n = m; |
4030
|
40 elseif (isvector (m) && length (m) == 2) |
3914
|
41 n = m(2); |
|
42 m = m(1); |
|
43 else |
|
44 error ("repmat: only builds 2D matrices") |
|
45 endif |
|
46 endif |
|
47 |
|
48 if (isstr (a)) |
|
49 x = setstr (kron (ones (m, n), toascii (a))); |
|
50 else |
|
51 x = kron (ones (m, n), a); |
|
52 endif |
|
53 |
|
54 endfunction |