Matix operations in Swift