more F16 math

This commit is contained in:
Jorijn van der Graaf 2026-03-19 02:19:01 +01:00
commit e3cd40fa90
5 changed files with 1026 additions and 502 deletions

View file

@ -317,9 +317,7 @@ namespace Crafter {
constexpr void Normalize() { constexpr void Normalize() {
T fLength = Length(); T fLength = Length();
if (fLength > 0) {
fLength = 1.0f / fLength; fLength = 1.0f / fLength;
}
for(std::uint32_t i = 0; i < Len; i++) { for(std::uint32_t i = 0; i < Len; i++) {
this->v[i] *= fLength; this->v[i] *= fLength;

File diff suppressed because it is too large Load diff

View file

@ -23,4 +23,4 @@ export import :Basic;
export import :Vector; export import :Vector;
export import :MatrixRowMajor; export import :MatrixRowMajor;
export import :Intersection; export import :Intersection;
//export import :VectorF16; export import :VectorF16;

View file

@ -32,19 +32,42 @@ int main() {
// Vector<_Float16, 8, 8> vA; Vector<_Float16, 1326, 32> vA;
// for(std::uint32_t i = 0; i < 8; i++) { // for(std::uint32_t i = 0; i < 2; i++) {
// vA.v[i] = i; // vA.v[i] = i;
// } // }
// VectorF16<8, 1, 1> vfA(&vA); // for(std::uint32_t i = 2; i < 4; i++) {
// VectorF16<8, 1, 1> dot = VectorF16<8, 1, 1>::Dot(vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA); // vA.v[i] = i-2;
// std::println("{}", dot);
// Vector<float, 8, 8> vB;
// for(std::uint32_t i = 0; i < 8; i++) {
// vB.v[i] = i;
// } // }
// float test = Vector<float, 8, 8>::Dot(vA, vA); // for(std::uint32_t i = 4; i < 6; i++) {
// vA.v[i] = i-4;
// }
// for(std::uint32_t i = 6; i < 8; i++) {
// vA.v[i] = i-6;
// }
for(std::uint32_t i = 0; i < 8; i++) {
vA.v[i] = i;
}
for(std::uint32_t i = 8; i < 16; i++) {
vA.v[i] = i-8;
}
for(std::uint32_t i = 16; i < 24; i++) {
vA.v[i] = i-16;
}
for(std::uint32_t i = 24; i < 32; i++) {
}
VectorF16<8, 1, 4> vfA(&vA);
std::tuple<VectorF16<8, 1, 4>, VectorF16<8, 1, 4>, VectorF16<8, 1, 4>, VectorF16<8, 1, 4>, VectorF16<8, 1, 4>, VectorF16<8, 1, 4>, VectorF16<8, 1, 4>, VectorF16<8, 1, 4>> dot = VectorF16<8, 1, 4>::Normalize(vfA, vfA, vfA, vfA, vfA, vfA, vfA, vfA);
std::println("{}", std::get<0>(dot));
// std::println("{}", test); Vector<float, 8, 8> vB;
for(std::uint32_t i = 0; i < 8; i++) {
vB.v[i] = i;
}
vB.Normalize();
std::string log;
for(std::uint32_t i = 0; i < 8; i++) {
log += std::format("{} ", (float)vB.v[i]);
}
std::println("{{{}}}", log);
} }

View file

@ -8,7 +8,8 @@
"interfaces/Crafter.Math-Basic", "interfaces/Crafter.Math-Basic",
"interfaces/Crafter.Math-MatrixRowMajor", "interfaces/Crafter.Math-MatrixRowMajor",
"interfaces/Crafter.Math", "interfaces/Crafter.Math",
"interfaces/Crafter.Math-Intersection" "interfaces/Crafter.Math-Intersection",
"interfaces/Crafter.Math-VectorF16"
], ],
"implementations": [] "implementations": []
}, },
@ -27,7 +28,7 @@
"name": "test", "name": "test",
"implementations": ["interfaces/main"], "implementations": ["interfaces/main"],
"extends": ["base"], "extends": ["base"],
"debug": true "debug": false
} }
] ]
} }