daily update on 20230830

This commit is contained in:
Nitload
2023-08-30 22:49:11 +08:00
parent 1fcbfb972b
commit c6f4b3dd53
55 changed files with 648 additions and 1198 deletions
+5 -117
View File
@@ -1,6 +1,7 @@
using StgSharp.Math;
using System;
using System.Diagnostics;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
@@ -12,127 +13,14 @@ namespace StgSharp
internal unsafe static void Main(string[] args)
{
/**/
Matrix4x4 matrix = new Matrix4x4(
1,1,-1,2,
-1,-1,-4,1,
2,4,-6,1,
1,2,4,2
Matrix3x3 matrix = new Matrix3x3(
1,2,3,
4,5,6,
7,8,9
);
Console.WriteLine(matrix.Det());
/**/
System.Numerics.Matrix4x4 m = new System.Numerics.Matrix4x4(
1, 1, -1, 2,
-1, -1, -4, 1,
2, 4, -6, 1,
1, 2, 4, 2
);
Console.WriteLine(m.GetDeterminant());
/**/
int cycle = 1000;
int time = 10000;
for (int t = 0; t < cycle; t++)
{
Stopwatch sw = Stopwatch.StartNew();
sw.Start();
for (int i = 0; i < time; i++)
{
Matrix4x4 matrix4X4 = new Matrix4x4(
1, 1, -1, 2,
-1, -1, -4, 1,
2, 4, -6, 1,
1, 2, 4, 2
);
}
sw.Stop();
TimeSpan timeSpan = sw.Elapsed;
Console.WriteLine(timeSpan.TotalMilliseconds);
Stopwatch sw2 = new Stopwatch();
sw2.Start();
for (int i = 0; i < time; i++)
{
System.Numerics.Matrix4x4 test = new System.Numerics.Matrix4x4(
1, 1, -1, 2,
-1, -1, -4, 1,
2, 4, -6, 1,
1, 2, 4, 2
);
}
sw2.Stop();
TimeSpan timeSpan1 = sw2.Elapsed;
Console.WriteLine(timeSpan1.TotalMilliseconds);
Console.WriteLine();
}
/**/
/*
System.Numerics.Matrix4x4 smt1 = new System.Numerics.Matrix4x4(
1,2,3,4,
5,6,7,8,
1,2,3,4,
5,6,7,8
);
Matrix4x4 gmt1 = new Matrix4x4(
1, 2, 3, 4,
5, 6, 7, 8,
1, 2, 3, 4,
5, 6, 7, 8
);
Stopwatch s = new Stopwatch();
double cycle = 1e6;
for (int t = 0; t < 1000; t++)
{
s.Reset();
s.Start();
for (int i = 0; i < cycle; i++)
{
System.Numerics.Matrix4x4 ret = smt1 * smt1;
}
s.Stop();
TimeSpan span = s.Elapsed;
Console.WriteLine(span.TotalMilliseconds);
s.Reset();
s.Start();
for (int i = 0; i < cycle; i++)
{
Matrix4x4 ret = VectorCalc.Multiple(gmt1, gmt1);
}
s.Stop();
TimeSpan span1 = s.Elapsed;
Console.WriteLine(span1.TotalMilliseconds);
Console.WriteLine(t);
Console.WriteLine();
}
/**/
}