mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 15:12:31 +00:00
Compare commits
4 Commits
0a96f4e2e9
...
cfd62e7e06
Author | SHA1 | Date | |
---|---|---|---|
|
cfd62e7e06 | ||
|
87863a834b | ||
|
f9c0dd0450 | ||
|
2682c359f9 |
@ -1805,7 +1805,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
||||
lp.path = b.fmt("{}", .{output_dir});
|
||||
}
|
||||
|
||||
// -femit-bin[=path] (default) Output machine code
|
||||
// -femit-bin[=path] (default) Produce and output a binary to an optional path. Defaults to the current working directory.
|
||||
if (compile.generated_bin) |bin| {
|
||||
bin.path = output_dir.joinString(b.allocator, compile.out_filename) catch @panic("OOM");
|
||||
}
|
||||
|
@ -115,6 +115,10 @@ pub fn Complex(comptime T: type) type {
|
||||
pub fn magnitude(self: Self) T {
|
||||
return @sqrt(self.re * self.re + self.im * self.im);
|
||||
}
|
||||
|
||||
pub fn squaredMagnitude(self: Self) T {
|
||||
return self.re * self.re + self.im * self.im;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -189,6 +193,13 @@ test "magnitude" {
|
||||
try testing.expect(math.approxEqAbs(f32, c, 5.83095, epsilon));
|
||||
}
|
||||
|
||||
test "squaredMagnitude" {
|
||||
const a = Complex(f32).init(5, 3);
|
||||
const c = a.squaredMagnitude();
|
||||
|
||||
try testing.expect(math.approxEqAbs(f32, c, math.pow(f32, a.magnitude(), 2), epsilon));
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("complex/abs.zig");
|
||||
_ = @import("complex/acosh.zig");
|
||||
|
@ -414,7 +414,7 @@ const usage_build_generic =
|
||||
\\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
|
||||
\\ -fincremental Enable incremental compilation
|
||||
\\ -fno-incremental Disable incremental compilation
|
||||
\\ -femit-bin[=path] (default) Output machine code
|
||||
\\ -femit-bin[=path] (default) Produce and output a binary to an optional path. Defaults to the current working directory.
|
||||
\\ -fno-emit-bin Do not output machine code
|
||||
\\ -femit-asm[=path] Output .s (assembly code)
|
||||
\\ -fno-emit-asm (default) Do not output .s (assembly code)
|
||||
|
Loading…
Reference in New Issue
Block a user