fix matrix copy on swap
add tn itn matrix and invariants