-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDataRoot.scala
32 lines (26 loc) · 1007 Bytes
/
DataRoot.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package rkhs
import breeze.linalg._
import various.TypeDef._
/**
* Definition of traits to encapsulate container types, and avoid type erasure in pattern matching (in function detectDenseVectorType for example).
* Note that any type of containers could be used, not just DenseVector, because the data container is not specified in DataRoot, but in the derived
* types.
*/
sealed trait DataRoot {
val typeName: String
def nPoint: Index
}
object DataRoot {
case class RealVal(val data: DenseVector[Real]) extends DataRoot { // because case class Real will not work, it will replace definition of Real in this file
val typeName = "Real"
def nPoint: Index = data.size
}
case class VectorReal(val data: DenseVector[DenseVector[Real]]) extends DataRoot {
val typeName = "VectorReal"
def nPoint: Index = data.size
}
case class MatrixReal(val data: DenseVector[DenseMatrix[Real]]) extends DataRoot {
val typeName = "Matrix of Real"
def nPoint: Index = data.size
}
}