- $$MASK_TO_INT and $$INT_TO_MASK to create bool masks from integers and back.

- Fix bug when creating bool vectors in certain cases.
This commit is contained in:
Christoffer Lerno
2025-12-25 20:55:11 +01:00
parent 18b246c577
commit f3b71ed7eb
13 changed files with 193 additions and 30 deletions

View File

@@ -462,6 +462,7 @@ macro swizzle(v, ...) @builtin
return $$swizzle(v, $vasplat);
}
<*
Shuffle two vectors by a common index from arranging the vectors sequentially in memory

View File

@@ -3,6 +3,20 @@
module std::math::vector;
import std::math;
<*
@require $Type.kindof == VECTOR &&& $kindof(($Type){}[0]) == BOOL : "Expected a bool vector"
@require $kindof(mask).is_int() : "Expected an integer mask"
*>
macro bool[<*>] mask_from_int($Type, mask)
{
return $$int_to_mask(mask, $Type.len);
}
macro bool[<*>].mask_to_int(self)
{
return $$mask_to_int(self);
}
macro double double[<*>].sq_magnitude(self) => self.dot(self);
macro float float[<*>].sq_magnitude(self) => self.dot(self);