function y = mult_E12(x, QC, mC, nC, QD, mD, nD, w)
% Called by wls.m.
%
% Compute the product y = E12 x.

% Break x into pieces.
x2 = x(1 : nC*(mD-nD));
x3 = x(nC*(mD-nD) + (1 : (mC-nC)*nD));
x4 = x(nC*(mD-nD) + (mC-nC)*nD + 1 : mC*mD-nC*nD);

QC1 = QC(:, 1:nC);
QC2 = QC(:, nC+1 : mC);
QD1 = QD(:, 1:nD);
QD2 = QD(:, nD+1 : mD);

% Compute z's.
z2 = KPmult(QC1, QD2, x2);
z3 = KPmult(QC2, QD1, x3);
z4 = KPmult(QC2, QD2, x4);
z = w .* (z2 + z3 + z4);

% Compute y.
y = KPmultT(QC1, QD1, z);
