All Downloads are FREE. Search and download functionalities are using the official Maven repository.

breeze.linalg.support.CanCreateZeros.scala Maven / Gradle / Ivy

There is a newer version: 1.0
Show newest version
package breeze.linalg.support

import breeze.math.Semiring

import scala.reflect.ClassTag

/**
 * breeze
 * 7/10/14
 * @author Gabriel Schubiner 
 *
 *
 */
trait CanCreateZeros[+T, I] {
  def apply(d: I): T
}

object ArrayCanCreateZeros {
  class OpArray[@specialized V:ClassTag:Semiring]
    extends CanCreateZeros[Array[V],Int] {
    override def apply(d: Int) = {
      Array.fill(d)(implicitly[Semiring[V]].zero)
    }
  }
  implicit object OpArrayI extends OpArray[Int]
  implicit object OpArrayS extends OpArray[Short]
  implicit object OpArrayL extends OpArray[Long]
  implicit object OpArrayF extends OpArray[Float]
  implicit object OpArrayD extends OpArray[Double]
  implicit def OpArrayAny[V:ClassTag:Semiring] : OpArray[V] = new OpArray[V]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy