예제 #1
0
        public static Vector8f Normalize(Vector8us value)
        {
            var absolute = Absolute(value);

            if (absolute <= float.Epsilon)
            {
                return(Vector8us.Zero);
            }
            else
            {
                return((Vector8f)value / absolute);
            }
        }
예제 #2
0
 public static Vector8ul Map(Vector8us value, Func <ushort, ulong> mapping)
 {
     return(new Vector8ul(mapping(value.V0), mapping(value.V1), mapping(value.V2), mapping(value.V3), mapping(value.V4), mapping(value.V5), mapping(value.V6), mapping(value.V7)));
 }
예제 #3
0
 public static float Absolute(Vector8us value)
 {
     return(Functions.Sqrt(AbsoluteSquared(value)));
 }
예제 #4
0
 public static bool Any(Vector8us value, Predicate <ushort> predicate)
 {
     return(predicate(value.V0) || predicate(value.V1) || predicate(value.V2) || predicate(value.V3) || predicate(value.V4) || predicate(value.V5) || predicate(value.V6) || predicate(value.V7));
 }
예제 #5
0
 public static int AbsoluteSquared(Vector8us value)
 {
     return(Dot(value, value));
 }
예제 #6
0
 public static Vector8us Abs(Vector8us value)
 {
     return(new Vector8us(Functions.Abs(value.V0), Functions.Abs(value.V1), Functions.Abs(value.V2), Functions.Abs(value.V3), Functions.Abs(value.V4), Functions.Abs(value.V5), Functions.Abs(value.V6), Functions.Abs(value.V7)));
 }
