Переименование проектов и оптимизация вычислений / Renaming of projects and optimization of computations

This commit is contained in:
Andrey Pokidov 2024-12-04 23:23:44 +07:00
parent 37d86bc4c1
commit 75e5c02609
36 changed files with 177 additions and 379 deletions

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BasicGeometry\BasicGeometry.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,80 @@
// See https://aka.ms/new-console-template for more information
using System;
using System.ComponentModel;
using System.Diagnostics;
using BasicGeometry;
public static class Program
{
private static FP32Versor[] AllocateVersors(int amount)
{
return new FP32Versor[amount];
}
private static FP32Versor[] MakeZeroVersors(int amount)
{
FP32Versor[] versors = AllocateVersors(amount);
for (int i = 0; i < amount; i++)
{
versors[i].Reset();
}
return versors;
}
private static FP32Versor[] MakeRandomVersors(int amount)
{
Random randomizer = new Random(Environment.TickCount);
FP32Versor[] versors = AllocateVersors(amount);
for (int i = 0; i < amount; i++)
{
versors[i] = new FP32Versor(
randomizer.NextSingle(),
randomizer.NextSingle(),
randomizer.NextSingle(),
randomizer.NextSingle()
);
}
return versors;
}
private static void PrintVersor(in FP32Versor versor)
{
Console.WriteLine("({0}, {1}, {2}, {3})", versor.GetScalar(), versor.GetX1(), versor.GetX2(), versor.GetX3());
}
public static int Main()
{
int amount = 1000000;
FP32Versor[] versors1 = MakeRandomVersors(amount);
FP32Versor[] versors2 = MakeRandomVersors(amount);
FP32Versor[] results = MakeZeroVersors(amount);
long start, end;
start = Environment.TickCount64;
for (int j = 0; j < 1000; j++)
{
for (int i = 0; i < amount; i++)
{
FP32Versor.Combine(versors1[i], versors2[i], out results[i]);
}
}
end = Environment.TickCount64;
Console.WriteLine("Time: {0}", end - start);
PrintVersor(versors1[10]);
PrintVersor(versors2[10]);
PrintVersor(results[10]);
return 0;
}
}