added more tests

This commit is contained in:
Jorijn van der Graaf 2026-03-29 06:47:06 +02:00
commit d09155736f
2 changed files with 61 additions and 417 deletions

View file

@ -172,7 +172,7 @@ std::string* TestAllCombinations() {
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
for (std::uint32_t i = 0; i < Len * Packing; i++) {
if (!FloatEquals(stored.v[i], floats[i] / T(2))) {
return new std::string(std::format("Scalar multiply mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * T(2)), (float)stored.v[i]));
return new std::string(std::format("Scalar divide mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * T(2)), (float)stored.v[i]));
}
}
}
@ -279,6 +279,66 @@ std::string* TestAllCombinations() {
}
}
}
{
VectorType<Len, Packing> vec(floats);
VectorType<Len, Packing> result = vec.Sin();
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
for(std::uint32_t i2 = 0; i2 < Packing; i2++){
for (std::uint32_t i = 0; i < Len; i++) {
T expected = (T)std::sin((float)floats[i2*Len+i]);
if (!FloatEquals(stored.v[i2*Len+i], expected)) {
return new std::string(std::format("Sin mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i2*(Len-1)+i]));
}
}
}
}
{
VectorType<Len, Packing> vec(floats);
VectorType<Len, Packing> result = vec.Cos();
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
for(std::uint32_t i2 = 0; i2 < Packing; i2++){
for (std::uint32_t i = 0; i < Len; i++) {
T expected = (T)std::cos((float)floats[i2*Len+i]);
if (!FloatEquals(stored.v[i2*Len+i], expected)) {
return new std::string(std::format("Cos mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i2*(Len-1)+i]));
}
}
}
}
{
VectorType<Len, Packing> vec(floats);
auto result = vec.SinCos();
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> storedSin = std::get<0>(result).Store();
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> storedCos = std::get<1>(result).Store();
for(std::uint32_t i2 = 0; i2 < Packing; i2++){
for (std::uint32_t i = 0; i < Len; i++) {
T expected = (T)std::sin((float)floats[i2*Len+i]);
if (!FloatEquals(storedSin.v[i2*Len+i], expected)) {
return new std::string(std::format("SinCos sin mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)storedSin.v[i2*(Len-1)+i]));
}
expected = (T)std::cos((float)floats[i2*Len+i]);
if (!FloatEquals(storedCos.v[i2*Len+i], expected)) {
return new std::string(std::format("SinCos cos mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)storedCos.v[i2*(Len-1)+i]));
}
}
}
}
{
VectorType<Len, Packing> vec(floats);
VectorType<Len, Packing> result = vec.template Shuffle<GetCountReverse<Len>()>();
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
for (std::uint32_t i = 0; i < Len; i++) {
T expected = floats[Len - 1 - i];
if (!FloatEquals(stored.v[i], expected)) {
return new std::string(std::format("Shuffle mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i]));
}
}
}
}
if constexpr(Packing == 1) {
@ -320,18 +380,6 @@ std::string* TestAllCombinations() {
return new std::string(std::format("Normalize mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, 1, (float)length));
}
}
{
VectorType<Len, Packing> vec(floats);
VectorType<Len, Packing> result = vec.template Shuffle<GetCountReverse<Len>()>();
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
for (std::uint32_t i = 0; i < Len; i++) {
T expected = floats[Len - 1 - i];
if (!FloatEquals(stored.v[i], expected)) {
return new std::string(std::format("Shuffle mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i]));
}
}
}
}
if constexpr(Len == 3) {
@ -447,8 +495,6 @@ std::string* TestAllCombinations() {
VectorType<1, Packing*4> result2 = VectorType<Len, Packing>::Length(std::get<0>(result), std::get<1>(result), std::get<2>(result), std::get<3>(result));
Vector<T, Packing*4, VectorType<Len, Packing>::Alignment> stored = result2.Store();
//std::println("{}", stored);
for(std::uint8_t i = 0; i < Len*Packing; i++) {
if (!FloatEquals(stored.v[i], T(1))) {
return new std::string(std::format("Normalize {} test failed at Len={} Packing={} Expected: {}, Got: {}", i, Len, Packing, 1, (float)stored.v[i]));