Reducing the number of nonzero elements of topological loop (B) and cutset (D) matrices