import breeze.math.PowImplicits._
@expand @expand.valify implicit def v_v_Op[@expand.args(Int, Double) T, @expand.args(OpAdd, OpSub, OpDiv, OpSet, OpMod, OpPow) Op <: OpType] (implicit @expand.sequence[Op]({_ + _}, {_ - _}, {_ / _}, {(a, b) => b}, {_ % _}, {_ pow _}) op: Op.Impl2[T, T, T]): Op.Impl2[Vector[T], Vector[T], Vector[T]] = { new Op.Impl2[Vector[T], Vector[T], Vector[T]] { def apply(a: Vector[T], b: Vector[T]): Vector[T] = { (a.length, b.length) match { case (0, _) => a case (_, 0) => b case (1, bl) => val s = a(0) val result = Vector.zeros[T](bl) var i = 0 while (i < bl) { result(i) = op(s, b(i)) i += 1 } result case (al, 1) => val s = b(0) val result = Vector.zeros[T](al) var i = 0 while (i < al) { result(i) = op(a(i), s) i += 1 } result case (al, bl) if al == bl => val result = a.copy var i = 0 while (i < al) { result(i) = op(a(i), b(i)) i += 1 } result case (al, bl) if al < bl => val result = Vector.zeros[T](bl) var i = 0 while (i < bl) { result(i) = op(a(i % al), b(i)) i += 1 } result case (al, bl) => val result = Vector.zeros[T](al) var i = 0 while (i < al) { result(i) = op(a(i), b(i % bl)) i += 1 } result } } implicitly[BinaryRegistry[Vector[T], Vector[T], Op.type, Vector[T]]].register(this) } }
implicit def opAdd[T : ClassTag : Semiring]: OpAdd.Impl2[Vector[T], Vector[T], Vector[T]] = new OpAdd.Impl2[Vector[T], Vector[T], Vector[T]] { val r = implicitly[Semiring[T]] def apply(a: Vector[T], b: Vector[T]): Vector[T] = { ... } }
--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze...@googlegroups.com.
To post to this group, send email to scala-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/359a8a53-8fc5-4787-a93c-9dc598e61f06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/4320b640-77fb-4e48-80d0-66a9cb013ad2%40googlegroups.com.
def plus[T : ClassTag : Semiring](v1: Vector[T], v2: Vector[T]): Vector[T] = v1 + v2
plus(v, v2)
--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze...@googlegroups.com.
To post to this group, send email to scala-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/a4153831-c67b-4c4a-ba44-baa68209be1f%40googlegroups.com.