The most common solution would be to write a class that wraps com.azavea.math.Numeric and implements scala.math.Numeric in terms of:
class AzaveaNumericWrapper[T]( implicit val n: com.azavea.math.Numeric[T] ) extends scala.math.Numeric { def compare (x: T, y: T): Int = n.compare(x, y) def minus (x: T, y: T): T = n.minus(x, y) // and so on }
Then we implement the implicit conversion:
// NOTE: in scala 2.10, we could directly declare AzaveaNumericWrapper as an implicit class implicit def toAzaveaNumericWrapper[T]( implicit n: com.azavea.math.Numeric[T] ) = new AzaveaNumericWrapper( n )
The fact that n itself is implicit is key here: it allows you to automatically use implicit values ββof type com.azavea.math.Numeric , where na is an implicit value of type scala.math.Numeric . Note that to complete this, you probably want to do the opposite as well (write the ScalaNumericWrapper class, which implements com.azavea.math.Numeric in terms of scala.math.Numeric).
Now there is a flaw for the above solution: you get a conversion (and therefore instanciation) for each call (to a method that has a context binding like scala.math.Numeric , and where you are only an instance of com.azavea.math.Numeric ). So you really want to define an implicit singleton instance of AzaveaNumericWrapper for each of your number types. Assuming you have types MyType and MyOtherType for which you have defined instances of com.azavea.math.Numeric :
implicit object MyTypeIsNumeric extends AzaveaNumericWrapper[MyType] implicit object MyOtherTypeIsNumeric extends AzaveaNumericWrapper[MyOtherType] //...
Also, keep in mind that the obvious primary purpose of the azavea Numeric class is to significantly increase execution speed (mainly because of its specialization in type of parameters). Using the wrapper as described above, you lose the specialization and therefore the speed that goes out of it. Specialization must be used to the end, and as soon as you invoke a general method that is not specialized, you introduce into the world of unspecialized generics (even if this method then calls a specialized method). Therefore, in cases where speed matters, try using azavea Numeric directly instead of scala Numeric (just because AzaveaNumericWrapper uses it internally does not mean that you will get any increase in speed, since there will be no specialization here).
You may have noticed that in my examples I avoided defining instances of AzaveaNumericWrapper for types Int , Long and so on. This is because the implicit scala.math.Numeric values ββfor these types are already (in the standard library). You may be tempted to simply hide them (via something like import scala.math.Numeric.{ShortIsIntegral => _} ) to be sure that your own (Azavea-supported) version is being used, but it makes no sense. The only reason I can think of is to make it work faster, but as explained above, it will not.