[37] | 1 | function Y = qdft(X, A, L) |
---|
| 2 | % QDFT Discrete quaternion Fourier transform. |
---|
| 3 | % |
---|
| 4 | % This function computes the one-dimensional discrete quaternion Fourier |
---|
| 5 | % transform of (columns of) X, which may be a real or complex quaternion |
---|
| 6 | % array. A is the transform axis and it may be a real or complex pure |
---|
| 7 | % quaternion. It need not be a unit pure quaternion. L may take the values |
---|
| 8 | % 'L' or 'R' according to whether the hypercomplex exponential is to be |
---|
| 9 | % multiplied on the left or right of X. There are no default values. |
---|
| 10 | % |
---|
| 11 | % This function uses direct evaluation using a matrix product, and it is |
---|
| 12 | % intended mainly for verifying results against fast transform |
---|
| 13 | % implementations such as qfft.m. See also: iqdft.m. |
---|
| 14 | |
---|
| 15 | % Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
| 16 | % See the file : Copyright.m for further details. |
---|
| 17 | |
---|
| 18 | error(nargchk(3, 3, nargin)), error(nargoutchk(0, 1, nargout)) |
---|
| 19 | |
---|
| 20 | if size(A) ~= [1, 1] |
---|
| 21 | error('The transform axis cannot be a matrix or vector.'); |
---|
| 22 | end |
---|
| 23 | |
---|
| 24 | if ~isa(A, 'quaternion') | ~ispure(A) |
---|
| 25 | error('The transform axis must be a pure quaternion.') |
---|
| 26 | end |
---|
| 27 | |
---|
| 28 | if L ~= 'L' & L ~= 'R' |
---|
| 29 | error('L must have the value ''L'' or ''R''.'); |
---|
| 30 | end |
---|
| 31 | |
---|
| 32 | A = unit(A); % Ensure that A is a unit (pure) quaternion. |
---|
| 33 | |
---|
| 34 | [r,c] = size(X); |
---|
| 35 | |
---|
| 36 | E = exp(-A .* 2 .* pi .* ((0:r-1)' *(0:r-1)) ./r); |
---|
| 37 | |
---|
| 38 | if L == 'L' |
---|
| 39 | Y = E * X; % Multiply the exponential matrix on the left. |
---|
| 40 | elseif L == 'R' |
---|
| 41 | Y = (X.' * E.').'; % To multiply the exponential matrix on the right |
---|
| 42 | % we transpose both and transpose the result. |
---|
| 43 | else |
---|
| 44 | error('L has incorrect value'); |
---|
| 45 | end |
---|