public static IDensity <G, M, RF> Divide <G, M, RF>(this IDensity <G, M, RF> d, IDensity <G, M, RF> d2) where G : IMultiplicativeGroup <M> { var g = d.BaseStructure; return(Density <G, M, RF> .BinaryOp <G, M>(g, d, d2, (a, b) => g.Divide(a, b), (s, t) => $"({s}/{t})")); }
public static IDensity <G, M, RF> Multiply <G, M, RF>(this IDensity <G, M, RF> d, IDensity <G, M, RF> d2) where G : IMultiplicativeMonoid <M> { var g = d.BaseStructure; return(Density <G, M, RF> .BinaryOp <G, M>(g, d, d2, (a, b) => g.Multiply(a, b), (s, t) => $"({s}*{t})")); }
public static IDensity <G, M, RF> Add <G, M, RF>(this IDensity <G, M, RF> d, IDensity <G, M, RF> d2) where G : IAdditiveMonoid <M> { var g = d.BaseStructure; return(Density <G, M, RF> .BinaryOp <G, M>(g, d, d2, (a, b) => g.Add(a, b), (s, t) => $"({s}+{t})")); }
public static IDensity <G, M, RF> Subtract <G, M, RF>(this IDensity <G, M, RF> d, IDensity <G, M, RF> d2) where G : IAdditiveGroup <M> { var g = d.BaseStructure; return(Density <G, M, RF> .BinaryOp <G, M>(g, d, d2, (a, b) => g.Subtract(a, b), (s, t) => $"({s}-{t})")); }
public static IDensity <G, M, RF> WithDisadvantage <G, M, RF>(this IDensity <G, M, RF> d, int n = 1) where G : IAdditiveMonoid <M>, IComparer <M> { var g = d.BaseStructure; if (n < 0) { return(d.WithAdvantage(-n)); } if (n == 0) { return(d); } if (n == 1) { return(Density <G, M, RF> .BinaryOp <G, M>(d.BaseStructure, d, d, (a, b) => g.Min(a, b), (s, t) => $"d{s}")); } var mDensity = d.AsMultiDensity(n).MultiOp <G, M>(d.BaseStructure, e => g.Min(e), e => $"d{n}{e.First()}"); return(mDensity); }