From 5b9b9dc472132be3c8171a73ca7785815b084c65 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Thu, 5 Feb 2026 01:18:05 +0100 Subject: [PATCH] added alignment --- interfaces/Crafter.Math-BasicTypes.cppm | 9 +- interfaces/Crafter.Math-MatrixRowMajor.cppm | 46 +- interfaces/Crafter.Math-Vector.cppm | 997 ++------------------ 3 files changed, 106 insertions(+), 946 deletions(-) diff --git a/interfaces/Crafter.Math-BasicTypes.cppm b/interfaces/Crafter.Math-BasicTypes.cppm index dcbafdd..8641a1e 100755 --- a/interfaces/Crafter.Math-BasicTypes.cppm +++ b/interfaces/Crafter.Math-BasicTypes.cppm @@ -1,12 +1,11 @@ /* -Crafter.Math -Copyright (C) 2026 Catcrafts -Catcrafts.net +Crafter®.Math +Copyright (C) 2026 Catcrafts® +catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 3.0 of the License, or (at your option) any later version. +License version 3.0 as published by the Free Software Foundation; This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/interfaces/Crafter.Math-MatrixRowMajor.cppm b/interfaces/Crafter.Math-MatrixRowMajor.cppm index c0a4737..3520949 100755 --- a/interfaces/Crafter.Math-MatrixRowMajor.cppm +++ b/interfaces/Crafter.Math-MatrixRowMajor.cppm @@ -80,8 +80,9 @@ namespace Crafter { m[2][3] = w2; } - Vector operator*(Vector b) const requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { - return Vector( + template + Vector operator*(Vector b) const requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { + return Vector( b.x * m[0][0] + b.y * m[1][0] + b.z * m[2][0] + m[3][0], b.x * m[0][1] + b.y * m[1][1] + b.z * m[2][1] + m[3][1], b.x * m[0][2] + b.y * m[1][2] + b.z * m[2][2] + m[3][2] @@ -178,7 +179,8 @@ namespace Crafter { 0, 0, z, 0 ); } - static MatrixRowMajor Scaling(Vector vector) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { + template + static MatrixRowMajor Scaling(Vector vector) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { return Scaling(vector.x, vector.y, vector.z); } @@ -197,7 +199,9 @@ namespace Crafter { 0, 0, 1, z ); } - static MatrixRowMajor Translation(Vector vector) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { + + template + static MatrixRowMajor Translation(Vector vector) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { return Translation(vector.x, vector.y, vector.z); } @@ -264,24 +268,26 @@ namespace Crafter { return M; } - static MatrixRowMajor LookAt(Vector eyePosition, Vector focusPosition, Vector upDirection) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { + template + static MatrixRowMajor LookAt(Vector eyePosition, Vector focusPosition, Vector upDirection) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { MatrixRowMajor M; - Vector negEyeDirection = eyePosition - focusPosition; + Vector negEyeDirection = eyePosition - focusPosition; return LookTo(eyePosition, negEyeDirection, upDirection); return M; } - static MatrixRowMajor LookTo(Vector eyePosition, Vector eyeDirection, Vector upDirection) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { - Vector R2 = eyeDirection.Normalize(); + template + static MatrixRowMajor LookTo(Vector eyePosition, Vector eyeDirection, Vector upDirection) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { + Vector R2 = eyeDirection.Normalize(); - Vector R0 = upDirection.Cross(R2); + Vector R0 = upDirection.Cross(R2); R0 = R0.Normalize(); - Vector R1 = R2.Cross(R0); + Vector R1 = R2.Cross(R0); - Vector NegEyePosition = -eyePosition; + Vector NegEyePosition = -eyePosition; float D0 = R0.Dot(NegEyePosition); float D1 = R1.Dot(NegEyePosition); @@ -311,18 +317,20 @@ namespace Crafter { return M; } - static MatrixRowMajor Rotation(Vector vector) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { + template + static MatrixRowMajor Rotation(Vector vector) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { return Rotation(vector.x, vector.y, vector.z); } - Vector TransformNormal(Vector V) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { - Vector Z = Vector(V.z, V.z, V.z); - Vector Y = Vector(V.y, V.y, V.y); - Vector X = Vector(V.x, V.x, V.x); + template + Vector TransformNormal(Vector V) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as) { + Vector Z = Vector(V.z, V.z, V.z); + Vector Y = Vector(V.y, V.y, V.y); + Vector X = Vector(V.x, V.x, V.x); - Vector Result = Z * Vector(m[2][0], m[2][1], m[2][2]); - Result = Y * Vector(m[1][0], m[1][1], m[1][2]) + Result; - Result = X * Vector(m[0][0], m[0][1], m[0][2]) + Result; + Vector Result = Z * Vector(m[2][0], m[2][1], m[2][2]); + Result = Y * Vector(m[1][0], m[1][1], m[1][2]) + Result; + Result = X * Vector(m[0][0], m[0][1], m[0][2]) + Result; return Result; } diff --git a/interfaces/Crafter.Math-Vector.cppm b/interfaces/Crafter.Math-Vector.cppm index 823fcc1..ba78af7 100755 --- a/interfaces/Crafter.Math-Vector.cppm +++ b/interfaces/Crafter.Math-Vector.cppm @@ -24,76 +24,76 @@ import :BasicTypes; import :Misc; namespace Crafter { - template - struct VectorBase { - T v[Len]; + template + struct __attribute__((packed)) VectorBase { + T v[Aligment]; }; - template - struct VectorBase { + template + struct __attribute__((packed)) VectorBase { union { - T v[1]; + T v[Aligment]; T x; }; }; - template - struct VectorBase { + template + struct __attribute__((packed)) VectorBase { union { - T v[2]; - struct { + T v[Aligment]; + struct __attribute__((packed)) { T x, y; }; }; - VectorBase(float x, float y): x(x), y(y) { + VectorBase(float x, float y): x(x), y(y) { } - VectorBase() = default; + VectorBase() = default; }; - template - struct VectorBase { + template + struct __attribute__((packed)) VectorBase { union { - T v[3]; - struct { + T v[Aligment]; + struct __attribute__((packed)) { T x, y, z; }; }; - VectorBase(float x, float y, float z): x(x), y(y), z(z) { + VectorBase(float x, float y, float z): x(x), y(y), z(z) { } - VectorBase() = default; + VectorBase() = default; }; - template - struct VectorBase { + template + struct __attribute__((packed)) VectorBase { union { - T v[4]; - struct { + T v[Aligment]; + struct __attribute__((packed)) { T x, y, z, w; }; }; - VectorBase(float x, float y, float z, float w): x(x), y(y), z(z), w(w) { + VectorBase(float x, float y, float z, float w): x(x), y(y), z(z), w(w) { } - VectorBase() = default; + VectorBase() = default; }; - export template - class Vector : public VectorBase { + export template + class Vector : public VectorBase { public: - Vector(float x, float y, float z, float w ) requires(std::same_as && Len == 4) : VectorBase(x, y, z, w) { + Vector(float x, float y, float z, float w ) requires(std::same_as && Len == 4) : VectorBase(x, y, z, w) { } - Vector(float x, float y, float z) requires(std::same_as && Len == 3) : VectorBase(x, y, z) { + Vector(float x, float y, float z) requires(std::same_as && Len == 3) : VectorBase(x, y, z) { } - Vector(float x, float y) requires(std::same_as && Len == 2) : VectorBase(x, y) { + Vector(float x, float y) requires(std::same_as && Len == 2) : VectorBase(x, y) { } Vector() = default; - static Vector QuaternionRotationRollPitchYaw(float Pitch, float Yaw, float Roll) requires(Len == 4) { + static Vector QuaternionRotationRollPitchYaw(float Pitch, float Yaw, float Roll) requires(Len == 4) { const float halfpitch = Pitch * 0.5f; float cp = std::cosf(halfpitch); float sp = std::sinf(halfpitch); @@ -106,7 +106,7 @@ namespace Crafter { float cr = std::cosf(halfroll); float sr = std::sinf(halfroll); - return Vector( + return Vector( cr * sp * cy + sr * cp * sy, cr * cp * sy - sr * sp * cy, sr * cp * cy - cr * sp * sy, @@ -115,52 +115,52 @@ namespace Crafter { } template - Vector operator+(Vector b){ - Vector resultVector; + Vector operator+(Vector b){ + Vector resultVector; for(std::uint32_t i = 0; i < std::min(Len, Blen); i++) { resultVector.v[i] = this->v[i]+b.v[i]; } return resultVector; } template - Vector operator-(Vector b){ - Vector resultVector; + Vector operator-(Vector b){ + Vector resultVector; for(std::uint32_t i = 0; i < std::min(Len, Blen); i++) { resultVector.v[i] = this->v[i]-b.v[i]; } return resultVector; } - Vector operator-(){ - Vector resultVector; + Vector operator-(){ + Vector resultVector; for(std::uint32_t i = 0; i < Len; i++) { resultVector.v[i] = -this->v[i]; } return resultVector; } template - Vector operator*(Vector b){ - Vector resultVector; + Vector operator*(Vector b){ + Vector resultVector; for(std::uint32_t i = 0; i < std::min(Len, Blen); i++) { resultVector.v[i] = this->v[i]*b.v[i]; } return resultVector; } template - Vector operator/(Vector b){ - Vector resultVector; + Vector operator/(Vector b){ + Vector resultVector; for(std::uint32_t i = 0; i < std::min(Len, Blen); i++) { resultVector.v[i] = this->v[i]/b.v[i]; } return resultVector; } - Vector Rotate(Vector rotation) requires(Len == 3) { - Vector q = rotation.QuaternionConjugate(); - Vector result = q.QuaternionMultiply(Vector(this->x, this->y, this->z, 0)); - return Vector(result.x, result.y, result.z); + Vector Rotate(Vector rotation) requires(Len == 3) { + Vector q = rotation.QuaternionConjugate(); + Vector result = q.QuaternionMultiply(Vector(this->x, this->y, this->z, 0)); + return Vector(result.x, result.y, result.z); } - Vector Normalize() requires(Len == 3) { + Vector Normalize() requires(Len == 3) { float fLength = Length(); // Prevent divide by zero @@ -169,10 +169,10 @@ namespace Crafter { fLength = 1.0f / fLength; } - return Vector(this->v[0] * fLength, this->v[1] * fLength, this->v[2] * fLength); + return Vector(this->v[0] * fLength, this->v[1] * fLength, this->v[2] * fLength); } - Vector Normalize() requires(Len == 4) { + Vector Normalize() requires(Len == 4) { float fLength = Length(); // Prevent divide by zero @@ -181,7 +181,7 @@ namespace Crafter { fLength = 1.0f / fLength; } - return Vector(this->v[0] * fLength, this->v[1] * fLength, this->v[2] * fLength, this->v[3] * fLength); + return Vector(this->v[0] * fLength, this->v[1] * fLength, this->v[2] * fLength, this->v[3] * fLength); } float Length() @@ -190,15 +190,15 @@ namespace Crafter { return std::sqrtf(Result); } - Vector ReciprocalLength() requires(Len == 3) { - Vector Result = LengthSq(); + Vector ReciprocalLength() requires(Len == 3) { + Vector Result = LengthSq(); Result = ReciprocalSqrt(Result); return Result; } - Vector ReciprocalSqrt() requires(Len == 3) + Vector ReciprocalSqrt() requires(Len == 3) { - return Vector( + return Vector( 1.f / std::sqrtf(this->v[0]), 1.f / std::sqrtf(this->v[1]), 1.f / std::sqrtf(this->v[2]) @@ -210,26 +210,26 @@ namespace Crafter { return Dot(*this); } - float Dot(Vector v2) requires(Len == 3) + float Dot(Vector v2) requires(Len == 3) { return this->v[0] * v2.v[0] + this->v[1] * v2.v[1] + this->v[2] * v2.v[2]; } - float Dot(Vector v2) requires(Len == 4) + float Dot(Vector v2) requires(Len == 4) { return this->v[0] * v2.v[0] + this->v[1] * v2.v[1] + this->v[2] * v2.v[2] + this->v[3] * v2.v[3]; } - Vector Cross(Vector v2) requires(Len == 3) { - return Vector( + Vector Cross(Vector v2) requires(Len == 3) { + return Vector( (this->v[1] * v2.v[2]) - (this->v[2] * v2.v[1]), (this->v[2] * v2.v[0]) - (this->v[0] * v2.v[2]), (this->v[0] * v2.v[1]) - (this->v[1] * v2.v[0]) ); }; - Vector QuaternionConjugate() requires(Len == 4) { - return Vector( + Vector QuaternionConjugate() requires(Len == 4) { + return Vector( -this->x, -this->y, -this->z, @@ -237,8 +237,8 @@ namespace Crafter { ); } - Vector QuaternionMultiply(Vector q2) requires(Len == 4) { - return Vector( + Vector QuaternionMultiply(Vector q2) requires(Len == 4) { + return Vector( (q2.v[3] * this->v[0]) + (q2.v[0] * this->v[3]) + (q2.v[1] * this->v[2]) - (q2.v[2] * this->v[1]), (q2.v[3] * this->v[1]) - (q2.v[0] * this->v[2]) + (q2.v[1] * this->v[3]) + (q2.v[2] * this->v[0]), (q2.v[3] * this->v[2]) + (q2.v[0] * this->v[1]) - (q2.v[1] * this->v[0]) + (q2.v[2] * this->v[3]), @@ -246,890 +246,43 @@ namespace Crafter { ); } - Vector QuaternionRotationAxis(float angle) requires(Len == 3) { - Vector Normal = Normalize(); + Vector QuaternionRotationAxis(float angle) requires(Len == 3) { + Vector Normal = Normalize(); return Normal.QuaternionRotationNormal(angle); } - Vector QuaternionRotationNormal(float angle) requires(Len == 3) { - Vector N = Vector(this->x, this->y, this->z, 1); + Vector QuaternionRotationNormal(float angle) requires(Len == 3) { + Vector N = Vector(this->x, this->y, this->z, 1); float SinV, CosV; XMScalarSinCos(&SinV, &CosV, 0.5f * angle); - Vector Scale = Vector(SinV, SinV, SinV, CosV); + Vector Scale = Vector(SinV, SinV, SinV, CosV); return N * Scale; } - static Vector NegativeMultiplySubtract(Vector a, Vector b, Vector c) requires(Len == 4) { - return Vector( + static Vector NegativeMultiplySubtract(Vector a, Vector b, Vector c) requires(Len == 4) { + return Vector( c.v[0] - (a.v[0] * b.v[0]), c.v[1] - (a.v[1] * b.v[1]), c.v[2] - (a.v[2] * b.v[2]), c.v[3] - (a.v[3] * b.v[3]) ); } - - - - -// typedef -// typename std::conditional<(sizeof(T)* len > 32 && (std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as)), __m512i, -// typename std::conditional<(sizeof(T)* len > 16 && (std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as)), __m256i, -// typename std::conditional<(sizeof(T)* len <= 16 && (std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as || std::same_as)), __m128i, -// typename std::conditional<(len > 16 && std::same_as), __m512h, -// typename std::conditional<(len > 8 && std::same_as), __m256h, -// typename std::conditional<(len <= 8 && std::same_as), __m128h, -// typename std::conditional<(len > 8 && std::same_as), __m512, -// typename std::conditional<(len > 4 && std::same_as), __m256, -// typename std::conditional<(len <= 4 && std::same_as), __m128, -// typename std::conditional<(len > 4 && std::same_as), __m512d, -// typename std::conditional<(len > 2 && std::same_as), __m256d, __m128d -// >::type>::type>::type>::type>::type>::type>::type>::type>::type>::type>::type vector_type; - - -// public: -// template -// static consteval uint8_t GetVectorAlignedSize() { -// if constexpr(std::same_as && std::same_as) { -// return 64; -// } else if constexpr(std::same_as || (std::same_as && std::same_as) || (std::same_as && std::same_as)) { -// return 32; -// } else if constexpr(std::same_as || std::same_as || (std::same_as && std::same_as) || (std::same_as && std::same_as) || (std::same_as && std::same_as)) { -// return 16; -// } else if constexpr(std::same_as || std::same_as || std::same_as || (std::same_as && std::same_as) || (std::same_as && std::same_as) || (std::same_as && std::same_as)) { -// return 8; -// } else if constexpr(std::same_as || std::same_as || (std::same_as && std::same_as) || (std::same_as && std::same_as)) { -// return 4; -// } else if constexpr(std::same_as || (std::same_as && std::same_as)) { -// return 2; -// } else{ -// throw std::invalid_argument(""); -// } -// } -// vector_type v; - -// Vector() {}; -// Vector(__m128h v) requires(std::same_as) : v(v) { } -// Vector(__m128 v) requires(std::same_as) : v(v) { } -// Vector(__m128d v) requires(std::same_as) : v(v) { } -// Vector(__m128i v) requires(std::same_as) : v(v) { } - -// Vector(__m256h v) requires(std::same_as) : v(v) { } -// Vector(__m256 v) requires(std::same_as) : v(v) { } -// Vector(__m256d v) requires(std::same_as) : v(v) { } -// Vector(__m256i v) requires(std::same_as) : v(v) { } - -// Vector(__m512h v) requires(std::same_as) : v(v) { } -// Vector(__m512 v) requires(std::same_as) : v(v) { } -// Vector(__m512d v) requires(std::same_as) : v(v) { } -// Vector(__m512i v) requires(std::same_as) : v(v) { } - -// template -// void operator+=(Vector b) requires(Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// this->v = (*this+b).v; -// } -// template -// void operator-=(Vector b) requires(Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// this->v = (*this-b).v; -// } -// template -// void operator*=(Vector b) requires(Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// this->v = (*this*b).v; -// } -// template -// void operator/=(Vector b) requires(Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// this->v = (*this/b).v; -// } - -// std::string ToString() const { -// std::ostringstream ss; -// ss << "{ "; -// T store[GetVectorAlignedSize()]; -// Store(store); -// for(uint8_t i = 0; i < len; i++) { -// ss << std::format("{}", store[i]); -// if(i+1 < len) { -// ss << ", "; -// } -// } -// ss << " }"; -// return std::string(ss.str()); -// } -// #pragma region 128 -// Vector( -// const __fp16& x0 = 0, const __fp16& y0 = 0, const __fp16& z0 = 0, const __fp16& w0 = 0, -// const __fp16& x1 = 0, const __fp16& y1 = 0, const __fp16& z1 = 0, const __fp16& w1 = 0 -// ) requires(std::same_as && std::same_as) { -// __fp16 temp[]{ x0,y0,z0,w0,x1,y1,z1,w1,}; -// v = _mm_load_ph(temp); -// } - -// Vector(float x0 = 0, float y0 = 0, float z0 = 0, float w0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm_set_ps(w0, z0, y0, x0); -// } - -// Vector(double x0 = 0, double y0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm_set_pd(y0, x0); -// } - -// Vector( -// int8_t x0 = 0, int8_t y0 = 0, int8_t z0 = 0, int8_t w0 = 0, -// int8_t x1 = 0, int8_t y1 = 0, int8_t z1 = 0, int8_t w1 = 0, -// int8_t x2 = 0, int8_t y2 = 0, int8_t z2 = 0, int8_t w2 = 0, -// int8_t x3 = 0, int8_t y3 = 0, int8_t z3 = 0, int8_t w3 = 0 -// ) requires(std::same_as && std::same_as) { -// v = _mm_set_epi8(w3, z3, y3, x3, w2, z2, y2, x2, w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector( -// int16_t x0 = 0, int16_t y0 = 0, int16_t z0 = 0, int16_t w0 = 0, -// int16_t x1 = 0, int16_t y1 = 0, int16_t z1 = 0, int16_t w1 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm_set_epi16(w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector(int32_t x0 = 0, int32_t y0 = 0, int32_t z0 = 0, int32_t w0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm_set_epi32(w0, z0, y0, x0); -// } - -// Vector(int64_t x0 = 0, int64_t y0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm_set_epi64x(y0, x0); -// } - -// Vector( -// uint8_t x0 = 0, uint8_t y0 = 0, uint8_t z0 = 0, uint8_t w0 = 0, -// uint8_t x1 = 0, uint8_t y1 = 0, uint8_t z1 = 0, uint8_t w1 = 0, -// uint8_t x2 = 0, uint8_t y2 = 0, uint8_t z2 = 0, uint8_t w2 = 0, -// uint8_t x3 = 0, uint8_t y3 = 0, uint8_t z3 = 0, uint8_t w3 = 0 -// ) requires(std::same_as && std::same_as) { -// v = _mm_set_epi8(w3, z3, y3, x3, w2, z2, y2, x2, w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector( -// uint16_t x0 = 0, uint16_t y0 = 0, uint16_t z0 = 0, uint16_t w0 = 0, -// uint16_t x1 = 0, uint16_t y1 = 0, uint16_t z1 = 0, uint16_t w1 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm_set_epi16(w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector(uint32_t x0 = 0, uint32_t y0 = 0, uint32_t z0 = 0, uint32_t w0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm_set_epi32(w0, z0, y0, x0); -// } - -// Vector(uint64_t x0 = 0, uint64_t y0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm_set_epi64x(y0, x0); -// } - -// static Vector Zero() requires(std::same_as) { -// return Vector(_mm_setzero_ps()); -// } - -// void Store(T* data) const requires(std::same_as) { -// _mm_storeu_ph(reinterpret_cast(data), reinterpret_cast<__m128h>(v)); -// } -// void Store(T* data) const requires(std::same_as) { -// _mm_storeu_ps(reinterpret_cast(data), reinterpret_cast<__m128>(v)); -// } -// void Store(T* data) const requires(std::same_as) { -// _mm_storeu_pd(data, reinterpret_cast<__m128d>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm_storeu_epi8(reinterpret_cast(data), reinterpret_cast<__m128i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm_storeu_epi16(reinterpret_cast(data), reinterpret_cast<__m128i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm_storeu_epi32(reinterpret_cast(data), reinterpret_cast<__m128i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm_storeu_epi64(reinterpret_cast(data), reinterpret_cast<__m128i>(v)); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_add_ph(reinterpret_cast<__m128h>(v), reinterpret_cast<__m128h>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_sub_ph(reinterpret_cast<__m128h>(v), reinterpret_cast<__m128h>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_mul_ph(reinterpret_cast<__m128h>(v), reinterpret_cast<__m128h>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_div_ph(reinterpret_cast<__m128h>(v), reinterpret_cast<__m128h>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_add_ps(reinterpret_cast<__m128>(v), reinterpret_cast<__m128>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_sub_ps(reinterpret_cast<__m128>(v), reinterpret_cast<__m128>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_mul_ps(reinterpret_cast<__m128>(v), reinterpret_cast<__m128>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_div_ps(reinterpret_cast<__m128>(v), reinterpret_cast<__m128>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_add_pd(reinterpret_cast<__m128d>(v), reinterpret_cast<__m128d>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_sub_pd(reinterpret_cast<__m128d>(v), reinterpret_cast<__m128d>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_mul_pd(reinterpret_cast<__m128d>(v), reinterpret_cast<__m128d>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_div_pd(reinterpret_cast<__m128d>(v), reinterpret_cast<__m128d>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_add_epi8(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_sub_epi8(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi8(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi8(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_add_epi16(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_sub_epi16(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi16(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi16(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_add_epi32(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_sub_epi32(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_mul_epi32(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi32(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_add_epi64(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm_sub_epi64(reinterpret_cast<__m128i>(v), reinterpret_cast<__m128i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi64(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi64(v, bv)); -// // } - -// template -// Vector AddMask() { - -// } -// #pragma endregion -// #pragma region 256 -// Vector( -// const __fp16& x0 = 0, const __fp16& y0 = 0, const __fp16& z0 = 0, const __fp16& w0 = 0, -// const __fp16& x1 = 0, const __fp16& y1 = 0, const __fp16& z1 = 0, const __fp16& w1 = 0, -// const __fp16& x2 = 0, const __fp16& y2 = 0, const __fp16& z2 = 0, const __fp16& w2 = 0, -// const __fp16& x3 = 0, const __fp16& y3 = 0, const __fp16& z3 = 0, const __fp16& w3 = 0 -// ) requires(std::same_as&& std::same_as) { -// __fp16 temp[]{ w0,z0,y0,x0,w1,z1,y1,x1,w2,z2,y2,x2,w3,z3,y3,x3 }; -// v = _mm256_load_ph(temp); -// } - -// Vector( -// float x0 = 0, float y0 = 0, float z0 = 0, float w0 = 0, -// float x1 = 0, float y1 = 0, float z1 = 0, float w1 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm256_set_ps(w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector(double x0 = 0, double y0 = 0, double z0 = 0, double w0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm256_set_pd(w0, z0, y0, x0); -// } - -// Vector( -// int8_t x0 = 0, int8_t y0 = 0, int8_t z0 = 0, int8_t w0 = 0, -// int8_t x1 = 0, int8_t y1 = 0, int8_t z1 = 0, int8_t w1 = 0, -// int8_t x2 = 0, int8_t y2 = 0, int8_t z2 = 0, int8_t w2 = 0, -// int8_t x3 = 0, int8_t y3 = 0, int8_t z3 = 0, int8_t w3 = 0, -// int8_t x4 = 0, int8_t y4 = 0, int8_t z4 = 0, int8_t w4 = 0, -// int8_t x5 = 0, int8_t y5 = 0, int8_t z5 = 0, int8_t w5 = 0, -// int8_t x6 = 0, int8_t y6 = 0, int8_t z6 = 0, int8_t w6 = 0, -// int8_t x7 = 0, int8_t y7 = 0, int8_t z7 = 0, int8_t w7 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm256_set_epi8(w7, z7, y7, x7, w6, z6, y6, x6, w5, z5, y5, x5, w4, z4, y4, x4, w3, z3, y3, x3, w2, z2, y2, x2, w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector( -// int16_t x0 = 0, int16_t y0 = 0, int16_t z0 = 0, int16_t w0 = 0, -// int16_t x1 = 0, int16_t y1 = 0, int16_t z1 = 0, int16_t w1 = 0, -// int16_t x2 = 0, int16_t y2 = 0, int16_t z2 = 0, int16_t w2 = 0, -// int16_t x3 = 0, int16_t y3 = 0, int16_t z3 = 0, int16_t w3 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm256_set_epi16(w3, z3, y3, x3, w2, z2, y2, x2, w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector( -// int32_t x0 = 0, int32_t y0 = 0, int32_t z0 = 0, int32_t w0 = 0, -// int32_t x1 = 0, int32_t y1 = 0, int32_t z1 = 0, int32_t w1 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm256_set_epi32(w1, z1, y1, x1, w0, z0, y0, x0); -// } - -// Vector(int64_t x0 = 0, int64_t y0 = 0, int64_t z0 = 0, int64_t w0 = 0) requires(std::same_as&& std::same_as) { -// v = _mm256_set_epi64x(w0, z0, y0, x0); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_add_ph(reinterpret_cast<__m256h>(v), reinterpret_cast<__m256h>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_sub_ph(reinterpret_cast<__m256h>(v), reinterpret_cast<__m256h>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_mul_ph(reinterpret_cast<__m256h>(v), reinterpret_cast<__m256h>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_div_ph(reinterpret_cast<__m256h>(v), reinterpret_cast<__m256h>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_add_ps(reinterpret_cast<__m256>(v), reinterpret_cast<__m256>(b.v))); -// } - -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_sub_ps(reinterpret_cast<__m256>(v), reinterpret_cast<__m256>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_mul_ps(reinterpret_cast<__m256>(v), reinterpret_cast<__m256>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_div_ps(reinterpret_cast<__m256>(v), reinterpret_cast<__m256>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_add_pd(reinterpret_cast<__m256d>(v), reinterpret_cast<__m256d>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_sub_pd(reinterpret_cast<__m256d>(v), reinterpret_cast<__m256d>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_mul_pd(reinterpret_cast<__m256d>(v), reinterpret_cast<__m256d>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_div_pd(reinterpret_cast<__m256d>(v), reinterpret_cast<__m256d>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_add_epi8(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_sub_epi8(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi8(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi8(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_add_epi16(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_sub_epi16(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi16(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi16(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_add_epi32(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_sub_epi32(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_mul_epi32(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi32(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_add_epi64(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm256_sub_epi64(reinterpret_cast<__m256i>(v), reinterpret_cast<__m256i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi64(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi64(v, bv)); -// // } - -// void Store(T* data) const requires(std::same_as) { -// _mm256_storeu_ph(reinterpret_cast(data), reinterpret_cast<__m256h>(v)); -// } -// void Store(T* data) const requires(std::same_as) { -// _mm256_storeu_ps(data, reinterpret_cast<__m256>(v)); -// } -// void Store(T* data) const requires(std::same_as) { -// _mm256_storeu_pd(data, reinterpret_cast<__m256d>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm256_storeu_epi8(reinterpret_cast(data), reinterpret_cast<__m256i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm256_storeu_epi16(reinterpret_cast(data), reinterpret_cast<__m256i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm256_storeu_epi32(reinterpret_cast(data), reinterpret_cast<__m256i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm256_storeu_epi64(reinterpret_cast(data), reinterpret_cast<__m256i>(v)); -// } -// #pragma endregion -// #pragma region 512 -// Vector( -// const __fp16& x0 = 0, const __fp16& y0 = 0, const __fp16& z0 = 0, const __fp16& w0 = 0, -// const __fp16& x1 = 0, const __fp16& y1 = 0, const __fp16& z1 = 0, const __fp16& w1 = 0, -// const __fp16& x2 = 0, const __fp16& y2 = 0, const __fp16& z2 = 0, const __fp16& w2 = 0, -// const __fp16& x3 = 0, const __fp16& y3 = 0, const __fp16& z3 = 0, const __fp16& w3 = 0, -// const __fp16& x4 = 0, const __fp16& y4 = 0, const __fp16& z4 = 0, const __fp16& w4 = 0, -// const __fp16& x5 = 0, const __fp16& y5 = 0, const __fp16& z5 = 0, const __fp16& w5 = 0, -// const __fp16& x6 = 0, const __fp16& y6 = 0, const __fp16& z6 = 0, const __fp16& w6 = 0, -// const __fp16& x7 = 0, const __fp16& y7 = 0, const __fp16& z7 = 0, const __fp16& w7 = 0 -// ) requires(std::same_as&& std::same_as) { -// __fp16 temp[]{ w0,z0,y0,x0, w1,z1,y1,x1, w2,z2,y2,x2,w3, z3,y3,x3, w4,z4,y4,x4, w5,z5,y5,x5, w6,z6,y6,x6, w7,z7,y7,x7 }; -// v = _mm512_load_ph(temp); -// } - -// Vector( -// float x0 = 0, float y0 = 0, float z0 = 0, float w0 = 0, -// float x1 = 0, float y1 = 0, float z1 = 0, float w1 = 0, -// float x2 = 0, float y2 = 0, float z2 = 0, float w2 = 0, -// float x3 = 0, float y3 = 0, float z3 = 0, float w3 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm512_set_ps( -// w3, z3, y3, x3, -// w2, z2, y2, x2, -// w1, z1, y1, x1, -// w0, z0, y0, x0 -// ); -// } - -// Vector( -// double x0 = 0, double y0 = 0, double z0 = 0, double w0 = 0, -// double x1 = 0, double y1 = 0, double z1 = 0, double w1 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm512_set_pd( -// w1, z1, y1, x1, -// w0, z0, y0, x0 -// ); -// } - -// Vector( -// int8_t x0 = 0, int8_t y0 = 0, int8_t z0 = 0, int8_t w0 = 0, -// int8_t x1 = 0, int8_t y1 = 0, int8_t z1 = 0, int8_t w1 = 0, -// int8_t x2 = 0, int8_t y2 = 0, int8_t z2 = 0, int8_t w2 = 0, -// int8_t x3 = 0, int8_t y3 = 0, int8_t z3 = 0, int8_t w3 = 0, -// int8_t x4 = 0, int8_t y4 = 0, int8_t z4 = 0, int8_t w4 = 0, -// int8_t x5 = 0, int8_t y5 = 0, int8_t z5 = 0, int8_t w5 = 0, -// int8_t x6 = 0, int8_t y6 = 0, int8_t z6 = 0, int8_t w6 = 0, -// int8_t x7 = 0, int8_t y7 = 0, int8_t z7 = 0, int8_t w7 = 0, -// int8_t x8 = 0, int8_t y8 = 0, int8_t z8 = 0, int8_t w8 = 0, -// int8_t x9 = 0, int8_t y9 = 0, int8_t z9 = 0, int8_t w9 = 0, -// int8_t x10 = 0, int8_t y10 = 0, int8_t z10 = 0, int8_t w10 = 0, -// int8_t x11 = 0, int8_t y11 = 0, int8_t z11 = 0, int8_t w11 = 0, -// int8_t x12 = 0, int8_t y12 = 0, int8_t z12 = 0, int8_t w12 = 0, -// int8_t x13 = 0, int8_t y13 = 0, int8_t z13 = 0, int8_t w13 = 0, -// int8_t x14 = 0, int8_t y14 = 0, int8_t z14 = 0, int8_t w14 = 0, -// int8_t x15 = 0, int8_t y15 = 0, int8_t z15 = 0, int8_t w15 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm512_set_epi8( -// w15, z15, y15, x15, -// w14, z14, y14, x14, -// w13, z13, y13, x13, -// w12, z12, y12, x12, -// w11, z11, y11, x11, -// w10, z10, y10, x10, -// w9, z9, y9, x9, -// w8, z8, y8, x8, -// w7, z7, y7, x7, -// w6, z6, y6, x6, -// w5, z5, y5, x5, -// w4, z4, y4, x4, -// w3, z3, y3, x3, -// w2, z2, y2, x2, -// w1, z1, y1, x1, -// w0, z0, y0, x0 -// ); -// } - -// Vector( -// int16_t x0 = 0, int16_t y0 = 0, int16_t z0 = 0, int16_t w0 = 0, -// int16_t x1 = 0, int16_t y1 = 0, int16_t z1 = 0, int16_t w1 = 0, -// int16_t x2 = 0, int16_t y2 = 0, int16_t z2 = 0, int16_t w2 = 0, -// int16_t x3 = 0, int16_t y3 = 0, int16_t z3 = 0, int16_t w3 = 0, -// int16_t x4 = 0, int16_t y4 = 0, int16_t z4 = 0, int16_t w4 = 0, -// int16_t x5 = 0, int16_t y5 = 0, int16_t z5 = 0, int16_t w5 = 0, -// int16_t x6 = 0, int16_t y6 = 0, int16_t z6 = 0, int16_t w6 = 0, -// int16_t x7 = 0, int16_t y7 = 0, int16_t z7 = 0, int16_t w7 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm512_set_epi16( -// w7, z7, y7, x7, -// w6, z6, y6, x6, -// w5, z5, y5, x5, -// w4, z4, y4, x4, -// w3, z3, y3, x3, -// w2, z2, y2, x2, -// w1, z1, y1, x1, -// w0, z0, y0, x0 -// ); -// } - -// Vector( -// int32_t x0 = 0, int32_t y0 = 0, int32_t z0 = 0, int32_t w0 = 0, -// int32_t x1 = 0, int32_t y1 = 0, int32_t z1 = 0, int32_t w1 = 0, -// int32_t x2 = 0, int32_t y2 = 0, int32_t z2 = 0, int32_t w2 = 0, -// int32_t x3 = 0, int32_t y3 = 0, int32_t z3 = 0, int32_t w3 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm512_set_epi32( -// w3, z3, y3, x3, -// w2, z2, y2, x2, -// w1, z1, y1, x1, -// w0, z0, y0, x0 -// ); -// } - -// Vector( -// int64_t x0 = 0, int64_t y0 = 0, int64_t z0 = 0, int64_t w0 = 0, -// int64_t x1 = 0, int64_t y1 = 0, int64_t z1 = 0, int64_t w1 = 0 -// ) requires(std::same_as&& std::same_as) { -// v = _mm512_set_epi64( -// w1, z1, y1, x1, -// w0, z0, y0, x0 -// ); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_add_ph(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_sub_ph(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_mul_ph(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_div_ph(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_add_ps(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_sub_ps(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_mul_ps(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_div_ps(reinterpret_cast<__m512>(v), reinterpret_cast<__m512>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_add_pd(reinterpret_cast<__m512d>(v), reinterpret_cast<__m512d>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_sub_pd(reinterpret_cast<__m512d>(v), reinterpret_cast<__m512d>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_mul_pd(reinterpret_cast<__m512d>(v), reinterpret_cast<__m512d>(b.v))); -// } -// template -// Vector operator/(Vector b) requires(std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_div_pd(reinterpret_cast<__m512d>(v), reinterpret_cast<__m512d>(b.v))); -// } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_add_epi8(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_sub_epi8(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi8(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi8(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_add_epi16(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_sub_epi16(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi16(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi16(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_add_epi32(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_sub_epi32(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// template -// Vector operator*(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_mul_epi32(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi32(v, bv)); -// // } - -// template -// Vector operator+(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_add_epi64(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// template -// Vector operator-(Vector b) requires(std::same_as && std::same_as && Vector::GetVectorAlignedSize() == GetVectorAlignedSize()) { -// return Vector(_mm512_sub_epi64(reinterpret_cast<__m512i>(v), reinterpret_cast<__m512i>(b.v))); -// } -// // template -// // Vector operator*(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_mul_epi64(v, bv)); -// // } -// // template -// // Vector operator/(Vector b) requires(std::same_as && std::same_as) { -// // __m512i v = this->v; -// // __m512i bv = b.v; -// // return Vector(_mm512_div_epi64(v, bv)); -// // } - -// void Store(T* data) const requires(std::same_as) { -// _mm512_storeu_ph(reinterpret_cast(data), reinterpret_cast<__m512h>(v)); -// } -// void Store(T* data) const requires(std::same_as) { -// _mm512_storeu_ps(reinterpret_cast(data), reinterpret_cast<__m512>(v)); -// } -// void Store(T* data) const requires(std::same_as) { -// _mm512_storeu_pd(data, reinterpret_cast<__m512d>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm512_storeu_epi8(reinterpret_cast(data), reinterpret_cast<__m512i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm512_storeu_epi16(reinterpret_cast(data), reinterpret_cast<__m512i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm512_storeu_epi32(reinterpret_cast(data), reinterpret_cast<__m512i>(v)); -// } -// void Store(T* data) const requires(std::same_as && std::same_as) { -// _mm512_storeu_epi64(reinterpret_cast(data), reinterpret_cast<__m512i>(v)); -// } -// #pragma endregion -// }; - -// export template -// class VectorVector : public Vector { -// public: -// VectorVector(__m128h v0, __m128h v1) requires(std::same_as && vectorLenght*Vector::GetVectorAlignedSize() == Vector::GetVectorAlignedSize()) { -// this->v = _mm256_castps128_ps256(v0); -// this->v = _mm256_insertf128_ps(this->v,v1,1); -// } -// VectorVector(__m128 v0, __m128 v1, __m128 v2, __m128 v3) requires(std::same_as && vectorLenght*Vector::GetVectorAlignedSize() == Vector::GetVectorAlignedSize()) { -// this->v = _mm512_castps256_ps512(_mm256_castps128_ps256(v0)); -// this->v = _mm512_insertfloatx4(this->v, v1, 1); -// this->v = _mm512_insertfloatx4(this->v, v2, 2); -// this->v = _mm512_insertfloatx4(this->v, v3, 3); -// } -// VectorVector(__m512 v) : Vector(v) { //requires(std::same_as && vectorLenght*Vector::GetVectorAlignedSize() == Vector::GetVectorAlignedSize()) : Vector(v) - -// } -// VectorVector( -// float x0 = 0, float y0 = 0, float z0 = 0, -// float x1 = 0, float y1 = 0, float z1 = 0, -// float x2 = 0, float y2 = 0, float z2 = 0, -// float x3 = 0, float y3 = 0, float z3 = 0, -// float x4 = 0, float y4 = 0, float z4 = 0, -// float x5 = 0 -// ) requires(std::same_as && vectorLenght*Vector::GetVectorAlignedSize() == Vector::GetVectorAlignedSize() && len == 3) : -// Vector( -// x0,y0,z0, -// x1,y1,z1, -// x2,y2,z2, -// x3,y3,z3, -// x4,y4,z4, -// x5) -// {} - -// VectorVector( -// float x0 = 0, float y0 = 0, float z0 = 0, float w0 = 0, -// float x1 = 0, float y1 = 0, float z1 = 0, float w1 = 0, -// float x2 = 0, float y2 = 0, float z2 = 0, float w2 = 0, -// float x3 = 0, float y3 = 0, float z3 = 0, float w3 = 0 -// ) : -// Vector( -// w3, z3, y3, x3, -// w2, z2, y2, x2, -// w1, z1, y1, x1, -// w0, z0, y0, x0) -// {} }; } template <> -struct std::formatter> : std::formatter { - auto format(const Crafter::Vector& obj, format_context& ctx) const { +struct std::formatter> : std::formatter { + auto format(const Crafter::Vector& obj, format_context& ctx) const { return std::formatter::format(std::format("{{{}, {}, {}}}", obj.x, obj.y, obj.z ), ctx); } + auto format(const Crafter::Vector& obj, format_context& ctx) const { + return std::formatter::format(std::format("{{{}, {}, {}, {}}}", + obj.x, obj.y, obj.z, obj.w + ), ctx); + } }; \ No newline at end of file