add inverse and swap function.
fix a bug.