validate_sqmat <- function(x, n, message = NULL){
  validate_numeric(x)
  stopifnot(is.matrix(x))
  if(any(dim(x) != n)) stop(message, "The dimensions of ", deparse1(substitute(x)),
                            " must be ", n, " by ", n)
}
