diff --git a/README.md b/README.md new file mode 100644 index 0000000..87834e9 --- /dev/null +++ b/README.md @@ -0,0 +1,151 @@ +# Skeleton Framework + +Skeleton is a computational library built with .NET 8.0, primarily designed to handle special complex matrices of small sizes (like 3x3) but supports matrices of any dimension over any custom field. +Other modules such as morphisms, groups, rings, and fields are under development. + +## Features + +- Vector and Matrix operations +- Vector spaces and Affine space operations +- Analytic functions, Polynomials, and Bivariant functions +- Sampling of Special Matrices + +## Planned Features + +- Statistics: Hypothesis testing +- Algebra: Group and Ring operations +- Auto-registration for custom fields and dimensions + +## Supported Matrix Types + +- General Matrix: `CategoryOf.OnField.FMatrix` +- Normal Matrix: `CategoryOf.OnField.FNormalMatrix` +- Diagonal Matrix: `CategoryOf.OnField.FDiagonalMatrix` +- Unitary Matrix: `CategoryOf.OnField.FDiagonalMatrix` +- Special Unitary Matrix: `CategoryOf.OnField.FSpecialUnitaryMatrix` + +**Note**: The types `CategoryOf<>.OnField<>.FLieUnitaryMatrix` and `CategoryOf<>.OnField<>.FSpecialLieUnitaryMatrix` may not represent matrices as their names imply. Instead, they denote congruence classes of \( \{ \log(x) \ | \ x \in SU \} \), where all eigenvalues lie within \((-π, π)\). +Be cautious when using `FSpecialUnitaryMatrix.Log`, as this may not behave as the general logarithm function. + +## Requirements + +- .NET SDK version: 8.0.0 + +## Installation + +Clone the repository: +```bash +git clone +cd Skeleton +dotnet restore +dotnet build +``` +Alternatively, add the NuGet source: + +```bash +dotnet nuget add source --name hangman-lab https://git.hangman-lab.top/api/packages/hzhang/nuget/index.json +``` + + +## Usage +### Example Usage +You can use tensors (vectors and matrices) with predefined dimensions (e.g., 2, 3, 4) and predefined fields (e.g., double, complex): + +```csharp + +using Skeleton.Algebra.DimensionProviders; +using Skeleton.Algebra; +using System.Numerics; + +var c2_1 = new CategoryOf.OnField.FVector(1, 1); +var c2_2 = c2_1 * 0.5d; +var c2_3 = c2_1 + c2_2; + +var m3_r = new CategoryOf.OnField.FMatrix( +1d, 0d, 0d, +0d, 1d, 0d, +0d, 0d, 1d +); +``` +### Simplifying with Aliases +Declare aliases in a Usings.cs file: + +```csharp +global using C2 = Skeleton.Algebra.CategoryOf.OnField.FVector; +global using C3 = Skeleton.Algebra.CategoryOf.OnField.FVector; +global using C4 = Skeleton.Algebra.CategoryOf.OnField.FVector; + +global using R2 = Skeleton.Algebra.CategoryOf.OnField.FVector; +global using R3 = Skeleton.Algebra.CategoryOf.OnField.FVector; +global using R4 = Skeleton.Algebra.CategoryOf.OnField.FVector; + +global using SU2 = Skeleton.Algebra.CategoryOf.FSpecialUnitaryMatrix; +global using SU3 = Skeleton.Algebra.CategoryOf.FSpecialUnitaryMatrix; +global using SU4 = Skeleton.Algebra.CategoryOf.FSpecialUnitaryMatrix; + +``` +Then use the aliases in your code: +```csharp +C2 a = new C2(1, 0); +C2 b = a * 0.5d; + +``` +### Custom Dimension and Field +#### Custom Dimension +To define a custom dimension, declare an interface like this: +```csharp +using Skeleton.Algebra.DimensionProviders; +[OfDimension(10)] +public interface IDimX +{ + +} +``` +#### Custom Field +To use a custom field, implement a FieldStructure class with the following required methods: +```csharp +class CustomFieldStructure : FieldStructure +{ + abstract TScalar Addition(TScalar self, TScalar other); + abstract TScalar AdditionUnit { get; } + abstract TScalar Multiplication(TScalar self, TScalar other); + abstract TScalar MultiplicationUnit { get; } + abstract TScalar AdditionInverse(TScalar self); + abstract TScalar MultiplicationInverse(TScalar self); + abstract TScalar Conj(TScalar self); + abstract bool IsEqualApprox(TScalar self, TScalar other, double? absTol=null, double? relTol = null); + abstract string RawCSharpRepresentation(TScalar x); + abstract double MaxError(TScalar a); + abstract TScalar SquareRoot(TScalar a); + +} +``` +Additionally, you can optionally implement the following methods for extended functionality: +```csharp +virtual TScalar Log(TScalar x); +virtual TScalar Exp(TScalar x); +virtual TScalar FromComplex(Complex a); +virtual TScalar RealMul(TScalar a, double b); +virtual Complex ComplexCast(TScalar a); +virtual TScalar Resolve(string dumpString); +virtual string DumpString(TScalar x); +virtual string RawPythonRepresentation(TScalar x); +virtual string RawRepresentation(TScalar x); +virtual TScalar FromReal(double x); +virtual double AsReal(TScalar x); +virtual TScalar Fix(TScalar x); +virtual TScalar Division(TScalar self, TScalar other); +virtual TScalar Subtraction(TScalar self, TScalar other); + +``` + +Finally, register the custom field: +```csharp +ScalarFieldStructureProvider.Register(new CustomFieldStructure()); +``` +## License +[MIT][license] © [hzhang][author] + + +[author]: https://hangman-lab.top +[license]: license \ No newline at end of file diff --git a/Skeleton.csproj b/Skeleton.csproj index 5788700..7782305 100644 --- a/Skeleton.csproj +++ b/Skeleton.csproj @@ -4,10 +4,13 @@ net8.0 enable disable - 0.0.5 + 0.0.6 hzhang true + hzhang + https://git.hangman-lab.top/hzhang/Skeleton + https://git.hangman-lab.top/hzhang/Skeleton diff --git a/license b/license new file mode 100644 index 0000000..d78261e --- /dev/null +++ b/license @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) hzhang + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/src/Algebra.zip b/src/Algebra.zip deleted file mode 100644 index 7eb0818..0000000 Binary files a/src/Algebra.zip and /dev/null differ