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

poly.algebra.MultiplicativeCSemigroup.scala Maven / Gradle / Ivy

package poly.algebra

import poly.algebra.factory._
import poly.algebra.specgroup._

/**
 * Represents a multiplicative commutative semigroup.
 *
 * An instance of this typeclass should satisfy the following axioms:
 *  - $lawMultiplicativeAssociativity
 *  - $lawMultiplicativeCommutativity
 *
 * @define lawMultiplicativeCommutativity '''Multiplicative commutativity''':  ∀''a'', ''b''∈X, ''a'' * ''b'' == ''b'' * ''a''.
 * @author Tongfei Chen
 */
trait MultiplicativeCSemigroup[@sp(fdi) X] extends MultiplicativeSemigroup[X] {
  override def asSemigroupWithMul: CSemigroup[X] = new CSemigroup[X] {
    def op(x: X, y: X) = mul(x, y)
  }
}

object MultiplicativeCSemigroup extends ImplicitGetter[MultiplicativeCSemigroup] {
  def create[@sp(fdi) X](f: (X, X) => X): MultiplicativeCSemigroup[X] = new MultiplicativeCSemigroup[X] {
    def mul(x: X, y: X): X = f(x, y)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy