Rank and nullity of linear transformations and matrices