/usr/share/octave/packages/3.2/tsa-4.1.0/mvfilter.m is in octave-tsa 4.1.0+svn20110501-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | function [x,z]=mvfilter(B,A,x,z)
% Multi-variate filter function
%
% Y = MVFILTER(B,A,X)
% [Y,Z] = MVFILTER(B,A,X,Z)
%
% Y = MVFILTER(B,A,X) filters the data in matrix X with the
% filter described by cell arrays A and B to create the filtered
% data Y. The filter is a 'Direct Form II Transposed'
% implementation of the standard difference equation:
%
% a0*Y(n) = b0*X(:,n) + b1*X(:,n-1) + ... + bq*X(:,n-q)
% - a1*Y(:,n-1) - ... - ap*Y(:,n-p)
%
% A=[a0,a1,a2,...,ap] and B=[b0,b1,b2,...,bq] must be matrices of
% size Mx((p+1)*M) and Mx((q+1)*M), respectively.
% a0,a1,...,ap, b0,b1,...,bq are matrices of size MxM
% a0 is usually the identity matrix I or must be invertible
% X should be of size MxN, if X has size NxM a warning
% is raised, and the output Y is also transposed.
%
% A simulated MV-AR process can be generiated with
% Y = mvfilter(eye(M), [eye(M),-AR],randn(M,N));
%
% A multivariate inverse filter can be realized with
% [AR,RC,PE] = mvar(Y,P);
% E = mvfilter([eye(M),-AR],eye(M),Y);
%
% see also: MVAR, FILTER
% $Id: mvfilter.m 6981 2010-03-02 23:38:34Z schloegl $
% Copyright (C) 1996-2003 by Alois Schloegl <a.schloegl@ieee.org>
%
% 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 3 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 should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
[ra, ca] = size(A);
[rb, cb] = size(B);
[M, N ] = size(x);
if (ra~=rb),
fprintf(2,'ERROR MVFILTER: number of rows of A and B do not fit\n');
return;
end;
if nargin<4,
z = []; %zeros(M,oo);
end;
if (M~=ra),
if (N==ra),
fprintf(2,'Warning MVFILTER: dimensions fit only to transposed data. X has been transposed.\n');
x = x.';
%[x,z] = mvfilter(B,A,x,z); x = x.'; return;
else
fprintf(2,'ERROR MVFILTER: dimensions do not fit\n');
return;
end;
end;
p = ca/M-1;
q = cb/M-1;
oo = max(p,q);
if isempty(z)
z = zeros(M,oo);
else
if any(size(z)~=[M,oo])
fprintf('Error MVFILTER: size of z does not fit\n');
[size(z),oo,M]
return;
end;
end;
%%%%% normalization to A{1}=I;
if p<=q,
for k=1:p,
%A{k}=A{k}/A{1};
A(:,k*M+(1:M)) = A(:,k*M+(1:M)) / A(:,1:M);
end;
A(:,1:M) = eye(M);
else
for k=0:q,
%B{k}=B{k}/A{1};
B(:,k*M+(1:M)) = B(:,k*M+(1:M)) / A(:,1:M);
end;
end;
for k = 1:N,
acc = B(:,1:M) * x(:,k) + z(:,1); % / A{1};
z = [z(:,2:oo), zeros(M,1)];
for l = 1:q,
z(:,l) = z(:,l) + B(:,l*M+(1:M)) * x(:,k);
end;
for l = 1:p,
z(:,l) = z(:,l) - A(:,l*M+(1:M)) * acc;
end;
x(:,k) = acc;
end;
|