diff --git a/StgSharp.Common/Mathematics/Linear/ElementType.cs b/StgSharp.Common/Mathematics/Linear/ElementType.cs index 16ad96db..11b2587d 100644 --- a/StgSharp.Common/Mathematics/Linear/ElementType.cs +++ b/StgSharp.Common/Mathematics/Linear/ElementType.cs @@ -1,9 +1,9 @@ -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // ----------------------------------------------------------------------- // file="ElementType" // Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. All rights reserved. +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -25,12 +25,6 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace StgSharp.Mathematics.Numeric { public enum MatrixElementType : int diff --git a/StgSharp.Common/State/IState.cs b/StgSharp.Common/State/ISimpleStateMachine.cs similarity index 73% rename from StgSharp.Common/State/IState.cs rename to StgSharp.Common/State/ISimpleStateMachine.cs index 788c9995..b022a65a 100644 --- a/StgSharp.Common/State/IState.cs +++ b/StgSharp.Common/State/ISimpleStateMachine.cs @@ -1,9 +1,9 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="IState" +// file="ISimpleStateMachine" // Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. All rights reserved. +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -33,5 +33,19 @@ using System.Threading.Tasks; namespace StgSharp.State { - public interface IState { } + public interface ISimpleStateMachine + where TStateNode: ISimpleStateMachineNode + where TStateLabel: unmanaged, Enum + where TStateContext: StateContext + { + + ref readonly TStateNode this[TStateLabel label] { get; } + + ref readonly TStateNode GetCurrentStateNode(); + + void Reset(); + + bool TryMoveNext(TStateContext ctx); + + } } diff --git a/StgSharp.Common/State/IStateMachine.cs b/StgSharp.Common/State/ISimpleStateMachineNode.cs similarity index 79% rename from StgSharp.Common/State/IStateMachine.cs rename to StgSharp.Common/State/ISimpleStateMachineNode.cs index 5084cfec..46473ff6 100644 --- a/StgSharp.Common/State/IStateMachine.cs +++ b/StgSharp.Common/State/ISimpleStateMachineNode.cs @@ -1,9 +1,9 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="IStateMachine" +// file="ISimpleStateMachineNode" // Project: StgSharp -// AuthorGroup: Nitload -// Copyright (c) Nitload. All rights reserved. +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -33,14 +33,13 @@ using System.Threading.Tasks; namespace StgSharp.State { - public interface IStateMachine where TState: IState + public interface ISimpleStateMachineNode where TLabel: unmanaged, Enum + where TStateContext: StateContext { - TState CurrentState { get; set; } + public ICollection AvailableStateLabels { get; } - TState RootState { get; } - - void GotoNextState(TInput input); + bool TryGetNextStateLabel(TLabel label, TStateContext context, out TLabel nextLabel); } } diff --git a/StgSharp.Common/State/StateContext.cs b/StgSharp.Common/State/StateContext.cs new file mode 100644 index 00000000..38d1d62f --- /dev/null +++ b/StgSharp.Common/State/StateContext.cs @@ -0,0 +1,40 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="StateContext.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// 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. +// +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StgSharp.State +{ + public abstract class StateContext { } +} diff --git a/StgSharp.Native/sn-src/m.solve.x86.c b/StgSharp.Native/sn-src/m.solve.x86.c index 9653f7c9..e0776a0e 100644 --- a/StgSharp.Native/sn-src/m.solve.x86.c +++ b/StgSharp.Native/sn-src/m.solve.x86.c @@ -1,4 +1,4 @@ -#include "sn_target.h" +#include "sn_target.h" #if SN_IS_ARCH(SN_ARCH_X86_64) @@ -96,7 +96,7 @@ DECLARE_KER_PROC_LEFT_RIGHT_ANS_SCALAR(float, sse, , try_plu) __m128 _t = _mm_shuffle_ps(_p, _p, _MM_SHUFFLE(2, 3, 0, 1)); \ _p = _mm_add_ps(_p, _t); \ _t = _mm_movehl_ps(_t, _p); \ - ans = _mm_cvt_ss(_mm_add_ss(_p, _t)); \ + ans = _mm_cvtss_f32(_mm_add_ss(_p, _t)); \ } while (0) #define FIND_MAX_F32_SSE(a, b) \ @@ -143,7 +143,7 @@ DECLARE_KER_PROC_RIGHT_ANS(float, sse, , quality) register __m128 min0 = _mm_min_ps(col_shuff_2, col_shuff_3); min = _mm_min_ps(min, min0); - float quality = _mm_cvt_ss(_mm_div_ps(min, _mm_add_ps(max, tiny))); + float quality = _mm_cvtss_f32(_mm_div_ps(min, _mm_add_ps(max, tiny))); ans->f32_x[0].m128_f32[0] = quality; if (quality < quality_threshold) { return; diff --git a/StgSharp.RegularAnalysis/RegularExpression.StateMachine.cs b/StgSharp.RegularAnalysis/RegularExpression.StateMachine.cs new file mode 100644 index 00000000..7ef625ca --- /dev/null +++ b/StgSharp.RegularAnalysis/RegularExpression.StateMachine.cs @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="RegularExpression.StateMachine" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// 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. +// +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +using StgSharp.State; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using System.Threading.Tasks; + +namespace StgSharp.RegularAnalysis +{ + public partial class RegularExpression + { + + private readonly RegularExpressionState _state; + + private class RegularExpressionState : ISimpleStateMachine<, RegularExpressionCases, RegularExpressionStateContext> { } + + private enum RegularExpressionCases { } + + private class RegularExpressionStateContext : StateContext + { + + public int Begin { get; set; } + + public int Position { get; set; } + + public ReadOnlySpan CurrentCharSpan => Source.AsSpan()[Begin..Position]; + + public string Source { get; init; } + + } + + } +} diff --git a/StgSharp.RegularAnalysis/RegularExpression.cs b/StgSharp.RegularAnalysis/RegularExpression.cs new file mode 100644 index 00000000..481bfdc2 --- /dev/null +++ b/StgSharp.RegularAnalysis/RegularExpression.cs @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="RegularExpression.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// 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. +// +// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +namespace StgSharp.RegularAnalysis +{ + public class RegularExpression { } +} diff --git a/StgSharp.RegularAnalysis/StgSharp.RegularAnalysis.csproj b/StgSharp.RegularAnalysis/StgSharp.RegularAnalysis.csproj new file mode 100644 index 00000000..0153ae4b --- /dev/null +++ b/StgSharp.RegularAnalysis/StgSharp.RegularAnalysis.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/StgSharpDevelop.sln b/StgSharpDevelop.sln index e099905a..d7a8640e 100644 --- a/StgSharpDevelop.sln +++ b/StgSharpDevelop.sln @@ -30,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.Model", "StgSharp. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.Mathematics", "StgSharp.Mathematics\StgSharp.Mathematics.csproj", "{9946599F-4D34-440F-840D-F9443D5AEFAA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.RegularAnalysis", "StgSharp.RegularAnalysis\StgSharp.RegularAnalysis.csproj", "{46339874-C6B8-4361-997E-2E30387E51F9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -123,6 +125,18 @@ Global {9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|ARM64.Build.0 = Release|ARM64 {9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.ActiveCfg = Release|x64 {9946599F-4D34-440F-840D-F9443D5AEFAA}.Release|x64.Build.0 = Release|x64 + {46339874-C6B8-4361-997E-2E30387E51F9}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.Debug|ARM64.Build.0 = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.Debug|x64.ActiveCfg = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.Debug|x64.Build.0 = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|ARM64.ActiveCfg = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|ARM64.Build.0 = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|x64.ActiveCfg = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.PerformanceDebug|x64.Build.0 = Debug|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.Release|ARM64.ActiveCfg = Release|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.Release|ARM64.Build.0 = Release|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.Release|x64.ActiveCfg = Release|Any CPU + {46339874-C6B8-4361-997E-2E30387E51F9}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE