Added abs, pow and product operations

This commit is contained in:
adrien
2026-04-22 14:50:21 +02:00
parent c4e462add3
commit 0dd9e02f59
4 changed files with 131 additions and 6 deletions
+9
View File
@@ -75,6 +75,15 @@ pub fn sub(comptime a: Self, comptime b: Self) Self {
return result;
}
/// Multiply exponents by a scalar integer. Used internally by `pow` in Scalar.
pub fn scale(comptime a: Self, comptime exp: comptime_int) Self {
@setEvalBranchQuota(10_000);
var result = Self.initFill(0);
inline for (std.enums.values(Dimension)) |d|
result.set(d, a.get(d) * exp);
return result;
}
/// Returns true if every dimension exponent is equal. Used to enforce type compatibility in `add`, `sub`, `to`.
pub fn eql(comptime a: Self, comptime b: Self) bool {
inline for (std.enums.values(Dimension)) |d|