diff --git a/src/Algebra/AdditionalProperties/Extensions/ComplexMatrixExtension.cs b/src/Algebra/AdditionalProperties/Extensions/ComplexMatrixExtension.cs index 8cff58c..29494de 100644 --- a/src/Algebra/AdditionalProperties/Extensions/ComplexMatrixExtension.cs +++ b/src/Algebra/AdditionalProperties/Extensions/ComplexMatrixExtension.cs @@ -11,19 +11,12 @@ using C33 = CategoryOf.OnField.FMatrix; public static class ComplexMatrixExtension { - private struct C22B + private struct C22B(Complex a, Complex b, Complex c, Complex d) { - public C22B(Complex a, Complex b, Complex c, Complex d) - { - X11 = a; - X12 = b; - X21 = c; - X22 = d; - } - public Complex X11; - public Complex X12; - public Complex X21; - public Complex X22; + public Complex X11 = a; + public Complex X12 = b; + public Complex X21 = c; + public Complex X22 = d; public static C22B operator +(C22B a, C22B b) => new(a.X11 + b.X11, a.X12 + b.X12, a.X21 + b.X21, a.X22 + b.X22); @@ -96,14 +89,16 @@ public static class ComplexMatrixExtension C22B w = t + FastFullMul(cPd - a, Ds_CsA); C22B wPv = w + v; - C33 res = new(); - res[1, 1] = t.X11 + self[1, 3] * other[3, 1]; - res[1, 2] = t.X12 + self[1, 3] * other[3, 2]; - res[2, 1] = t.X21 + self[2, 3] * other[3, 1]; - res[2, 2] = t.X22 + self[2, 3] * other[3, 2]; + C33 res = new() + { + [1, 1] = t.X11 + self[1, 3] * other[3, 1], + [1, 2] = t.X12 + self[1, 3] * other[3, 2], + [2, 1] = t.X21 + self[2, 3] * other[3, 1], + [2, 2] = t.X22 + self[2, 3] * other[3, 2], + [1, 3] = wPv.X11 + (self[1, 3] - self[3, 3] - cSa.X11) * other[3, 3], + [2, 3] = wPv.X21 + (self[2, 3] - cSa.X21) * other[3, 3] + }; - res[1, 3] = wPv.X11 + (self[1, 3] - self[3, 3] - cSa.X11) * other[3, 3]; - res[2, 3] = wPv.X21 + (self[2, 3] - cSa.X21) * other[3, 3]; C22B wPu = w + u; res[3, 1] = wPu.X11 + self[3, 3] * (other[3, 1] - other[1, 1] + CsD.X11); res[3, 2] = wPu.X12 + self[3, 3] * (other[3, 2] - other[1, 2] + CsD.X12); diff --git a/src/Algebra/AdditionalProperties/Extensions/ComplexNormalMatrixExtension.cs b/src/Algebra/AdditionalProperties/Extensions/ComplexNormalMatrixExtension.cs index 4520572..2540973 100644 --- a/src/Algebra/AdditionalProperties/Extensions/ComplexNormalMatrixExtension.cs +++ b/src/Algebra/AdditionalProperties/Extensions/ComplexNormalMatrixExtension.cs @@ -3,17 +3,8 @@ using Skeleton.DataStructure.Packs.MatrixDecompositions; namespace Skeleton.Algebra.AdditionalProperties.Extensions; -/// -/// additional methods for complex normal matrix -/// public static class ComplexNormalMatrixExtension { - /// - /// unitary decomposition of complex normal matrix - /// - /// - /// - /// public static JDPair.OnField.FMatrix> UnitaryDecomposition (this CategoryOf.OnField.FNormalMatrix a, bool order = false) diff --git a/src/Algebra/AdditionalProperties/IUnitaryInvariantMatrix.cs b/src/Algebra/AdditionalProperties/IUnitaryInvariantMatrix.cs index 1604713..fad3b0c 100644 --- a/src/Algebra/AdditionalProperties/IUnitaryInvariantMatrix.cs +++ b/src/Algebra/AdditionalProperties/IUnitaryInvariantMatrix.cs @@ -1,11 +1,7 @@ namespace Skeleton.Algebra.AdditionalProperties; -/// -/// matrix property invariant under unitary similarity -/// public interface IUnitaryInvariantMatrix { } -/// public interface IUnitaryInvariantMatrix : IUnitaryInvariantMatrix where TUnitaryInvariant : IUnitaryInvariantMatrix,new() { } diff --git a/src/Algebra/AffineSpaces/AffineSpace.cs b/src/Algebra/AffineSpaces/AffineSpace.cs index e923f11..b16c688 100644 --- a/src/Algebra/AffineSpaces/AffineSpace.cs +++ b/src/Algebra/AffineSpaces/AffineSpace.cs @@ -7,40 +7,24 @@ using Skeleton.DataStructure.Packs.LinearSystems; namespace Skeleton.Algebra.AffineSpaces; -/// -/// general affine space -/// public abstract class AffineSpace : FixableTensor { } -/// public abstract class AffineSpace : AffineSpace where TAffine : AffineSpace, new() { - /// - /// intersection of two affine space - /// - /// - /// public abstract TAffine Intersection(TAffine otherSpace); } -/// public abstract class AffineSpace : AffineSpace where TSpace : VectorSpace, new() where TAffine : AffineSpace, new() { - - - /// - /// underlying vector space - /// public TSpace BaseSpace { get; set; } = new(); } -/// public abstract class AffineSpace : AffineSpace where TMatrix : Matrix, new() where TSpace : VectorSpace, new() @@ -49,55 +33,29 @@ public abstract class AffineSpace : AffineSpace public abstract class AffineSpace : AffineSpace where TVector : Vector, new() where TMatrix : Matrix, new() where TSpace : VectorSpace, new() where TAffine : AffineSpace, new() { - - /// - /// bias vector - /// public TVector Bias { get; set; } = new(); - /// - /// if a point is container in the space - /// - /// - /// + public bool ContainsPoint(TVector p) => BaseSpace.ContainsVector(p - Bias); - - /// - /// construct - /// - /// - /// + public void Fill(TSpace s, TVector b) { BaseSpace = s; Bias = b; } - - /// - /// generate affine space from a space and a bias vector - /// - /// - /// - /// + public static TAffine Dispatch(TSpace s, TVector b) { TAffine res = new (); res.Fill(s, b); return res; } - - /// - /// generate affine space from a set of basis and a bias vector - /// - /// - /// - /// + public static TAffine Dispatch(IEnumerable basis, TVector b) { TSpace s = VectorSpace.Dispatch(basis); @@ -106,7 +64,6 @@ public abstract class AffineSpace : AffineSpa } -/// public abstract class AffineSpace : AffineSpace where TVector : Vector, new() where TMatrix : Matrix, new() @@ -114,9 +71,7 @@ public abstract class AffineSpace : where TAffine : AffineSpace, new() where TScalar : notnull { - - /// - /// + public LinearSystem InverseSystem { get { @@ -130,7 +85,6 @@ public abstract class AffineSpace : } } - /// public override TAffine Intersection(TAffine otherSpace) { LinearSystem sa = InverseSystem; diff --git a/src/Algebra/AffineSpaces/FAffineSpace.cs b/src/Algebra/AffineSpaces/FAffineSpace.cs index cc7bc66..488f6b0 100644 --- a/src/Algebra/AffineSpaces/FAffineSpace.cs +++ b/src/Algebra/AffineSpaces/FAffineSpace.cs @@ -6,13 +6,9 @@ public partial class CategoryOf { public static partial class OnField { - /// public class FAffineSpace : AffineSpace { - /// public FAffineSpace() { } - - /// public override int Dim => FDim; } } diff --git a/src/Algebra/Extensions/GeneralExt.cs b/src/Algebra/Extensions/GeneralExt.cs index 8aa623e..554955a 100644 --- a/src/Algebra/Extensions/GeneralExt.cs +++ b/src/Algebra/Extensions/GeneralExt.cs @@ -4,30 +4,20 @@ using Skeleton.Utils.Helpers; namespace Skeleton.Algebra.Extensions; -/// -/// public static class GeneralExt { - - /// - /// private static readonly ThreadLocal> TolCache = new(() => new Stack()); [ThreadStatic] private static double TolValue; private static double Tol => TolCache.Value!.TryPeek(out TolValue) ? TolValue : 1E-8D; - /// - /// - /// public static void SetTol(double t) { TolCache.Value!.Push(t); } - /// - /// public static void ResetTol() { TolCache.Value!.Pop(); @@ -43,31 +33,17 @@ public static class GeneralExt return Math.Abs(x) < Tol; } - /// - /// - /// - /// public static bool CZero(this Complex x) { return x.Real.CZero() && x.Imaginary.CZero(); } - /// - /// - /// - /// - /// + public static bool IsEqualApprox(this float l, float r) { return (l - r).CZero(); } - - /// - /// - /// - /// - /// - /// + public static bool IsSignificantlyGreaterThen(this double l, double r) { if (l.IsEqualApprox(r)) @@ -75,42 +51,21 @@ public static class GeneralExt return l > r; } - /// - /// - /// - /// - /// - /// public static bool IsSignificantlyLessThen(this double l, double r) { if (l.IsEqualApprox(r)) return false; return l < r; } - - /// - /// - /// - /// - /// + public static bool IsEqualApprox(this double l, double r) { return (l - r).CZero(); } - - /// - /// - /// - /// - /// + public static bool IsEqualApprox(this Complex l, Complex r) => l.Real.IsEqualApprox(r.Real) && l.Imaginary.IsEqualApprox(r.Imaginary); - - /// - /// - /// - /// public static Complex LSum(this IEnumerable l) { Complex res = Complex.Zero; @@ -118,11 +73,7 @@ public static class GeneralExt res += x; return res; } - - /// - /// - /// - /// + public static float LSum(this IEnumerable l) { float res = 0; @@ -130,11 +81,7 @@ public static class GeneralExt res += x; return res; } - - /// - /// - /// - /// + public static double LSum(this IEnumerable l) { double res = 0; @@ -143,10 +90,6 @@ public static class GeneralExt return res; } - /// - /// - /// - /// public static Complex LProd(this IEnumerable l) { Complex res = Complex.One; @@ -154,12 +97,7 @@ public static class GeneralExt res *= x; return res; } - - /// - /// - /// - /// - /// + public static bool ApproxContains(this IEnumerable l, Complex k) { foreach (Complex x in l) @@ -167,12 +105,7 @@ public static class GeneralExt return true; return false; } - - /// - /// - /// - /// - /// + public static bool ApproxContains(this IEnumerable l, float k) { foreach (float x in l) @@ -181,11 +114,6 @@ public static class GeneralExt return false; } - /// - /// - /// - /// - /// public static bool ApproxContains(this IEnumerable l, double k) { foreach (double x in l) @@ -194,10 +122,6 @@ public static class GeneralExt return false; } - /// - /// - /// - /// public static Dictionary RoughGroup(this IEnumerable r) { List> clusters = new List>(); @@ -228,11 +152,7 @@ public static class GeneralExt return res; } - /// - /// group complex numbers by count - /// - /// - /// + public static Dictionary Group(this IEnumerable l) where TScalar : notnull { diff --git a/src/Algebra/FieldStructures/ComplexFieldStructure.cs b/src/Algebra/FieldStructures/ComplexFieldStructure.cs index 10f545c..4498640 100644 --- a/src/Algebra/FieldStructures/ComplexFieldStructure.cs +++ b/src/Algebra/FieldStructures/ComplexFieldStructure.cs @@ -3,83 +3,53 @@ using Skeleton.Algebra.Extensions; namespace Skeleton.Algebra.FieldStructures; -/// [CustomFieldStructure] public class ComplexFieldStructure : FieldStructure { - /// - /// - /// + public static readonly ComplexFieldStructure Structure = new(); - - /// public override Complex Addition(Complex self, Complex other) => self + other; - - /// public override Complex AdditionUnit => 0d; - - /// public override Complex Multiplication(Complex self, Complex other) => self * other; - - /// public override Complex MultiplicationUnit => 1d; - - /// public override Complex AdditionInverse(Complex self) => -self; - - /// public override Complex MultiplicationInverse(Complex self) => 1d / self; - - /// public override Complex Subtraction(Complex self, Complex other) => self - other; - - /// public override Complex Division(Complex self, Complex other) => self / other; - - /// public override bool IsEqualApprox(Complex self, Complex other, double? absTol = null, double? relTol = null) - => RealFieldStructure.Structure.IsEqualApprox(self.Real, other.Real, absTol, relTol) && RealFieldStructure.Structure.IsEqualApprox(self.Imaginary, other.Imaginary, absTol, relTol); - - /// + public override Complex Fix(Complex x) => base.Fix(new Complex( RealFieldStructure.Structure.Fix(x.Real), RealFieldStructure.Structure.Fix(x.Imaginary) )); - - /// + public override Complex Conj(Complex self) => Complex.Conjugate(self); - /// public override double AsReal(Complex x) => x.Real; - /// public override Complex FromReal(double x) => x; private const string PlusSign = "+"; private const string EmptyString = ""; - /// public override string RawRepresentation(Complex x) => RealFieldStructure.Structure.IsEqualApprox(x.Imaginary, 0d) ? RealFieldStructure.Structure.Representation(x.Real) : $"{x.Real}{(x.Imaginary > 0 ? PlusSign : EmptyString)}{x.Imaginary}i"; - - /// + public override string RawPythonRepresentation(Complex x) => RealFieldStructure.Structure.IsEqualApprox(x.Imaginary, 0d) ? RealFieldStructure.Structure.Representation(x.Real) : $"{x.Real}{(x.Imaginary > 0 ? PlusSign : EmptyString)}{x.Imaginary}j"; - /// public override string RawCSharpRepresentation(Complex x) => RealFieldStructure.Structure.IsEqualApprox(x.Imaginary, 0d) ? RealFieldStructure.Structure.Representation(x.Real) : $"{x.Real}{(x.Imaginary >= 0 ? PlusSign : EmptyString)}{x.Imaginary}*AlgebraConstant.I"; - /// public override string DumpString(Complex x) => "" + RealFieldStructure.Structure.DumpString(x.Real) + @@ -87,7 +57,6 @@ public class ComplexFieldStructure : FieldStructure RealFieldStructure.Structure.DumpString(x.Imaginary) + ""; - /// public override Complex Resolve(string dumpString) { double[] restored = dumpString @@ -99,26 +68,19 @@ public class ComplexFieldStructure : FieldStructure return new Complex(restored[0], restored[1]); } - /// public override double MaxError(Complex a) => Math.Max(Math.Abs(a.Real), Math.Abs(a.Imaginary)); - - /// + public override Complex ComplexCast(Complex a) => a; - - /// + public override Complex RealMul(Complex a, double b) => a * b; - /// public override Complex SquareRoot(Complex a) => Complex.Sqrt(a); - - /// + public override Complex FromComplex(Complex a) => a; - /// public override Complex Log(Complex x) => Complex.Log(x); - /// public override Complex Exp(Complex x) => Complex.Exp(x); public override Complex Sign(Complex x) diff --git a/src/Algebra/FieldStructures/FieldStructure.cs b/src/Algebra/FieldStructures/FieldStructure.cs index 9b512db..8294be8 100644 --- a/src/Algebra/FieldStructures/FieldStructure.cs +++ b/src/Algebra/FieldStructures/FieldStructure.cs @@ -1,120 +1,50 @@ using System.Numerics; -using System.Reflection.Metadata; using Skeleton.Algebra.Extensions; using Skeleton.DataStructure.Packs; namespace Skeleton.Algebra.FieldStructures; -/// -/// operations / structure of the field -/// + public abstract class FieldStructure { } -/// public abstract class FieldStructure : FieldStructure { - /// - /// return the singleton base on type - /// - /// public static FieldStructure Dispatch() { return FieldStructureRegistry.GetOperation(); } - - /// - /// addition in field - /// - /// - /// - /// + public abstract TScalar Addition(TScalar self, TScalar other); - /// - /// addition unit of the field
- /// a + unit = a for any a in field - ///
+ public abstract TScalar AdditionUnit { get; } - /// - /// multiplication in field - /// - /// - /// - /// + public abstract TScalar Multiplication(TScalar self, TScalar other); - /// - /// multiplication unit of the field
- /// unit * a = a for any a in the field except the addition unit - ///
+ public abstract TScalar MultiplicationUnit { get; } - /// - /// inverse of element under addition
- /// a + AddInv(a) = unit(addition) for any a in field - ///
- /// - /// + public abstract TScalar AdditionInverse(TScalar self); - /// - /// inverse of element under multiplication
- /// a * MulInv(a) = unit(multiplication) for any a in field except the addition unit - ///
- /// - /// + public abstract TScalar MultiplicationInverse(TScalar self); - /// - /// a + AddInv(b) - /// - /// - /// - /// + public virtual TScalar Subtraction(TScalar self, TScalar other) => Addition(self, AdditionInverse(other)); - - /// - /// a * MulInv(b) - /// - /// - /// - /// + public virtual TScalar Division(TScalar self, TScalar other) => Multiplication(self, MultiplicationInverse(other)); - /// - /// conjugate of the scalar - /// - /// - /// public abstract TScalar Conj(TScalar self); - /// - /// if two elements are close to each other in the field - /// - /// - /// - /// - /// - /// + public abstract bool IsEqualApprox(TScalar self, TScalar other, double? absTol=null, double? relTol = null); - /// - /// tolerance to check if two scalars are close - /// public double AbsoluteTolerance { get; set; } = 1E-8d; - /// - /// - /// public double RelativeTolerance { get; set; } = 1E-5d; - /// - /// if calculation in field won't introduce error, override this and leave it empty - /// otherwise, provide method to reduce the error here - /// - /// - /// public virtual TScalar Fix(TScalar x) { if (IsEqualApprox(x, AdditionUnit)) @@ -124,132 +54,40 @@ public abstract class FieldStructure : FieldStructure return x; } - /// - /// homomorphism from scalar field to real
- /// ignore if not applicable - ///
- /// - /// + public virtual double AsReal(TScalar x) => IsEqualApprox(x, AdditionUnit) ? 0 : 1; - /// - /// conjugated square xx* when field is real/complex - /// - /// - /// + public double ConjX2(TScalar x) => AsReal(Multiplication(x, Conj(x))); - - /// - /// homomorphism from real to scalar
- /// ignore if not applicable - ///
- /// - /// - public virtual TScalar FromReal(double x) => x.IsEqualApprox(0) ? AdditionUnit : MultiplicationUnit; - /// - /// readable string representation of data - /// - /// - /// - public string Representation(TScalar x) => RawRepresentation(Fix(x)); - - /// - /// representation of the original data, without fix - /// - /// - /// - public virtual string RawRepresentation(TScalar x) => $"{x}"; - - /// - /// code to construct object in python - /// - /// - /// - public string PythonRepresentation(TScalar x) => RawPythonRepresentation(Fix(x)); - - /// - /// code to construct scalar object in python
- /// ignore if not applicable - ///
- /// - /// - public virtual string RawPythonRepresentation(TScalar x) => ""; - /// - /// code to construct the object in c# - /// - /// - /// - public string CSharpRepresentation(TScalar x) => RawCSharpRepresentation(Fix(x)); - /// - /// C# string for the original data - /// - /// - /// - public abstract string RawCSharpRepresentation(TScalar x); - - /// - /// dump the object as string which can be restored exactly
- /// ignore if not applicable
- /// if override can not contain following string as substring
- /// <D> </D> <C> </C> <CSPLIT/>
- /// <VECTOR> <VSPLIT/> </VECTOR>
- /// <MATRIX> <MSPLIT/> </MSPLIT> - ///
- /// - /// - public virtual string DumpString(TScalar x) => ""; - - /// - /// method to restore a value from dump string
- /// ignore if not applicable - ///
- /// - /// - public virtual TScalar Resolve(string dumpString) => AdditionUnit; - /// - /// max diff from zero - /// - /// - /// - public abstract double MaxError(TScalar a); - - /// - /// homomorphism from field to complex
- /// ignore if not applicable - ///
- /// - /// - public virtual Complex ComplexCast(TScalar a) => IsEqualApprox(a, AdditionUnit) ? 0 : 1; + public virtual TScalar FromReal(double x) => x.IsEqualApprox(0) ? AdditionUnit : MultiplicationUnit; + + public string Representation(TScalar x) => RawRepresentation(Fix(x)); + + public virtual string RawRepresentation(TScalar x) => $"{x}"; + + public string PythonRepresentation(TScalar x) => RawPythonRepresentation(Fix(x)); + + public virtual string RawPythonRepresentation(TScalar x) => ""; + + public string CSharpRepresentation(TScalar x) => RawCSharpRepresentation(Fix(x)); + + public abstract string RawCSharpRepresentation(TScalar x); + + public virtual string DumpString(TScalar x) => ""; + + public virtual TScalar Resolve(string dumpString) => AdditionUnit; + + public abstract double MaxError(TScalar a); + + public virtual Complex ComplexCast(TScalar a) => IsEqualApprox(a, AdditionUnit) ? 0 : 1; - /// - /// K x R -> K
- /// ignore if not applicable - ///
- /// - /// - /// public virtual TScalar RealMul(TScalar a, double b) => a; - - /// - /// for y in field, find x such that x*x = y - /// - /// - /// + public abstract TScalar SquareRoot(TScalar a); - /// - /// Absolute value - /// - /// - /// + public TScalar Abs(TScalar a) => SquareRoot(Multiplication(a, Conj(a))); - /// - /// a x^2 + b x + c = unit(add) - /// - /// - /// - /// - /// + public QuadraticRoots QuadraticRoot(TScalar a, TScalar b, TScalar c) { TScalar invB = AdditionInverse(b); @@ -262,12 +100,7 @@ public abstract class FieldStructure : FieldStructure TScalar x2 = Division(Subtraction(invB, SquareRoot(Subtraction(b2, acx4))), ax2); return new QuadraticRoots(x1, x2); } - - /// - /// - /// - /// - /// + public virtual TScalar Sign(TScalar x) => MultiplicationUnit; internal TScalar WilkinsonShift(TScalar a11, TScalar a12, TScalar a21, TScalar a22) @@ -328,26 +161,10 @@ public abstract class FieldStructure : FieldStructure ); } - /// - /// homomorphism from complex to this field - /// - /// - /// public virtual TScalar FromComplex(Complex a) => AdditionUnit; - - - /// - /// log of the element in the field - /// - /// - /// + public virtual TScalar Log(TScalar x) => AdditionUnit; - - /// - /// exp of the element in the field - /// - /// - /// + public virtual TScalar Exp(TScalar x) => MultiplicationUnit; } diff --git a/src/Algebra/FieldStructures/FieldStructureRegistry.cs b/src/Algebra/FieldStructures/FieldStructureRegistry.cs index a8c0e37..4816f42 100644 --- a/src/Algebra/FieldStructures/FieldStructureRegistry.cs +++ b/src/Algebra/FieldStructures/FieldStructureRegistry.cs @@ -1,15 +1,8 @@ namespace Skeleton.Algebra.FieldStructures; -/// -/// -/// public static class FieldStructureRegistry { - /// - /// Register customer field structure - /// - /// - /// + public static void Register(FieldStructure structure) => FieldStructureRegistry.Structure = structure; diff --git a/src/DataStructure/Link/Link.cs b/src/DataStructure/Link/Link.cs index a5cfc97..8f17aa5 100644 --- a/src/DataStructure/Link/Link.cs +++ b/src/DataStructure/Link/Link.cs @@ -2,20 +2,9 @@ using System.Collections; namespace Skeleton.DataStructure.Link; -/// -/// Linked List -/// -/// public class Link : IEnumerable { - /// - /// singleton for default value - /// public static readonly Link Null = new(); - - /// - /// Constructor - /// public Link() { Head = new LinkHead(); @@ -27,35 +16,16 @@ public class Link : IEnumerable Count = 0; } - /// - /// First item - /// public LinkNode First => Head.Next; - - /// - /// Last item - /// + public LinkNode Last => Tail.Previous; - - /// - /// number of items - /// + public int Count { get; set; } - - /// - /// head of linked list - /// + private LinkHead Head { get; } - /// - /// tail of linked list - /// private LinkTail Tail { get; } - - /// - /// iterator in reverse direction - /// - /// + public IEnumerable Backward { get @@ -72,11 +42,7 @@ public class Link : IEnumerable } } } - - /// - /// - /// - /// + public IEnumerator GetEnumerator() { LinkNode iter = Head.Next; @@ -95,11 +61,7 @@ public class Link : IEnumerable { return GetEnumerator(); } - - /// - /// add item next to head - /// - /// + public void AddFirst(TObject obj) { LinkNode node = new LinkNode(obj); @@ -110,11 +72,7 @@ public class Link : IEnumerable Head.Next = node; Count += 1; } - - /// - /// add item before tail - /// - /// + public void AddLast(TObject obj) { LinkNode node = new LinkNode(obj); @@ -125,13 +83,7 @@ public class Link : IEnumerable Tail.Previous = node; Count += 1; } - - /// - /// add item after specific node - /// - /// - /// - /// + public void AddAfter(LinkNode node, TObject obj) { if (node.Parent != this) @@ -144,22 +96,12 @@ public class Link : IEnumerable newNode.Previous = node; Count += 1; } - - /// - /// add item before specific node - /// - /// - /// + public void AddBefore(LinkNode node, TObject obj) { AddAfter(node.Previous, obj); } - - /// - /// - /// - /// - /// + public LinkNode Find(TObject value) { LinkNode iter = Head.Next; @@ -176,13 +118,7 @@ public class Link : IEnumerable return LinkNode.Null; } - - /// - /// find the node by selector - /// - /// - /// - /// + public LinkNode Find(Func selector) { LinkNode iter = Head.Next; @@ -199,12 +135,7 @@ public class Link : IEnumerable return LinkNode.Null; } - - /// - /// remove specific node - /// - /// - /// + public void Remove(LinkNode node) { if (!ReferenceEquals(node.Parent, this)) @@ -218,12 +149,7 @@ public class Link : IEnumerable node.Parent = Null; Count -= 1; } - - /// - /// remove the first item - /// - /// - /// + public TObject RemoveFirst() { LinkNode res = First; @@ -233,11 +159,7 @@ public class Link : IEnumerable Remove(res); return resValue; } - /// - /// remove the last item - /// - /// - /// + public TObject RemoveLast() { LinkNode res = Last; diff --git a/src/Utils/RandomEngines/Normal.cs b/src/Utils/RandomEngines/Normal.cs index 07e0a4e..66e2b30 100644 --- a/src/Utils/RandomEngines/Normal.cs +++ b/src/Utils/RandomEngines/Normal.cs @@ -1,16 +1,10 @@ namespace Skeleton.Utils.RandomEngines; -/// -/// public static class Normal { - /// - /// + public static double? ExNormal; - /// - /// - /// public static double Get() { if (ExNormal != null) diff --git a/src/Utils/RandomEngines/RandomSource.cs b/src/Utils/RandomEngines/RandomSource.cs index fe116e3..8efca4d 100644 --- a/src/Utils/RandomEngines/RandomSource.cs +++ b/src/Utils/RandomEngines/RandomSource.cs @@ -1,13 +1,7 @@ -using Skeleton.DataStructure; - namespace Skeleton.Utils.RandomEngines; -/// -/// public static class RandomSource { - /// - /// public static ThreadLocal Rnd = new(() => new Random()); public static void SetSeed(int seed) @@ -15,9 +9,6 @@ public static class RandomSource Rnd.Value = new Random(seed); } - /// - /// - /// public static double Get() { return Rnd.Value.NextDouble();