QRDOTDIV divides two real quaternions arrays elementwise q=[x,y] Inputs: x(4n,...) y(4n,...) Two real quaternion arrays of equal size Outputs: q(4n,...) The Hadamard quaotient (i.e. ./) of the input arrays If y is omitted then q = x^(-1) Copyright (C) Mike Brookes 2000-2012 Version: $Id: qrdotdiv.m 1689 2012-03-22 21:45:41Z dmb $ VOICEBOX is a MATLAB toolbox for speech processing. Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% This program 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 2 of the License, or (at your option) any later version. This program 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 can obtain a copy of the GNU General Public License from http://www.gnu.org/copyleft/gpl.html or by writing to Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function q=qrdotdiv(x,y) 0002 %QRDOTDIV divides two real quaternions arrays elementwise q=[x,y] 0003 % 0004 % Inputs: x(4n,...) 0005 % y(4n,...) Two real quaternion arrays of equal size 0006 % 0007 % Outputs: q(4n,...) The Hadamard quaotient (i.e. ./) of the input arrays 0008 % If y is omitted then q = x^(-1) 0009 % 0010 % Copyright (C) Mike Brookes 2000-2012 0011 % Version: $Id: qrdotdiv.m 1689 2012-03-22 21:45:41Z dmb $ 0012 % 0013 % VOICEBOX is a MATLAB toolbox for speech processing. 0014 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0015 % 0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0017 % This program is free software; you can redistribute it and/or modify 0018 % it under the terms of the GNU General Public License as published by 0019 % the Free Software Foundation; either version 2 of the License, or 0020 % (at your option) any later version. 0021 % 0022 % This program is distributed in the hope that it will be useful, 0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0025 % GNU General Public License for more details. 0026 % 0027 % You can obtain a copy of the GNU General Public License from 0028 % http://www.gnu.org/copyleft/gpl.html or by writing to 0029 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 persistent a b c 0032 if isempty(a) 0033 a=[1 2 3 4 2 1 4 3 3 4 1 2 4 3 2 1]; 0034 b=[1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4]; 0035 c=[6 8 10 11 15 16]; 0036 end 0037 s=size(x); 0038 x=reshape(x,4,[]); 0039 if nargin<2 % one argument - just invert x 0040 m=sum(x.^2,1); 0041 x=x./m(ones(4,1),:); 0042 x(2:4,:)=-x(2:4,:); 0043 q=reshape(x,s); 0044 else % multiply by conjugate of y and then divide by |y|^2 0045 y=reshape(y,4,[]); 0046 m=sum(y.^2,1); 0047 q=x(a,:).*y(b,:); 0048 q(c,:)=-q(c,:); 0049 q=reshape(sum(reshape(q,4,[]),1),s)./m(ones(4,1),:);; 0050 end

Generated on Thu 28-Jun-2018 14:29:51 by