add a space before {, and only indent 2 spaces for the body of the map; also make sure you add a space after "while". e.g.
```scala
    val data = matrix.map { x => 
      val row = Array.ofDim[Double](n)
      var i = 0
      while (i < n) {
        row(i) = x(i) - colSums(i)
        i += 1 
      }
      row
    }           
```