aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/scalam/DataSet.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/scalam/DataSet.scala')
-rw-r--r--src/main/scala/scalam/DataSet.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/scala/scalam/DataSet.scala b/src/main/scala/scalam/DataSet.scala
new file mode 100644
index 0000000..baff6a6
--- /dev/null
+++ b/src/main/scala/scalam/DataSet.scala
@@ -0,0 +1,24 @@
+package scalam
+
+import scalax.file.Path
+import breeze.linalg.DenseVector
+
+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)
+
+} \ No newline at end of file