% test diag_ckt_invar3()

global_defs;

for j=1:10
example = 1;
switch example
	case (1)
		a0= get_unit_vec(randn(3,1));
		b0= get_unit_vec(randn(3,1));
		c0= get_unit_vec(randn(3,1));
		a1= get_unit_vec(randn(3,1));
		b1= get_unit_vec(randn(3,1));
		c1= get_unit_vec(randn(3,1));
	otherwise
		error("example number is out of range");
end

ckt = dr11(c1,c0)*dr11(b1,b0)*dr11(a1,a0);
ckt_invar = ckt*dr11(-a1,-a0)*dr11(-b1,-b0)*dr11(-c1,-c0);
vecs_out = diag_ckt_invar3(ckt_invar);
c0f=vecs_out(1:3,1); b0f=vecs_out(1:3,2); a0f=vecs_out(1:3,3);
c1f=vecs_out(4:6,1); b1f=vecs_out(4:6,2); a1f=vecs_out(4:6,3);
fin_ckt = dr11(c1f,c0f)*dr11(b1f,b0f)*dr11(a1f,a0f);

%fin_ckt'*ckt is even number of DC-NOTs so
%it always has det=1


[U1,U0]= factor_SU2pow2_matrix(fin_ckt'*ckt);

error1 = norm(ckt - fin_ckt*kron(U1,U0))

endfor
