N*N coherence computation and test

@Sylvain @leahy @pantazis @John_Mosher @hossein27en?