Counter2Ops
trait Counter2Ops
Type members
Classlikes
class CanZipMapValuesCounter2[K1, K2, V, RV] extends CanZipMapValues[Counter2[K1, K2, V], V, RV, Counter2[K1, K2, RV]]
Implicits
Implicits
implicit def addIntoVV[K1, K2, V : Semiring]: InPlaceImpl2[Counter2[K1, K2, V], Counter2[K1, K2, V]]
implicit def canAxpy[K1, K2, V : Semiring]: InPlaceImpl3[Counter2[K1, K2, V], V, Counter2[K1, K2, V]]
implicit def canDivIntoVV[K1, K2, V : Field]: InPlaceImpl2[Counter2[K1, K2, V], Counter2[K1, K2, V]]
implicit def canMulIntoVV[K1, K2, V : Semiring]: InPlaceImpl2[Counter2[K1, K2, V], Counter2[K1, K2, V]]
implicit def canMulVS_M[K1, K2, V](implicit semiring: Semiring[V]): Impl2[Counter2[K1, K2, V], V, Counter2[K1, K2, V]]
Returns the k-norm of this Vector. implicit def canNorm[K1, K2, V:Ring]:CanNorm[Counter2[K1, K2, V]] = new CanNorm[Counter2[K1, K2, V]] { val field = implicitly[Ring[V]] def apply(c: Counter2[K1, K2, V], n: Double): Double = { import c._
Returns the k-norm of this Vector. implicit def canNorm[K1, K2, V:Ring]:CanNorm[Counter2[K1, K2, V]] = new CanNorm[Counter2[K1, K2, V]] { val field = implicitly[Ring[V]] def apply(c: Counter2[K1, K2, V], n: Double): Double = { import c._
if (n == 1) {
var sum = 0.0
activeValuesIterator foreach (v => sum += field.norm(v))
sum
} else if (n == 2) {
var sum = 0.0
activeValuesIterator foreach (v => { val nn = field.norm(v); sum += nn * nn })
math.sqrt(sum)
} else if (n == Double.PositiveInfinity) {
var max = Double.NegativeInfinity
activeValuesIterator foreach (v => { val nn = field.norm(v); if (nn > max) max = nn })
max
} else {
var sum = 0.0
activeValuesIterator foreach (v => { val nn = field.norm(v); sum += math.pow(nn,n) })
math.pow(sum, 1.0 / n)
}
}
}