1 ## Copyright (C) 2010 Soren Hauberg
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 3, or (at your option)
8 ## This program is distributed in the hope that it will be useful, but
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this file. If not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} rdivide (@var{a}, @var{b})
18 ## XXX: Write help text.
21 function retval = rdivide (a, b)
27 if (!ismatrix (a) || !ismatrix (a))
28 error ("rdivide: input arguments must be scalars or matrices");
31 if (!size_equal (a, b) || !isscalar (b))
32 error ("times: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)",
33 rows (a), columns (a), rows (b), columns (b));
36 ## Take action depending on input
37 if (isscalar (a) && isa (b, "kronprod"))
38 retval = kronprod (a ./ b.A, 1 ./ b.B);
39 elseif (isa (a, "kronprod") && isscalar (b))
40 if (numel (a.A) < numel (a.B))
41 retval = kronprod (a.A ./ b, a.B);
43 retval = kronprod (a.A, a.B ./ b);
45 elseif (isa (a, "kronprod") && isa (b, "kronprod"))
46 ## XXX: Can we do something smarter here?
47 retval = full (a) ./ full (b);
49 ## XXX: We should probably handle sparse cases and all sorts of other
50 ## situations better here
51 retval = full (a) ./ full (b);