1function [L,tfr]=dgtlength(Ls,a,M,varargin); 2%-*- texinfo -*- 3%@deftypefn {Function} dgtlength 4%@verbatim 5%DGTLENGTH DGT length from signal 6% Usage: L=dgtlength(Ls,a,M); 7% L=dgtlength(Ls,a,M,lt); 8% 9% DGTLENGTH(Ls,a,M) returns the length of a Gabor system that is long 10% enough to expand a signal of length Ls. Please see the help on 11% DGT for an explanation of the parameters a and M. 12% 13% If the returned length is longer than the signal length, the signal 14% will be zero-padded by DGT. 15% 16% A valid transform length must be divisable by both a and M. This 17% means that the minumal admissable transform length is : 18% 19% Lsmallest = lcm(a,M); 20% 21% and all valid transform lengths are multipla of Lsmallest* 22% 23% Non-separable lattices: 24% ----------------------- 25% 26% DGTLENGTH(Ls,a,M,lt) does as above for a non-separable lattice with 27% lattice-type lt. For non-separable lattices, there is the additinal 28% requirement on the transform length, that the structure of the 29% lattice must be periodic. This gives a minimal transform length of : 30% 31% Lsmallest = lcm(a,M)*lt(2); 32% 33%@end verbatim 34%@strong{Url}: @url{http://ltfat.github.io/doc/gabor/dgtlength.html} 35%@seealso{dgt} 36%@end deftypefn 37 38% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>. 39% This file is part of LTFAT version 2.3.1 40% 41% This program is free software: you can redistribute it and/or modify 42% it under the terms of the GNU General Public License as published by 43% the Free Software Foundation, either version 3 of the License, or 44% (at your option) any later version. 45% 46% This program is distributed in the hope that it will be useful, 47% but WITHOUT ANY WARRANTY; without even the implied warranty of 48% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 49% GNU General Public License for more details. 50% 51% You should have received a copy of the GNU General Public License 52% along with this program. If not, see <http://www.gnu.org/licenses/>. 53 54if nargin<3 55 error('%s: Too few input parameters.',upper(mfilename)); 56end; 57 58% This function takes some of the same input parameters as DGT. The phase 59% parameter is ignore, because it does not change the length of the 60% transform, but is included to not cause problem when dgtlength is 61% called via framelength. 62definput.keyvals.lt=[0 1]; 63definput.flags.phase={'freqinv','timeinv'}; 64[flags,kv,lt]=ltfatarghelper({'lt'},definput,varargin); 65 66if ~isnumeric(M) || ~isscalar(M) 67 error('%s: M must be a scalar',upper(mfilename)); 68end; 69 70if ~isnumeric(a) || ~isscalar(a) 71 error('%s: "a" must be a scalar',upper(mfilename)); 72end; 73 74if rem(M,1)~=0 || M<=0 75 error('%s: M must be a positive integer',upper(mfilename)); 76end; 77 78if rem(a,1)~=0 || a<=0 79 error('%s: "a" must be a positive integer',upper(mfilename)); 80end; 81 82if ~isnumeric(Ls) 83 error('%s: Ls must be numeric.',upper(mfilename)); 84end; 85 86if ~isscalar(Ls) 87 error('%s: Ls must a scalar.',upper(mfilename)); 88end; 89 90if nargin<4 91 92 Lsmallest=lcm(a,M); 93 94else 95 96 if ~isnumeric(lt) || ~isvector(lt) || length(lt)~=2 97 error('%s: lt must be a vector of length 2.',upper(mfilename)); 98 end; 99 100 101 if (mod(lt(2),1)>0) || lt(2)<=0 102 error('%s: lt(2) must be a positive integer.',upper(mfilename)); 103 end; 104 105 if (mod(lt(1),1)>0) || lt(1)<0 || lt(1)>=lt(2) 106 error(['%s: lt(1)=%i must be a positive integer that is larger than 0 but ' ... 107 'smaller than lt(2)=%i.'],upper(mfilename),lt(1),lt(2)); 108 end; 109 110 if lt(1)==0 && lt(2)~=1 111 error('%s: The rectangular lattice can only be specified by lt=[0 1].',upper(mfilename)); 112 end; 113 114 if gcd(lt(1),lt(2))>1 115 error('%s: lt(1)/lt(2) must be an irriducible fraction.',upper(mfilename)); 116 end; 117 118 Lsmallest=lcm(a,M)*lt(2); 119 120end; 121 122L=ceil(Ls/Lsmallest)*Lsmallest; 123 124 125 126