def innerProductRoot()

in algebird-core/src/main/scala/com/twitter/algebird/DecayingCMS.scala [356:374]


    def innerProductRoot(that: CMS): DoubleAt = {
      var i = 0
      var res = Double.PositiveInfinity
      val t = Math.max(this.timeInHL, that.timeInHL)
      val scale = this.getScale(t) * that.getScale(t)
      while (i < depth) {
        var sum = 0.0
        val it0 = this.cells(i).iterator
        val it1 = that.cells(i).iterator
        while (it0.hasNext) {
          val x = it0.next() * it1.next()
          if (x != 0.0) sum += x
        }
        if (sum < res) res = sum
        i += 1
      }
      val x = if (res != 0.0) Math.sqrt(res * scale) else 0.0
      new DoubleAt(x, t)
    }