本文整理汇总了C#中Mono.Simd.Vector4f类的典型用法代码示例。如果您正苦于以下问题:C# Vector4f类的具体用法?C# Vector4f怎么用?C# Vector4f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector4f类属于Mono.Simd命名空间,在下文中一共展示了Vector4f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: test_0_accessor_and_byref_var
public static int test_0_accessor_and_byref_var()
{
Vector4f a = new Vector4f (1, 2, 3, 4);
if (use_getter_with_byref (ref a) != 4)
return 1;
return 0;
}
示例2: Dp2Add
public static Vector4f Dp2Add(Vector4f a, Vector4f b, Vector4f c)
{
Vector4f res = a * b;
//XX we could use HorizontalAdd here
res = res + res.Shuffle (ShuffleSel.XFromY) + c;
return res.Shuffle (ShuffleSel.ExpandX);
}
示例3: Dot
public static float Dot (ref Vector4f vector1, ref Vector4f vector2)
{
Vector4f t = vector1 * vector2;
t = t.HorizontalAdd (t);
t = t.HorizontalAdd (t);
return t.X;
}
示例4: Sample
public Vector4f Sample(Vector4f coord)
{
int x = (int) (coord.X * tex.Width);
int y = (int) (coord.Y * tex.Height);
Vector4f color = tex.ReadColor (x, y);
if (Tracing.Enabled) Console.WriteLine ("sampling {0} -> [{1}, {2}] -> {3}", coord, x, y, color);
return color;
}
示例5: call_simd_fp
public static void call_simd_fp()
{
Vector4f a = new Vector4f (20f, 22f, 23f, 24f);
float b = 25f;
Vector4f c = new Vector4f (26f, 27f, 28f, 29f);
float d = 30f;
b += d;
a += c;
}
示例6: Quaternion
public Quaternion (Vector3 vectorPart, float scalarPart)
{
#if SIMD
v4 = new Vector4f (vectorPart.X, vectorPart.Y, vectorPart.Z, scalarPart);
#else
x = vectorPart.X;
y = vectorPart.Y;
z = vectorPart.Z;
w = scalarPart;
#endif
}
示例7: AndNot
public static unsafe Vector4f AndNot (this Vector4f v1, Vector4f v2)
{
Vector4f res = new Vector4f ();
int *a = (int*)&v1;
int *b = (int*)&v2;
int *c = (int*)&res;
*c++ = ~*a++ & *b++;
*c++ = ~*a++ & *b++;
*c++ = ~*a++ & *b++;
*c = ~*a & *b;
return res;
}
示例8: SimdTest
public void SimdTest()
{
Bounds bounds = new Bounds(new Vector3(1, 1, 1), new Vector3(3, 3, 3));
const int positionX = 4;
const int positionZ = 3;
// Non-SIMD version
Vector3Int bMin;
Vector3Int bMax;
Vector3Int myVec52 = new Vector3Int(Chunk.Vec5.X, Chunk.Vec5.X, Chunk.Vec5.X);
{
Vector3Int pom = new Vector3Int(positionX * EngineSettings.ChunkConfig.SizeX, 0, positionZ * EngineSettings.ChunkConfig.SizeZ);
int minX = Mathf.Clamp(Mathf.FloorToInt(bounds.min.x) - pom.X - myVec52.X, 0, EngineSettings.ChunkConfig.MaskX);
int minY = Mathf.Clamp(Mathf.FloorToInt(bounds.min.y) - myVec52.Y, 0, EngineSettings.ChunkConfig.SizeYTotal - 1);
int minZ = Mathf.Clamp(Mathf.FloorToInt(bounds.min.z) - pom.Z - myVec52.Z, 0, EngineSettings.ChunkConfig.MaskZ);
bMin = new Vector3Int(minX, minY, minZ);
int maxX = Mathf.Clamp(Mathf.Clamp(bMin.X, 0, EngineSettings.ChunkConfig.MaskX), 0, EngineSettings.ChunkConfig.MaskX);
int maxY = Mathf.Clamp(Mathf.Clamp(bMin.Y, 0, EngineSettings.ChunkConfig.SizeYTotal - 1), 0, EngineSettings.ChunkConfig.SizeYTotal-1);
int maxZ = Mathf.Clamp(Mathf.Clamp(bMin.Z, 0, EngineSettings.ChunkConfig.MaskZ), 0, EngineSettings.ChunkConfig.MaskZ);
bMax = new Vector3Int(maxX, maxY, maxZ);
}
// SIMD version
Vector4i bMinv;
Vector4i bMaxv;
{
Vector4f bMinf = new Vector4f(bounds.min.x, bounds.min.y, bounds.min.z, 0f);
bMinv = bMinf.ConvertToIntTruncated();
Vector4f bMaxf = new Vector4f(bounds.max.x, bounds.max.y, bounds.max.z, 0f);
bMaxv = bMaxf.ConvertToInt();
Vector4i pom = new Vector4i(positionX, 0, positionZ, 0)*Chunk.VecSize;
bMinv -= pom;
bMinv -= Chunk.Vec5;
bMinv = bMinv.Max(Vector4i.Zero).Min(Chunk.VecSize1);
// Clamp to 0..size (x,z) or 0..height (y) respectively
bMaxv -= pom;
bMaxv += Chunk.Vec5;
bMaxv = bMaxv.Max(Vector4i.Zero).Min(Chunk.VecSize1);
// Clamp to 0..size (x,z) or 0..height (y) respectively
}
Assert.AreEqual(bMin.X, bMinv.X);
Assert.AreEqual(bMin.Y, bMinv.Y);
Assert.AreEqual(bMin.Z, bMinv.Z);
Assert.AreEqual(bMax.X, bMaxv.X);
Assert.AreEqual(bMax.Y, bMaxv.Y);
Assert.AreEqual(bMax.Z, bMaxv.Z);
}
示例9: test_0_accessors
public static int test_0_accessors()
{
Vector4f a = new Vector4f (1, 2, 3, 4);
if (a.X != 1f)
return 1;
if (a.Y != 2f)
return 2;
if (a.Z != 3f)
return 3;
if (a.W != 4f)
return 4;
return 0;
}
示例10: test_0_vector4f_one_element_ctor
static int test_0_vector4f_one_element_ctor () {
Vector4f a = new Vector4f (99);
if (a.X != 99)
return 1;
if (a.Y != 99)
return 2;
if (a.Z != 99)
return 3;
if (a.W != 99)
return 4;
return 0;
}
示例11: test_0_f_to_i_trunc
public static int test_0_f_to_i_trunc () {
var a = new Vector4f (1.1f, 2.2f, 3.5f, 4.6f);
var b = a.ConvertToIntTruncated ();
if (b.X != 1)
return 1;
if (b.Y != 2)
return 2;
if (b.Z != 3)
return 3;
if (b.W != 4)
return 4;
return 0;
}
示例12: test_0_set_vector4f_operator_neq
public static int test_0_set_vector4f_operator_neq () {
Vector4f a = new Vector4f(1, 2, 3, 4);
Vector4f b = new Vector4f(1, 2, 3, 4);
if (a != b)
return 1;
a = new Vector4f(1, 2, float.NaN, 4);
b = new Vector4f(1, 2, float.NaN, 4);
if (!(a != b)) //NaN is always !=
return 2;
a = new Vector4f(1, 2, float.NaN, 4);
b = new Vector4f(1, 2, 10, 4);
if (!(a != b))
return 3;
a = new Vector4f(1, 2, float.PositiveInfinity, 4);
b = new Vector4f(1, 2, float.PositiveInfinity, 4);
if (a != b)
return 4;
a = new Vector4f(1, 2, 20, 4);
b = new Vector4f(1, 2, 30, 4);
if (!(a != b))
return 5;
return 0;
}
示例13: test_0_shuffle_with_two_args_ps
public static int test_0_shuffle_with_two_args_ps () {
Vector4f a = new Vector4f (1, 2, 3, 4);
Vector4f b = new Vector4f (5, 6, 7, 8);
Vector4f c = a.Shuffle (b, ShuffleSel.ExpandY);
if (c.X != 2)
return 1;
if (c.Y != 2)
return 2;
if (c.Z != 6)
return 3;
if (c.W != 6)
return 4;
return 0;
}
示例14: test_0_f_to_d
public static int test_0_f_to_d () {
var a = new Vector4f (1,2,3,4);
var b = a.ConvertToDouble ();
if (b.X != 1)
return 1;
if (b.Y != 2)
return 2;
return 0;
}
示例15: CallMethodThatClobbersRegs
static void CallMethodThatClobbersRegs () {
Vector4f a = new Vector4f (9,9,9,9);
Vector4f b = new Vector4f (9,9,9,9);
a = a + b;
}