如何将 breeze.linalg.DenseMatrix 转换为 Map[String,Value]?

How to convert breeze.linalg.DenseMatrix to Map[String,Value]?

我需要将 DenseMatrix 转换为 Map[String,[Value]]。键将第一行的每个值。相应键的值将是 column.

eg:

Solid liquid Gas 
Stone Water  Oxygen
Gold  kerosene Nitrogen

So map will be Map(Solid -> [Stone,Gold],Liquid -> [Water,kerosene],Gas -> [Oxygen,Nitrogen])

我觉得是这样的:

val mat = DenseMatrix(("Solid", "liquid", "gas"), ("Stone", "Water", "Oxygen"), ("Gold", "kerosene", "Nitrogen"))

{
  for {
    i <- 0 until mat.rows
  } yield (mat(i, 0) -> mat(i, 1 until mat.cols))
} toMap