matrix manipulation for rust languange