2

Naive user wants to do a simple convolve in Scala Breeze:

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)

Can someone write up a little example how to do this ?

4

1 回答 1

3

你已经走对了。只要确保您拥有最新版本的breeze,即0.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)
于 2014-01-24T13:59:21.370 回答