nnz added for matrices and tensors