make a copy of matrix for destructive operations

this should fix #157