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;
[Intrinsic]
public static unsafe Vector<byte> Narrow(Vector<ushort> low, Vector<ushort> high)
{
- unchecked
- {
- int elements = Vector<byte>.Count;
+ unchecked
+ {
+ int elements = Vector<byte>.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<byte>(retPtr);
- }
+ return new Vector<byte>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<ushort> Narrow(Vector<uint> low, Vector<uint> high)
{
- unchecked
- {
- int elements = Vector<ushort>.Count;
+ unchecked
+ {
+ int elements = Vector<ushort>.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<ushort>(retPtr);
- }
+ return new Vector<ushort>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<uint> Narrow(Vector<ulong> low, Vector<ulong> high)
{
- unchecked
- {
- int elements = Vector<uint>.Count;
+ unchecked
+ {
+ int elements = Vector<uint>.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<uint>(retPtr);
- }
+ return new Vector<uint>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<sbyte> Narrow(Vector<short> low, Vector<short> high)
{
- unchecked
- {
- int elements = Vector<sbyte>.Count;
+ unchecked
+ {
+ int elements = Vector<sbyte>.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<sbyte>(retPtr);
- }
+ return new Vector<sbyte>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<short> Narrow(Vector<int> low, Vector<int> high)
{
- unchecked
- {
- int elements = Vector<short>.Count;
+ unchecked
+ {
+ int elements = Vector<short>.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<short>(retPtr);
- }
+ return new Vector<short>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<int> Narrow(Vector<long> low, Vector<long> high)
{
- unchecked
- {
- int elements = Vector<int>.Count;
+ unchecked
+ {
+ int elements = Vector<int>.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<int>(retPtr);
- }
+ return new Vector<int>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<float> Narrow(Vector<double> low, Vector<double> high)
{
- unchecked
- {
- int elements = Vector<float>.Count;
+ unchecked
+ {
+ int elements = Vector<float>.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<float>(retPtr);
- }
+ return new Vector<float>(retPtr);
+ }
}
#endregion Widen/Narrow
[Intrinsic]
public static unsafe Vector<float> ConvertToSingle(Vector<int> value)
{
- unchecked
- {
- int elements = Vector<float>.Count;
+ unchecked
+ {
+ int elements = Vector<float>.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<float>(retPtr);
- }
+ return new Vector<float>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<float> ConvertToSingle(Vector<uint> value)
{
- unchecked
- {
- int elements = Vector<float>.Count;
+ unchecked
+ {
+ int elements = Vector<float>.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<float>(retPtr);
- }
+ return new Vector<float>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<double> ConvertToDouble(Vector<long> value)
{
- unchecked
- {
- int elements = Vector<double>.Count;
+ unchecked
+ {
+ int elements = Vector<double>.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<double>(retPtr);
- }
+ return new Vector<double>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<double> ConvertToDouble(Vector<ulong> value)
{
- unchecked
- {
- int elements = Vector<double>.Count;
+ unchecked
+ {
+ int elements = Vector<double>.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<double>(retPtr);
- }
+ return new Vector<double>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<int> ConvertToInt32(Vector<float> value)
{
- unchecked
- {
- int elements = Vector<int>.Count;
+ unchecked
+ {
+ int elements = Vector<int>.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<int>(retPtr);
- }
+ return new Vector<int>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<uint> ConvertToUInt32(Vector<float> value)
{
- unchecked
- {
- int elements = Vector<uint>.Count;
+ unchecked
+ {
+ int elements = Vector<uint>.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<uint>(retPtr);
- }
+ return new Vector<uint>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<long> ConvertToInt64(Vector<double> value)
{
- unchecked
- {
- int elements = Vector<long>.Count;
+ unchecked
+ {
+ int elements = Vector<long>.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<long>(retPtr);
- }
+ return new Vector<long>(retPtr);
+ }
}
/// <summary>
[Intrinsic]
public static unsafe Vector<ulong> ConvertToUInt64(Vector<double> value)
{
- unchecked
- {
- int elements = Vector<ulong>.Count;
+ unchecked
+ {
+ int elements = Vector<ulong>.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<ulong>(retPtr);
- }
+ return new Vector<ulong>(retPtr);
+ }
}
#endregion Same-Size Conversion
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;
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
{
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
}
}
<#
- }
+ }
#>
}
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;
<#
- }
+ }
#>
}
<#
- }
+ }
#>
}
}
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
}
}
<#
- }
+ }
#>
}
else
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
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];
<#
- }
+ }
#>
}
}
<#
- }
+ }
#>
}
}
internal unsafe Vector(void* dataPointer, int offset)
: this()
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
}
}
<#
- }
+ }
#>
else
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
}
}
<#
- }
+ }
#>
}
else
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
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)#>;
<#
- }
+ }
#>
}
}
<#
- }
+ }
#>
}
}
{
throw new IndexOutOfRangeException(SR.Format(SR.Arg_ArgumentOutOfRangeException, index));
}
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
}
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
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
return hash;
}
<#
- }
+ }
#>
else
{
}
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
{
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
return new Vector<T>(dataPtr);
}
<#
- }
+ }
#>
else
{
else
{
Vector<T> sum = new Vector<T>();
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
#>
}
<#
- }
+ }
#>
return sum;
}
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
return new Vector<T>(dataPtr);
}
<#
- }
+ }
#>
else
{
else
{
Vector<T> difference = new Vector<T>();
-<# 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;
}
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
return new Vector<T>(dataPtr);
}
<#
- }
+ }
#>
else
{
else
{
Vector<T> product = new Vector<T>();
-<# 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) #>);
<#
- }
+ }
#>
}
<#
else
{
Vector<T> product = new Vector<T>();
-<# 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);
<#
- }
+ }
#>
}
<#
else
{
Vector<T> product = new Vector<T>();
-<# 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);
<#
- }
+ }
#>
}
<#
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
return new Vector<T>(dataPtr);
}
<#
- }
+ }
#>
else
{
else
{
Vector<T> quotient = new Vector<T>();
-<# 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) #>);
<#
- }
+ }
#>
}
<#
#endregion Logical Operators
#region Conversions
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
/// <summary>
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
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<T>(ref register);
}
<#
- }
+ }
#>
else
{
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
else
{
Register register = new Register();
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
return new Vector<T>(ref register);
}
<#
- }
+ }
#>
else
{
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
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<T>(ref register);
}
<#
- }
+ }
#>
else
{
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
else
{
Vector<T> vec = new Vector<T>();
-<# 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
{
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
+<#
+ foreach (Type type in supportedTypes)
{
#>
<#=GenerateIfStatementHeader(type)#>
else
{
Vector<T> vec = new Vector<T>();
-<# 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
{
}
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
{
{
if (Vector.IsHardwareAccelerated)
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
return new Vector<T>(dataPtr);
}
<#
- }
+ }
#>
else
{
}
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
{
[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
{
[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
{
[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
{
[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
{
[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
{
[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
{
[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
{
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
private static T GetOneValue()
{
-<# foreach (Type type in supportedTypes)
- {
+<#
+ foreach (Type type in supportedTypes)
+ {
#>
<#=GenerateIfStatementHeader(type)#>
{
return (T)(object)value;
}
<#
- }
+ }
#>
else
{
[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
{
public static partial class Vector
{
#region Widen/Narrow
-<# foreach (Type type in WidenableTypes)
+<#
+ foreach (Type type in WidenableTypes)
{
Type widenTarget = GetWidenTarget(type);
#>
<#
}
-#>
-<# foreach (Type narrowSource in NarrowableTypes)
+
+ foreach (Type narrowSource in NarrowableTypes)
{
Type narrowTarget = GetNarrowTarget(narrowSource);
#>
[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);
+ }
}
<#
#endregion Widen/Narrow
#region Same-Size Conversion
-<# foreach (var pair in SameSizeConversionPairs)
+<#
+ foreach (var pair in SameSizeConversionPairs)
{
#>
/// <summary>
[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
}
}