Пример #1
0
 /// <summary>
 /// Writes the given <see cref="Vector8ul"/> to an <see cref="Ibasa.IO.BinaryWriter">.
 /// </summary>
 public static void Write(this Ibasa.IO.BinaryWriter writer, Vector8ul vector)
 {
     writer.Write(vector.V0);
     writer.Write(vector.V1);
     writer.Write(vector.V2);
     writer.Write(vector.V3);
     writer.Write(vector.V4);
     writer.Write(vector.V5);
     writer.Write(vector.V6);
     writer.Write(vector.V7);
 }
Пример #2
0
        public static Vector8d Normalize(Vector8ul value)
        {
            var absolute = Absolute(value);

            if (absolute <= double.Epsilon)
            {
                return(Vector8ul.Zero);
            }
            else
            {
                return((Vector8d)value / absolute);
            }
        }
Пример #3
0
 public static double Absolute(Vector8ul value)
 {
     return(Functions.Sqrt(AbsoluteSquared(value)));
 }
Пример #4
0
 public static ulong AbsoluteSquared(Vector8ul value)
 {
     return(Dot(value, value));
 }
Пример #5
0
 public static bool Any(Vector8ul value, Predicate <ulong> 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));
 }
Пример #6
0
 public static Vector8ul Abs(Vector8ul value)
 {
     return(new Vector8ul(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
 /// <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(Vector8ul left, Vector8ul right)
 {
     return(left == right);
 }
Пример #8
0
 public static Vector8sb Map(Vector8ul value, Func <ulong, 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)));
 }
Пример #9
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 Vector8ul Multiply(Vector8ul vector, ulong scalar)
 {
     return(new Vector8ul(vector.V0 * scalar, vector.V1 * scalar, vector.V2 * scalar, vector.V3 * scalar, vector.V4 * scalar, vector.V5 * scalar, vector.V6 * scalar, vector.V7 * scalar));
 }
Пример #10
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 Vector8ul Divide(Vector8ul vector, ulong scalar)
 {
     return(new Vector8ul(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>
 /// 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 Vector8ul Subtract(Vector8ul left, Vector8ul right)
 {
     return(new Vector8ul(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));
 }
Пример #12
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 Vector8ul Add(Vector8ul left, Vector8ul right)
 {
     return(new Vector8ul(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
        public static long Pack(int v0Bits, int v1Bits, int v2Bits, int v3Bits, int v4Bits, int v5Bits, int v6Bits, int v7Bits, Vector8ul vector)
        {
            Contract.Requires(0 <= v0Bits && v0Bits <= 64, "v0Bits must be between 0 and 64 inclusive.");
            Contract.Requires(0 <= v1Bits && v1Bits <= 64, "v1Bits must be between 0 and 64 inclusive.");
            Contract.Requires(0 <= v2Bits && v2Bits <= 64, "v2Bits must be between 0 and 64 inclusive.");
            Contract.Requires(0 <= v3Bits && v3Bits <= 64, "v3Bits must be between 0 and 64 inclusive.");
            Contract.Requires(0 <= v4Bits && v4Bits <= 64, "v4Bits must be between 0 and 64 inclusive.");
            Contract.Requires(0 <= v5Bits && v5Bits <= 64, "v5Bits must be between 0 and 64 inclusive.");
            Contract.Requires(0 <= v6Bits && v6Bits <= 64, "v6Bits must be between 0 and 64 inclusive.");
            Contract.Requires(0 <= v7Bits && v7Bits <= 64, "v7Bits must be between 0 and 64 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));
        }
Пример #14
0
 public static Vector8h Map(Vector8ul value, Func <ulong, Half> mapping)
 {
     return(new Vector8h(mapping(value.V0), mapping(value.V1), mapping(value.V2), mapping(value.V3), mapping(value.V4), mapping(value.V5), mapping(value.V6), mapping(value.V7)));
 }
Пример #15
0
 public static ulong Dot(Vector8ul left, Vector8ul 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);
 }
Пример #16
0
 public static Vector8us Map(Vector8ul value, Func <ulong, ushort> mapping)
 {
     return(new Vector8us(mapping(value.V0), mapping(value.V1), mapping(value.V2), mapping(value.V3), mapping(value.V4), mapping(value.V5), mapping(value.V6), mapping(value.V7)));
 }
Пример #17
0
 public static bool All(Vector8ul value, Predicate <ulong> 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));
 }
Пример #18
0
 public static Vector8ul Modulate(Vector8ul left, Vector8ul right)
 {
     return(new Vector8ul(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));
 }
Пример #19
0
 public static bool Any(Vector8ul 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);
 }
Пример #20
0
 public static Vector8ul Max(Vector8ul value1, Vector8ul value2)
 {
     return(new Vector8ul(Functions.Max(value1.V0, value2.V0), Functions.Max(value1.V1, value2.V1), Functions.Max(value1.V2, value2.V2), Functions.Max(value1.V3, value2.V3), Functions.Max(value1.V4, value2.V4), Functions.Max(value1.V5, value2.V5), Functions.Max(value1.V6, value2.V6), Functions.Max(value1.V7, value2.V7)));
 }
Пример #21
0
 public static Vector8ul Clamp(Vector8ul value, Vector8ul min, Vector8ul max)
 {
     return(new Vector8ul(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)));
 }