151 lines
3.6 KiB
C
151 lines
3.6 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include <basic-geometry.h>
|
|
|
|
#ifdef _WIN64
|
|
#include <windows.h>
|
|
#else
|
|
#include <time.h>
|
|
#endif // _WINDOWS_
|
|
|
|
#include "vector3_pair_difference.h"
|
|
|
|
typedef struct {
|
|
BGC_FP32_Turn3 versor1, versor2, result;
|
|
} structure_fp32_t;
|
|
|
|
structure_fp32_t* allocate_structures(const unsigned int amount)
|
|
{
|
|
return calloc(amount, sizeof(structure_fp32_t));
|
|
}
|
|
|
|
structure_fp32_t* make_structures(const unsigned int amount)
|
|
{
|
|
structure_fp32_t* list = allocate_structures(amount);
|
|
|
|
if (list == 0) {
|
|
return 0;
|
|
}
|
|
|
|
const float multiplier = 2.0f / RAND_MAX;
|
|
|
|
for (unsigned int i = 0; i < amount; i++) {
|
|
bgc_fp32_turn3_set_values(
|
|
&list[i].versor1,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f
|
|
);
|
|
|
|
bgc_fp32_turn3_set_values(
|
|
&list[i].versor2,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f
|
|
);
|
|
|
|
bgc_fp32_turn3_reset(&list[i].result);
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
|
|
void list_work(const uint_fast32_t amount, structure_fp32_t* list)
|
|
{
|
|
for (uint_fast32_t j = 0; j < 1000; j++) {
|
|
for (uint_fast32_t i = 0; i < amount; i++) {
|
|
bgc_fp32_turn3_combine(&list[i].result, &list[i].versor1, &list[i].versor2);
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
int main()
|
|
{
|
|
const unsigned int amount = 1000000;
|
|
structure_fp32_t* list = make_structures(amount);
|
|
|
|
#ifdef _WIN64
|
|
ULONGLONG start, end;
|
|
|
|
start = GetTickCount64();
|
|
|
|
srand((unsigned int)(start & 0xfffffff));
|
|
|
|
start = GetTickCount64();
|
|
#else
|
|
struct timespec start, end;
|
|
clock_gettime(0, &start);
|
|
srand((unsigned int)(start.tv_nsec & 0xfffffff));
|
|
|
|
clock_gettime(CLOCK_REALTIME, &start);
|
|
#endif // _WIN64
|
|
|
|
list_work(amount, list);
|
|
|
|
#ifdef _WIN64
|
|
end = GetTickCount64();
|
|
|
|
printf("Time: %lld\n", end - start);
|
|
#else
|
|
clock_gettime(CLOCK_REALTIME, &end);
|
|
|
|
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
|
#endif // _WIN64
|
|
|
|
print_fp32_quaternion(&list[10].versor1._versor);
|
|
print_fp32_quaternion(&list[10].versor2._versor);
|
|
print_fp32_quaternion(&list[10].result._versor);
|
|
|
|
free(list);
|
|
|
|
return 0;
|
|
}
|
|
*/
|
|
|
|
/*
|
|
int main() {
|
|
BGC_FP32_Complex complex, exponent, result;
|
|
|
|
bgc_fp32_complex_set_values(0, 1, &complex);
|
|
|
|
bgc_fp32_complex_set_values(4, 0, &exponent);
|
|
|
|
bgc_fp32_complex_get_exponation(&complex, exponent.real, exponent.imaginary, &result);
|
|
|
|
printf("(%f, %f) ^ (%f, %f) = (%f, %f)\n", complex.real, complex.imaginary, exponent.real, exponent.imaginary, result.real, result.imaginary);
|
|
|
|
return 0;
|
|
}
|
|
*/
|
|
/*
|
|
int main() {
|
|
BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|
BGC_FP32_Turn3 end = { 0.0f, 1.0f, 0.0f, 0.0f };
|
|
BGC_FP32_Turn3 result;
|
|
bgc_fp32_turn3_spherical_interpolation(&start, &end, 0.5f, &result);
|
|
printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3);
|
|
return 0;
|
|
}
|
|
*/
|
|
|
|
|
|
#include "affine3.h"
|
|
|
|
int main()
|
|
{
|
|
//test_fp32_pair_difference();
|
|
test_fp64_pair_difference();
|
|
|
|
//printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10));
|
|
|
|
//printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3));
|
|
//printf("offsetof(shift) = %zu\n", offsetof(BGC_FP32_Affine3, shift));
|
|
//printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3));
|
|
|
|
return 0;
|
|
}
|
|
|