标签: spire

Breeze vs. Spire:可以/我应该将它们结合起来吗?

我使用breeze的集合(即DenseVector),其中我有整数和双精度等,并使用它们有点像你可能使用numpy的数组.我偶然发现了https://github.com/non/spire.我的印象是,它在收藏方面不是那么强大,但是我可能想要收藏的类型更强 - 例如Interval听起来很棒.我的印象是否合适并将他们结合起来是一个好主意?

/sf/answers/2833244011/我了解到Breeze使用netlib-java非常快.如果我将AnyRef(在这种情况下来自Spire)DenseVector的后代放入后端数组而不是后代中,我会破坏这种速度AnyVal吗?

scala scala-breeze spire

7
推荐指数
0
解决办法
283
查看次数

使用Spire的Rationals的总和或产品(如何获得scala.Numeric)

我认为这应该是直截了当的:

import spire.math.Rational

val seq  = Vector(Rational(1, 4), Rational(3, 4))
val sum  = seq.sum      // missing: scala.Numeric
val prod = seq.product  // missing: scala.Numeric
Run Code Online (Sandbox Code Playgroud)

我想这只是将正确的东西带入隐含范围的问题.但是我要导入什么?

我可以看到,为了得到一个RationalIsNumeric,我必须做这样的事情:

import spire.math.Numeric._
implicit val err = new ApproximationContext(Rational(1, 192))
implicit val num = RationalIsNumeric
Run Code Online (Sandbox Code Playgroud)

但那只是给了我一个spire.math.Numeric.所以我另外尝试这个:

import spire.math.compat._
Run Code Online (Sandbox Code Playgroud)

但没有运气......

math scala numerical-methods spire

6
推荐指数
2
解决办法
501
查看次数

斯卡拉的尖顶框架:我无法对一个团队进行操作

我尝试使用spire,一个数学框架,但我有一条错误消息:

import spire.algebra._
import spire.implicits._

trait AbGroup[A] extends Group[A]

final class Rationnel_Quadratique(val n1: Int = 2)(val coef: (Int, Int)) {
  override def toString = {
    coef match {
        case (c, i) =>
            s"$c + $i?$n"
    }
  }

  def a() = coef._1

  def b() = coef._2

  def n() = n1


} 

object Rationnel_Quadratique {

  def apply(coef: (Int, Int),n: Int = 2)= {
    new Rationnel_Quadratique(n)(coef)
  }

}

object AbGroup {

  implicit object RQAbGroup extends AbGroup[Rationnel_Quadratique] {

    def +(a: Rationnel_Quadratique, b: Rationnel_Quadratique): Rationnel_Quadratique …
Run Code Online (Sandbox Code Playgroud)

math scala spire

2
推荐指数
1
解决办法
575
查看次数

标签 统计

scala ×3

spire ×3

math ×2

numerical-methods ×1

scala-breeze ×1