blob: ace37a310f6472422ce50d97af1a9175784ff0c7 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package scalam.collection
import breeze.linalg.DenseVector
import scala.collection.mutable.ArrayBuffer
import scala.collection.generic.CanBuildFrom
import scala.collection.mutable.Builder
/**
* This class serves as a wrapper for `breeze.linalg.DenseVector`s with all the operations found in
* indexed sequences. Where needed, instances of DenseVectors are implicitly converted
* into this class.
*
* The difference between this class and `WrappedDenseVector` is that calling transformer
* methods such as `filter` and `map` will yield a `DenseVector`, whereas a `WrappedDenseVector`
* will remain a `WrappedDenseVector`.
*
* @see [[scala.collection.mutable.ArrayOps]]
*
* @tparam Elem type of the elements contained in this DenseVector.
*
* @define Coll `DenseVector`
* @define orderDependent
* @define orderDependentFold
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
class DenseVectorOps[Elem: ClassManifest](override val repr: DenseVector[Elem]) extends DenseVectorLike[Elem, DenseVector[Elem]] {
val self = repr
def newBuilder = DenseVectorOps.newBuilder[Elem]
override protected[this] def thisCollection = new WrappedDenseVector(self)
override protected[this] def toCollection(repr: DenseVector[Elem]): WrappedDenseVector[Elem] = new WrappedDenseVector(repr)
override def seq = thisCollection
}
/**
* A companion object for DenseVectorsOps.
*/
object DenseVectorOps {
def newBuilder[Elem: ClassManifest] = new ArrayBuffer[Elem] mapResult (x => new DenseVector(x.toArray))
}
|