# check a solution (stored in x) param eps := 1e-6; param D{N,N} >= 0; let {i in N, j in N} D[i,j] := sum{k in Dim} (x[i,k] - x[j,k])^2; printf "distance matrix:\n"; set disterridx within {N,N}; let disterridx := {}; param errcount integer, >= 0, default 0; for{i in N} { for {j in N} { #printf " %.2f", D[i,j]; if (i < j and D[i,j] < 1-eps) then { let errcount := errcount + 1; let disterridx := disterridx union {(i,j)}; } } #printf "\n"; } if (errcount == 1) then { printf "one distance is < 1 by more than %g\n", eps; } else if (errcount > 1) then { printf "%d distances are < 1 by more than %g\n", errcount, eps; } else if (errcount == 0) then { printf "all distances are >= 1 by at least %g\n", eps; } for {(i,j) in disterridx} { printf " D(%d,%d) = %g\n", i,j, D[i,j]; } let errcount := 0; set normerridx default {}; printf "norms:"; param thenorm; for {i in N} { let thenorm := sum{k in Dim} x[i,k]^2; #printf " %.2f", thenorm; if (abs(thenorm - 1) > eps) then { let errcount := errcount + 1; let normerridx := normerridx union {i}; } } #printf "\n"; if (errcount == 1) then { printf "one norm is != 1 by more than %g\n", errcount, eps; display normerridx; } else if (errcount > 0) then { printf "%d norms are != 1 by more than %g\n", errcount, eps; display normerridx; } else if (errcount == 0) then { printf "all norms are == 1 with at most %g error\n", eps; }