HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulenumeric-prelude-0.4.4Haskell98

Algebra.Ring

  • 1 class
  • 13 values

Class

6 declarations
classclass C a => C a where
#

Ring encapsulates the mathematical structure of a (not necessarily commutative) ring, with the laws

  a * (b * c) === (a * b) * c
      one * a === a
      a * one === a
  a * (b + c) === a * b + a * c

Typical examples include integers, polynomials, matrices, and quaternions.

Minimal definition: *, (one or fromInteger)

Instances43C, …
  • C IntegerDefined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Int16Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Int32Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Int64Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Int8Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Word16Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Word32Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Word64Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C Word8Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C DoubleDefined in numeric-prelude-0.4.4 · Algebra.Ring
  • C FloatDefined in numeric-prelude-0.4.4 · Algebra.Ring
  • C IntDefined in numeric-prelude-0.4.4 · Algebra.Ring
  • C WordDefined in numeric-prelude-0.4.4 · Algebra.Ring
  • C TDefined in numeric-prelude-0.4.4 · Number.FixedPoint.Check
  • C TDefined in numeric-prelude-0.4.4 · Number.GaloisField2p32m5
  • C TDefined in numeric-prelude-0.4.4 · Number.Peano
  • C TDefined in numeric-prelude-0.4.4 · Number.Positional.Check
  • RealFloat a => C (Complex a)Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • Num a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.Wrapper.Haskell98
  • Integral a => C (Ratio a)Defined in numeric-prelude-0.4.4 · Algebra.Ring
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · Number.ResidueClass.Func
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · Number.Ratio
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.LaurentPolynomial
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.Matrix
    Property
    genIntMatrix /\ \a -> Laws.leftIdentity  (*) (Matrix.one (Matrix.numRows a)) a
    Property
    genIntMatrix /\ \a -> Laws.rightIdentity (*) (Matrix.one (Matrix.numColumns a)) a
    Property
    genIntMatrix /\ \a -> genFactorMatrix a /\ \b -> Laws.homomorphism Matrix.transpose (*) (flip (*)) a b
    Property
    genIntMatrix /\ \a -> genFactorMatrix a /\ \b -> genFactorMatrix b /\ \c -> Laws.associative (*) a b c
    Property
    genIntMatrix /\ \b -> genSameMatrix b /\ \c -> genFactorMatrix b /\ \a -> Laws.leftDistributive (*) (+) a b c
    Property
    genIntMatrix /\ \a -> genFactorMatrix a /\ \b -> genSameMatrix b /\ \c -> Laws.rightDistributive (*) (+) a b c
    Property
    QC.choose (0,10) /\ \k -> genDimension /\ \n -> genMatrixFor n n /\ \a -> a^k == nest (fromInteger k) ((a::Matrix.T Integer)*) (Matrix.one n)
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.Polynomial
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.PowerSeries
    Property
    QC.choose (1,10) /\ \expon (QC.Positive x) xs -> let xt = x:xs in  equalTrunc 15 (PS.pow (const x) (1 % expon) (PST.coeffs (PST.fromCoeffs xt ^ expon)) ++ repeat zero) (xt ++ repeat zero)
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.PowerSeries2
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.PowerSum
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.Wrapper.NumericPrelude
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · Number.Complex
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · Number.PartiallyTranscendental
  • C a => C (T a)Defined in numeric-prelude-0.4.4 · Number.Quaternion
  • (Eq a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · Number.ResidueClass.Check
  • (Eq a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · Number.ResidueClass.Maybe
  • (Ord a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · Number.NonNegative · orphan
  • (C a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.RootSet
  • (C a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · MathObj.PartialFraction
  • (C a, C a) => C (T a)Defined in numeric-prelude-0.4.4 · Number.NonNegativeChunky
  • C v => C (T a v)Defined in numeric-prelude-0.4.4 · Number.OccasionallyScalarExpression
  • C v => C (T a v)Defined in numeric-prelude-0.4.4 · Number.SI
  • (Ord a, C a, C b) => C (T a b)Defined in numeric-prelude-0.4.4 · MathObj.Algebra
  • (Ord i, C a) => C (T i a)Defined in numeric-prelude-0.4.4 · Number.Physical
  • (IsScalar u, C a) => C (T u a)Defined in numeric-prelude-0.4.4 · Number.DimensionTerm
method(*) :: a -> a -> a
#
methodone :: a
#
method(^) :: a -> Integer -> a
#

The exponent has fixed type Integer in order to avoid an arbitrarily limitted range of exponents, but to reduce the need for the compiler to guess the type (default type). In practice the exponent is most oftenly fixed, and is most oftenly 2. Fixed exponents can be optimized away and thus the expensive computation of Integers doesn't matter. The previous solution used a C constrained type and the exponent was converted to Integer before computation. So the current solution is not less efficient.

A variant of ^ with more flexibility is provided by Algebra.Core.ringPower.

valuesqr :: C a => a -> a
#

Complex functions

3 declarations

Properties

9 declarations