1%MTIMESR Multiply for f_hat
2%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
3
4% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
5%
6% This program is free software; you can redistribute it and/or modify it under
7% the terms of the GNU General Public License as published by the Free Software
8% Foundation; either version 2 of the License, or (at your option) any later
9% version.
10%
11% This program is distributed in the hope that it will be useful, but WITHOUT
12% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14% details.
15%
16% You should have received a copy of the GNU General Public License along with
17% this program; if not, write to the Free Software Foundation, Inc., 51
18% Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19function r = mtimesr(p,q)
20if (isa(p,'f_hat') && isnumeric(q))
21  p = f_hat(p);
22  if (p.N ~= length(q(:))-1)
23    error('Dimensions must agree.')
24  end
25  r = f_hat(p);
26  for k = 0:r.N
27    r.f_hat(k^2+1:k^2+1+2*k) = q(k+1)*r.f_hat(k^2+1:k^2+1+2*k);
28  end
29else
30  error('Wrong argument types');
31end
32