blob: 99e27a39f1cecf5e65522bb34b02e853e0726f88 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package scalam
import scalax.file.Path
import breeze.linalg.DenseVector
case class DataSet(val points: Seq[(Double, Double)], val name: String) {
def save(path: Path) = {
path.createFile(createParents = true, failIfExists = false)
for (processor <- path.outputProcessor; out = processor.asOutput)
for ((x, y) <- points) out.write(x + " " + y + "\n")
}
lazy val (xs, ys) = points.unzip match {
case (x, y) => (DenseVector(x: _*), DenseVector(y: _*))
}
}
object DataSet {
def apply(x: DenseVector[Double], y: DenseVector[Double], name: String = "") = new DataSet(x.data zip y.data, name)
}
|