Scala matrix manipulation api