예제 #7
0
        public static long Pack(int v0Bits, int v1Bits, int v2Bits, int v3Bits, int v4Bits, int v5Bits, int v6Bits, int v7Bits, Vector8us vector)
        {
            Contract.Requires(0 <= v0Bits && v0Bits <= 16, "v0Bits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= v1Bits && v1Bits <= 16, "v1Bits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= v2Bits && v2Bits <= 16, "v2Bits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= v3Bits && v3Bits <= 16, "v3Bits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= v4Bits && v4Bits <= 16, "v4Bits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= v5Bits && v5Bits <= 16, "v5Bits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= v6Bits && v6Bits <= 16, "v6Bits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= v7Bits && v7Bits <= 16, "v7Bits must be between 0 and 16 inclusive.");
            Contract.Requires(v0Bits + v1Bits + v2Bits + v3Bits + v4Bits + v5Bits + v6Bits + v7Bits <= 64);
            ulong v0 = (ulong)(vector.V0) >> (64 - v0Bits);
            ulong v1 = (ulong)(vector.V1) >> (64 - v1Bits);

            v1 <<= v0Bits;
            ulong v2 = (ulong)(vector.V2) >> (64 - v2Bits);

            v2 <<= v0Bits + v1Bits;
            ulong v3 = (ulong)(vector.V3) >> (64 - v3Bits);

            v3 <<= v0Bits + v1Bits + v2Bits;
            ulong v4 = (ulong)(vector.V4) >> (64 - v4Bits);

            v4 <<= v0Bits + v1Bits + v2Bits + v3Bits;
            ulong v5 = (ulong)(vector.V5) >> (64 - v5Bits);

            v5 <<= v0Bits + v1Bits + v2Bits + v3Bits + v4Bits;
            ulong v6 = (ulong)(vector.V6) >> (64 - v6Bits);

            v6 <<= v0Bits + v1Bits + v2Bits + v3Bits + v4Bits + v5Bits;
            ulong v7 = (ulong)(vector.V7) >> (64 - v7Bits);

            v7 <<= v0Bits + v1Bits + v2Bits + v3Bits + v4Bits + v5Bits + v6Bits;
            return((long)(v0 | v1 | v2 | v3 | v4 | v5 | v6 | v7));
        }
예제 #8
0
 /// <summary>
 /// Returns a value that indicates whether two vectors are equal.
 /// </summary>
 /// <param name="left">The first vector to compare.</param>
 /// <param name="right">The second vector to compare.</param>
 /// <returns>true if the left and right are equal; otherwise, false.</returns>
 public static bool Equals(Vector8us left, Vector8us right)
 {
     return(left == right);
 }
예제 #9
0
 public static int Dot(Vector8us left, Vector8us right)
 {
     return(left.V0 * right.V0 + left.V1 * right.V1 + left.V2 * right.V2 + left.V3 * right.V3 + left.V4 * right.V4 + left.V5 * right.V5 + left.V6 * right.V6 + left.V7 * right.V7);
 }
예제 #10
0
 /// <summary>
 /// Returns the product of a vector and scalar.
 /// </summary>
 /// <param name="vector">The vector to multiply.</param>
 /// <param name="scalar">The scalar to multiply.</param>
 /// <returns>The product of the left and right parameters.</returns>
 public static Vector8i Multiply(Vector8us vector, int scalar)
 {
     return(new Vector8i(vector.V0 * scalar, vector.V1 * scalar, vector.V2 * scalar, vector.V3 * scalar, vector.V4 * scalar, vector.V5 * scalar, vector.V6 * scalar, vector.V7 * scalar));
 }
예제 #11
0
 /// <summary>
 /// Divides a vector by a scalar and returns the result.
 /// </summary>
 /// <param name="vector">The vector to be divided (the dividend).</param>
 /// <param name="scalar">The scalar to divide by (the divisor).</param>
 /// <returns>The result of dividing left by right (the quotient).</returns>
 public static Vector8i Divide(Vector8us vector, int scalar)
 {
     return(new Vector8i(vector.V0 / scalar, vector.V1 / scalar, vector.V2 / scalar, vector.V3 / scalar, vector.V4 / scalar, vector.V5 / scalar, vector.V6 / scalar, vector.V7 / scalar));
 }
예제 #12
0
 /// <summary>
 /// Subtracts one vectors from another and returns the result.
 /// </summary>
 /// <param name="left">The value to subtract from (the minuend).</param>
 /// <param name="right">The value to subtract (the subtrahend).</param>
 /// <returns>The result of subtracting right from left (the difference).</returns>
 public static Vector8i Subtract(Vector8us left, Vector8us right)
 {
     return(new Vector8i(left.V0 - right.V0, left.V1 - right.V1, left.V2 - right.V2, left.V3 - right.V3, left.V4 - right.V4, left.V5 - right.V5, left.V6 - right.V6, left.V7 - right.V7));
 }
예제 #13
0
 /// <summary>
 /// Adds two vectors and returns the result.
 /// </summary>
 /// <param name="left">The first value to add.</param>
 /// <param name="right">The second value to add.</param>
 /// <returns>The sum of left and right.</returns>
 public static Vector8i Add(Vector8us left, Vector8us right)
 {
     return(new Vector8i(left.V0 + right.V0, left.V1 + right.V1, left.V2 + right.V2, left.V3 + right.V3, left.V4 + right.V4, left.V5 + right.V5, left.V6 + right.V6, left.V7 + right.V7));
 }
예제 #14
0
 /// <summary>
 /// Returns the additive inverse of a vector.
 /// </summary>
 /// <param name="value">A vector.</param>
 /// <returns>The negative of value.</returns>
 public static Vector8i Negative(Vector8us value)
 {
     return(new Vector8i(-value.V0, -value.V1, -value.V2, -value.V3, -value.V4, -value.V5, -value.V6, -value.V7));
 }
예제 #15
0
 public static Vector8sb Map(Vector8us value, Func <ushort, sbyte> mapping)
 {
     return(new Vector8sb(mapping(value.V0), mapping(value.V1), mapping(value.V2), mapping(value.V3), mapping(value.V4), mapping(value.V5), mapping(value.V6), mapping(value.V7)));
 }
예제 #16
0
 public static bool All(Vector8us value, Predicate <ushort> predicate)
 {
     return(predicate(value.V0) && predicate(value.V1) && predicate(value.V2) && predicate(value.V3) && predicate(value.V4) && predicate(value.V5) && predicate(value.V6) && predicate(value.V7));
 }
예제 #17
0
 public static Vector8i Modulate(Vector8us left, Vector8us right)
 {
     return(new Vector8i(left.V0 * right.V0, left.V1 * right.V1, left.V2 * right.V2, left.V3 * right.V3, left.V4 * right.V4, left.V5 * right.V5, left.V6 * right.V6, left.V7 * right.V7));
 }
예제 #18
0
 public static bool Any(Vector8us value)
 {
     return(value.V0 != 0 || value.V1 != 0 || value.V2 != 0 || value.V3 != 0 || value.V4 != 0 || value.V5 != 0 || value.V6 != 0 || value.V7 != 0);
 }
예제 #19
0
 public static Vector8us Min(Vector8us value1, Vector8us value2)
 {
     return(new Vector8us(Functions.Min(value1.V0, value2.V0), Functions.Min(value1.V1, value2.V1), Functions.Min(value1.V2, value2.V2), Functions.Min(value1.V3, value2.V3), Functions.Min(value1.V4, value2.V4), Functions.Min(value1.V5, value2.V5), Functions.Min(value1.V6, value2.V6), Functions.Min(value1.V7, value2.V7)));
 }
예제 #20
0
 public static Vector8us Clamp(Vector8us value, Vector8us min, Vector8us max)
 {
     return(new Vector8us(Functions.Clamp(value.V0, min.V0, max.V0), Functions.Clamp(value.V1, min.V1, max.V1), Functions.Clamp(value.V2, min.V2, max.V2), Functions.Clamp(value.V3, min.V3, max.V3), Functions.Clamp(value.V4, min.V4, max.V4), Functions.Clamp(value.V5, min.V5, max.V5), Functions.Clamp(value.V6, min.V6, max.V6), Functions.Clamp(value.V7, min.V7, max.V7)));
 }