use non-sparse implementation when k = n