From 3573cd77daa1c8a6321d9d292085a30a285a57a3 Mon Sep 17 00:00:00 2001 From: Clinton Ingram Date: Mon, 20 Aug 2018 04:09:45 -0700 Subject: [PATCH] Normalize whitespace/indentation Commit migrated from https://github.com/dotnet/coreclr/commit/04d9b557ef8b7c60a1194d062c7c2ee6e41fd8c1 --- .../src/System/Numerics/ConstantHelper.tt | 5 +- .../src/System/Numerics/Vector.cs | 328 ++++++++-------- .../src/System/Numerics/Vector.tt | 431 ++++++++++++--------- 3 files changed, 407 insertions(+), 357 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/ConstantHelper.tt b/src/libraries/System.Private.CoreLib/src/System/Numerics/ConstantHelper.tt index 5566c40..dd823ab 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/ConstantHelper.tt +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/ConstantHelper.tt @@ -20,7 +20,8 @@ namespace System.Numerics { internal class ConstantHelper { -<# foreach (var type in supportedTypes) +<# + foreach (var type in supportedTypes) { string hexValue = "0x" + new string('f', Marshal.SizeOf(type) * 2); #> @@ -57,4 +58,4 @@ namespace System.Numerics return type; } } -#> \ No newline at end of file +#> diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs index 0cae8ef..31a9114 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs @@ -100,7 +100,7 @@ namespace System.Numerics internal byte _byte; } - // Calculates the size of this struct in bytes, by computing the offset of a field in a structure + // Calculates the size of this struct in bytes, by computing the offset of a field in a structure private static unsafe int InitializeCount() { VectorSizeHelper vsh; @@ -5182,21 +5182,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; byte* retPtr = stackalloc byte[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (byte)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (byte)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (byte)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (byte)high[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5209,21 +5209,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; ushort* retPtr = stackalloc ushort[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (ushort)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (ushort)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (ushort)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (ushort)high[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5236,21 +5236,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; uint* retPtr = stackalloc uint[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (uint)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (uint)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (uint)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (uint)high[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5263,21 +5263,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; sbyte* retPtr = stackalloc sbyte[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (sbyte)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (sbyte)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (sbyte)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (sbyte)high[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5289,21 +5289,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; short* retPtr = stackalloc short[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (short)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (short)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (short)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (short)high[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5315,21 +5315,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; int* retPtr = stackalloc int[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (int)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (int)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (int)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (int)high[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5341,21 +5341,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; float* retPtr = stackalloc float[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (float)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (float)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (float)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (float)high[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } #endregion Widen/Narrow @@ -5369,17 +5369,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToSingle(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; float* retPtr = stackalloc float[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (float)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (float)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5391,17 +5391,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToSingle(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; float* retPtr = stackalloc float[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (float)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (float)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5412,17 +5412,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToDouble(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; double* retPtr = stackalloc double[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (double)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (double)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5434,17 +5434,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToDouble(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; double* retPtr = stackalloc double[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (double)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (double)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5455,17 +5455,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToInt32(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; int* retPtr = stackalloc int[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (int)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (int)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5477,17 +5477,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToUInt32(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; uint* retPtr = stackalloc uint[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (uint)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (uint)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5498,17 +5498,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToInt64(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; long* retPtr = stackalloc long[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (long)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (long)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } /// @@ -5520,17 +5520,17 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector ConvertToUInt64(Vector value) { - unchecked - { - int elements = Vector.Count; + unchecked + { + int elements = Vector.Count; ulong* retPtr = stackalloc ulong[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (ulong)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (ulong)value[i]; + } - return new Vector(retPtr); - } + return new Vector(retPtr); + } } #endregion Same-Size Conversion diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.tt b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.tt index cbc9fcf..9eda34d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.tt +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.tt @@ -105,7 +105,7 @@ namespace System.Numerics internal byte _byte; } - // Calculates the size of this struct in bytes, by computing the offset of a field in a structure + // Calculates the size of this struct in bytes, by computing the offset of a field in a structure private static unsafe int InitializeCount() { VectorSizeHelper vsh; @@ -114,15 +114,16 @@ namespace System.Numerics int vectorSizeInBytes = (int)(byteBase - vectorBase); int typeSizeInBytes = -1; -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { typeSizeInBytes = sizeof(<#=typeAliases[type]#>); } <# - } + } #> else { @@ -143,7 +144,8 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -157,27 +159,28 @@ namespace System.Numerics } } <# - } + } #> } else { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < totalSize / Marshal.SizeOf(type); g++) - { + for (int g = 0; g < totalSize / Marshal.SizeOf(type); g++) + { #> <#=GetRegisterFieldName(type, g)#> = (<#=typeAliases[type]#>)(object)value; <# - } + } #> } <# - } + } #> } } @@ -207,7 +210,8 @@ namespace System.Numerics if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -221,12 +225,13 @@ namespace System.Numerics } } <# - } + } #> } else { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -234,17 +239,17 @@ namespace System.Numerics fixed (<#=typeAliases[type]#>* basePtr = &this.<#=GetRegisterFieldName(type, 0)#>) { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> *(basePtr + <#=g#>) = (<#=typeAliases[type]#>)(object)values[<#=g#> + index]; <# - } + } #> } } <# - } + } #> } } @@ -258,8 +263,9 @@ namespace System.Numerics internal unsafe Vector(void* dataPointer, int offset) : this() { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -274,7 +280,7 @@ namespace System.Numerics } } <# - } + } #> else { @@ -351,8 +357,9 @@ namespace System.Numerics if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -366,13 +373,14 @@ namespace System.Numerics } } <# - } + } #> } else { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -380,17 +388,17 @@ namespace System.Numerics fixed (<#=typeAliases[type]#>* destinationBase = <#=type.Name.ToLowerInvariant()#>Array) { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> destinationBase[startIndex + <#=g#>] = this.<#=GetRegisterFieldName(type, g)#>; <# - } + } #> } } <# - } + } #> } } @@ -407,7 +415,8 @@ namespace System.Numerics { throw new IndexOutOfRangeException(SR.Format(SR.Arg_ArgumentOutOfRangeException, index)); } -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -463,36 +472,37 @@ namespace System.Numerics } else { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> <# - if (g == 0) - { + if (g == 0) + { #> this.<#=GetRegisterFieldName(type, g)#> == other.<#=GetRegisterFieldName(type, g)#> <# - } - else - { + } + else + { #> && this.<#=GetRegisterFieldName(type, g)#> == other.<#=GetRegisterFieldName(type, g)#><#=(g == (GetNumFields(type, totalSize) -1)) ? ";" : ""#> <# - } + } #> <# - } + } #> } <# - } + } #> else { @@ -511,7 +521,8 @@ namespace System.Numerics if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -523,7 +534,7 @@ namespace System.Numerics return hash; } <# - } + } #> else { @@ -532,23 +543,24 @@ namespace System.Numerics } else { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> hash = HashHelpers.Combine(hash, this.<#=GetRegisterFieldName(type, g)#>.GetHashCode()); <# - } + } #> return hash; } <# - } + } #> else { @@ -614,8 +626,9 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -627,7 +640,7 @@ namespace System.Numerics return new Vector(dataPtr); } <# - } + } #> else { @@ -637,8 +650,9 @@ namespace System.Numerics else { Vector sum = new Vector(); -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -652,7 +666,7 @@ namespace System.Numerics #> } <# - } + } #> return sum; } @@ -671,8 +685,9 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -684,7 +699,7 @@ namespace System.Numerics return new Vector(dataPtr); } <# - } + } #> else { @@ -694,22 +709,23 @@ namespace System.Numerics else { Vector difference = new Vector(); -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> difference.<#= GetRegisterFieldName(type, g) #> = (<#=typeAliases[type]#>)(left.<#= GetRegisterFieldName(type, g) #> - right.<#= GetRegisterFieldName(type, g) #>); <# - } + } #> } <# - } + } #> return difference; } @@ -729,8 +745,9 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -742,7 +759,7 @@ namespace System.Numerics return new Vector(dataPtr); } <# - } + } #> else { @@ -752,18 +769,19 @@ namespace System.Numerics else { Vector product = new Vector(); -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> product.<#= GetRegisterFieldName(type, g) #> = (<#=typeAliases[type]#>)(left.<#= GetRegisterFieldName(type, g) #> * right.<#= GetRegisterFieldName(type, g) #>); <# - } + } #> } <# @@ -792,18 +810,19 @@ namespace System.Numerics else { Vector product = new Vector(); -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> product.<#= GetRegisterFieldName(type, g) #> = (<#=typeAliases[type]#>)(value.<#= GetRegisterFieldName(type, g) #> * (<#=typeAliases[type]#>)(object)factor); <# - } + } #> } <# @@ -832,18 +851,19 @@ namespace System.Numerics else { Vector product = new Vector(); -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> product.<#= GetRegisterFieldName(type, g) #> = (<#=typeAliases[type]#>)(value.<#= GetRegisterFieldName(type, g) #> * (<#=typeAliases[type]#>)(object)factor); <# - } + } #> } <# @@ -867,8 +887,9 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -880,7 +901,7 @@ namespace System.Numerics return new Vector(dataPtr); } <# - } + } #> else { @@ -890,18 +911,19 @@ namespace System.Numerics else { Vector quotient = new Vector(); -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> quotient.<#= GetRegisterFieldName(type, g) #> = (<#=typeAliases[type]#>)(left.<#= GetRegisterFieldName(type, g) #> / right.<#= GetRegisterFieldName(type, g) #>); <# - } + } #> } <# @@ -1056,7 +1078,8 @@ namespace System.Numerics #endregion Logical Operators #region Conversions -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> /// @@ -1090,7 +1113,8 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -1113,23 +1137,24 @@ namespace System.Numerics else { Register register = new Register(); -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> <#= GetRegisterFieldName(type, g) #> = left.<#= GetRegisterFieldName(type, g) #> == right.<#= GetRegisterFieldName(type, g) #> ? ConstantHelper.Get<#=type.Name#>WithAllBitsSet() : (<#=typeAliases[type]#>)0; <# - } + } #> return new Vector(ref register); } <# - } + } #> else { @@ -1144,7 +1169,8 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -1167,8 +1193,9 @@ namespace System.Numerics else { Register register = new Register(); -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -1183,7 +1210,7 @@ namespace System.Numerics return new Vector(ref register); } <# - } + } #> else { @@ -1198,7 +1225,8 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -1221,23 +1249,24 @@ namespace System.Numerics else { Register register = new Register(); -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> <#= GetRegisterFieldName(type, g) #> = left.<#= GetRegisterFieldName(type, g) #> > right.<#= GetRegisterFieldName(type, g) #> ? ConstantHelper.Get<#=type.Name#>WithAllBitsSet() : (<#=typeAliases[type]#>)0; <# - } + } #> return new Vector(ref register); } <# - } + } #> else { @@ -1339,7 +1368,8 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -1362,23 +1392,24 @@ namespace System.Numerics else { Vector vec = new Vector(); -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> vec.<#=GetRegisterFieldName(type, g)#> = left.<#=GetRegisterFieldName(type, g)#> < right.<#=GetRegisterFieldName(type, g)#> ? left.<#=GetRegisterFieldName(type, g)#> : right.<#=GetRegisterFieldName(type, g)#>; <# - } + } #> return vec; } <# - } + } #> else { @@ -1392,7 +1423,8 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) +<# + foreach (Type type in supportedTypes) { #> <#=GenerateIfStatementHeader(type)#> @@ -1415,23 +1447,24 @@ namespace System.Numerics else { Vector vec = new Vector(); -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> vec.<#=GetRegisterFieldName(type, g)#> = left.<#=GetRegisterFieldName(type, g)#> > right.<#=GetRegisterFieldName(type, g)#> ? left.<#=GetRegisterFieldName(type, g)#> : right.<#=GetRegisterFieldName(type, g)#>; <# - } + } #> return vec; } <# - } + } #> else { @@ -1454,24 +1487,25 @@ namespace System.Numerics } else { -<# foreach (Type type in supportedTypes) - { - #> +<# + foreach (Type type in supportedTypes) + { +#> <#=GenerateIfStatementHeader(type)#> { <#=typeAliases[type]#> product = 0; <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> product += (<#=typeAliases[type]#>)(left.<#=GetRegisterFieldName(type, g)#> * right.<#=GetRegisterFieldName(type, g)#>); <# - } + } #> return (T)(object)product; } <# - } + } #> else { @@ -1485,8 +1519,9 @@ namespace System.Numerics { if (Vector.IsHardwareAccelerated) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -1498,7 +1533,7 @@ namespace System.Numerics return new Vector(dataPtr); } <# - } + } #> else { @@ -1507,23 +1542,24 @@ namespace System.Numerics } else { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { <# - for (int g = 0; g < GetNumFields(type, totalSize); g++) - { + for (int g = 0; g < GetNumFields(type, totalSize); g++) + { #> value.<#=GetRegisterFieldName(type, g)#> = (<#=typeAliases[type]#>)Math.Sqrt(value.<#=GetRegisterFieldName(type, g)#>); <# - } + } #> return value; } <# - } + } #> else { @@ -1537,15 +1573,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static bool ScalarEquals(T left, T right) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (<#=typeAliases[type]#>)(object)left == (<#=typeAliases[type]#>)(object)right; } <# - } + } #> else { @@ -1556,15 +1593,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static bool ScalarLessThan(T left, T right) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (<#=typeAliases[type]#>)(object)left < (<#=typeAliases[type]#>)(object)right; } <# - } + } #> else { @@ -1575,15 +1613,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static bool ScalarGreaterThan(T left, T right) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (<#=typeAliases[type]#>)(object)left > (<#=typeAliases[type]#>)(object)right; } <# - } + } #> else { @@ -1594,15 +1633,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarAdd(T left, T right) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (T)(object)unchecked((<#=typeAliases[type]#>)((<#=typeAliases[type]#>)(object)left + (<#=typeAliases[type]#>)(object)right)); } <# - } + } #> else { @@ -1613,15 +1653,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarSubtract(T left, T right) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (T)(object)(<#=typeAliases[type]#>)((<#=typeAliases[type]#>)(object)left - (<#=typeAliases[type]#>)(object)right); } <# - } + } #> else { @@ -1632,15 +1673,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarMultiply(T left, T right) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (T)(object)unchecked((<#=typeAliases[type]#>)((<#=typeAliases[type]#>)(object)left * (<#=typeAliases[type]#>)(object)right)); } <# - } + } #> else { @@ -1651,15 +1693,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarDivide(T left, T right) { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (T)(object)(<#=typeAliases[type]#>)((<#=typeAliases[type]#>)(object)left / (<#=typeAliases[type]#>)(object)right); } <# - } + } #> else { @@ -1670,8 +1713,9 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T GetOneValue() { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { @@ -1679,7 +1723,7 @@ namespace System.Numerics return (T)(object)value; } <# - } + } #> else { @@ -1690,15 +1734,16 @@ namespace System.Numerics [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T GetAllBitsSetValue() { -<# foreach (Type type in supportedTypes) - { +<# + foreach (Type type in supportedTypes) + { #> <#=GenerateIfStatementHeader(type)#> { return (T)(object)ConstantHelper.Get<#=type.Name#>WithAllBitsSet(); } <# - } + } #> else { @@ -1712,7 +1757,8 @@ namespace System.Numerics public static partial class Vector { #region Widen/Narrow -<# foreach (Type type in WidenableTypes) +<# + foreach (Type type in WidenableTypes) { Type widenTarget = GetWidenTarget(type); #> @@ -1751,8 +1797,8 @@ namespace System.Numerics <# } -#> -<# foreach (Type narrowSource in NarrowableTypes) + + foreach (Type narrowSource in NarrowableTypes) { Type narrowTarget = GetNarrowTarget(narrowSource); #> @@ -1773,21 +1819,21 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector<<#=typeAliases[narrowTarget]#>> Narrow(Vector<<#=typeAliases[narrowSource]#>> low, Vector<<#=typeAliases[narrowSource]#>> high) { - unchecked - { - int elements = Vector<<#=typeAliases[narrowTarget]#>>.Count; + unchecked + { + int elements = Vector<<#=typeAliases[narrowTarget]#>>.Count; <#=typeAliases[narrowTarget]#>* retPtr = stackalloc <#=typeAliases[narrowTarget]#>[elements]; - for (int i = 0; i < elements / 2; i++) - { - retPtr[i] = (<#=typeAliases[narrowTarget]#>)low[i]; - } - for (int i = 0; i < elements / 2; i++) - { - retPtr[i + (elements / 2)] = (<#=typeAliases[narrowTarget]#>)high[i]; - } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i] = (<#=typeAliases[narrowTarget]#>)low[i]; + } + for (int i = 0; i < elements / 2; i++) + { + retPtr[i + (elements / 2)] = (<#=typeAliases[narrowTarget]#>)high[i]; + } - return new Vector<<#=typeAliases[narrowTarget]#>>(retPtr); - } + return new Vector<<#=typeAliases[narrowTarget]#>>(retPtr); + } } <# @@ -1796,7 +1842,8 @@ namespace System.Numerics #endregion Widen/Narrow #region Same-Size Conversion -<# foreach (var pair in SameSizeConversionPairs) +<# + foreach (var pair in SameSizeConversionPairs) { #> /// @@ -1815,20 +1862,22 @@ namespace System.Numerics [Intrinsic] public static unsafe Vector<<#=typeAliases[pair.Value]#>> ConvertTo<#=pair.Value.Name#>(Vector<<#=typeAliases[pair.Key]#>> value) { - unchecked - { - int elements = Vector<<#=typeAliases[pair.Value]#>>.Count; + unchecked + { + int elements = Vector<<#=typeAliases[pair.Value]#>>.Count; <#=typeAliases[pair.Value]#>* retPtr = stackalloc <#=typeAliases[pair.Value]#>[elements]; - for (int i = 0; i < elements; i++) - { - retPtr[i] = (<#=typeAliases[pair.Value]#>)value[i]; - } + for (int i = 0; i < elements; i++) + { + retPtr[i] = (<#=typeAliases[pair.Value]#>)value[i]; + } - return new Vector<<#=typeAliases[pair.Value]#>>(retPtr); - } + return new Vector<<#=typeAliases[pair.Value]#>>(retPtr); + } } -<# } #> +<# + } +#> #endregion Same-Size Conversion } } -- 2.7.4