function S = symplectic_red_naive(w,k) % S=SYMPLECTIC_RED_NAIVE(w,k) constructs an elementary symplectic matrix % which reduces the vector w % w: a vector of length 2n % k: an integer less than or equal to n % S: elementary symplectic matrix n = length(w)/2; % Constructing the first Householder matrix [u1,b1] = householder(w(n+k:2*n)); Q1 = eye(2*n); Q1(k:n,k:n) = eye(n-k+1) - b1*u1*u1'; Q1(n+k:2*n,n+k:2*n) = Q1(k:n,k:n); w = Q1*w; % Constructing the Givens matrix G = givens([w(k) w(n+k)]); Q2 = eye(2*n); Q2([k n+k],[k n+k]) = G; w = Q2*w; % Constructing the second Householder matrix [u3,b3] = householder(w(k:n)); Q3 = eye(2*n); Q3(k:n,k:n) = eye(n-k+1) - b3*u3*u3'; Q3(n+k:2*n,n+k:2*n) = Q3(k:n,k:n); % Generating the output S = Q3*Q2*Q1;