mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix conj
This commit is contained in:
+1
-2
@@ -2,10 +2,9 @@
|
|||||||
#import "os.odin";
|
#import "os.odin";
|
||||||
#import "math.odin";
|
#import "math.odin";
|
||||||
|
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
x := 1+2i+3j+4k;
|
x := 1+2i+3j+4k;
|
||||||
y := 3-4i-5j-6k;
|
y := conj(x);
|
||||||
z := x/y;
|
z := x/y;
|
||||||
fmt.println(z, abs(z));
|
fmt.println(z, abs(z));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4003,14 +4003,14 @@ irValue *ir_build_expr(irProcedure *proc, AstNode *expr) {
|
|||||||
irValue *res = NULL;
|
irValue *res = NULL;
|
||||||
Type *t = ir_type(val);
|
Type *t = ir_type(val);
|
||||||
if (is_type_complex(t)) {
|
if (is_type_complex(t)) {
|
||||||
irValue *res = ir_add_local_generated(proc, tv->type);
|
res = ir_add_local_generated(proc, tv->type);
|
||||||
irValue *real = ir_emit_struct_ev(proc, val, 0);
|
irValue *real = ir_emit_struct_ev(proc, val, 0);
|
||||||
irValue *imag = ir_emit_struct_ev(proc, val, 1);
|
irValue *imag = ir_emit_struct_ev(proc, val, 1);
|
||||||
imag = ir_emit_unary_arith(proc, Token_Sub, imag, ir_type(imag));
|
imag = ir_emit_unary_arith(proc, Token_Sub, imag, ir_type(imag));
|
||||||
ir_emit_store(proc, ir_emit_struct_ep(proc, res, 0), real);
|
ir_emit_store(proc, ir_emit_struct_ep(proc, res, 0), real);
|
||||||
ir_emit_store(proc, ir_emit_struct_ep(proc, res, 1), imag);
|
ir_emit_store(proc, ir_emit_struct_ep(proc, res, 1), imag);
|
||||||
} else if (is_type_quaternion(t)) {
|
} else if (is_type_quaternion(t)) {
|
||||||
irValue *res = ir_add_local_generated(proc, tv->type);
|
res = ir_add_local_generated(proc, tv->type);
|
||||||
irValue *real = ir_emit_struct_ev(proc, val, 0);
|
irValue *real = ir_emit_struct_ev(proc, val, 0);
|
||||||
irValue *imag = ir_emit_struct_ev(proc, val, 1);
|
irValue *imag = ir_emit_struct_ev(proc, val, 1);
|
||||||
irValue *jmag = ir_emit_struct_ev(proc, val, 2);
|
irValue *jmag = ir_emit_struct_ev(proc, val, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user