2014-01-24 74 views
2

天真的用戶只需要一個簡單的卷積在斯卡拉微風:DenseVector卷積,如何(斯卡拉微風)

import breeze.linalg._ 
import breeze.numerics._ 
import breeze.signal.support.{OverhangOpt, CanConvolve} // ?? 

val kernel = DenseVector(1.0, 2.0) 
val data = DenseVector(2.0, 3.0, 4.0, 5.0) 
val out = data.convolve(kernel) 

能有人寫了一個小例子,如何做到這一點?

+0

它是否制定出你還是你需要別的嗎? – fotNelton

回答

3

你已經走上了正道。只要確保你有最新版本的breeze0.6-SNAPSHOT。例如,使用下面的部分在build.sbt

libraryDependencies ++= Seq(
     "org.scalanlp" % "breeze_2.10" % "0.6-SNAPSHOT" 
    ) 

resolvers ++= Seq(
     "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/", 
     "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/" 
    ) 

有沒有必要從breeze.signal.support進口的東西,你原來的例子會工作得很好:

scala> import breeze.linalg._ 
import breeze.linalg._ 

scala> import breeze.signal._ 
import breeze.signal._ 

scala> convolve(DenseVector(1.0, 2.0), DenseVector(3.0, 4.0, 5.0, 6.0)) 
res1: breeze.linalg.DenseVector[Double] = DenseVector(10.0, 13.0, 16.0)