%Tests odo.m

global_defs;
example=5
switch example
	case (1)
		U = rand_unitary(5, false);
	case (2)%U= Ax1
		U = kron(rand_unitary(2,true), id2);
	case (3)%CNOT, sigx(0)^n(1) 
		U = [id2,ze2;
		ze2,sigx];
	case (4)%multiplexor
		U = [rand_unitary(2,true), ze2;
		ze2,rand_unitary(2,true)];
	case (5)%swap, aka exchange operator 
		U = ex_op;				
	otherwise
		error("example number is out of range");
end
dim_U = rows(U);
[L, D, R] = odo(U);

err1=norm(L*D*R'-U)
err2=norm(L*transpose(L)-eye(dim_U))
err3=norm(R*transpose(R)-eye(dim_U))
err4=norm(D*D'-eye(dim_U))

