From 58a17583638f950fb04032984334cc68ed488f16 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 28 Aug 2023 20:32:29 +0900 Subject: [PATCH] [qfcc] Implement the regressive product That went surprisingly well (but it is built up from other ops, so pretty easy, really). --- tools/qfcc/source/expr_algebra.c | 6 ++++-- tools/qfcc/source/qc-parse.y | 1 + tools/qfcc/test/pga2d.r | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/expr_algebra.c b/tools/qfcc/source/expr_algebra.c index ff86773de..31a2849d5 100644 --- a/tools/qfcc/source/expr_algebra.c +++ b/tools/qfcc/source/expr_algebra.c @@ -1342,8 +1342,10 @@ geometric_product (expr_t *e1, expr_t *e2) static expr_t * regressive_product (expr_t *e1, expr_t *e2) { - notice (e1, "not implemented"); - return 0; + auto a = algebra_dual (e1); + auto b = algebra_dual (e2); + auto c = outer_product (a, b); + return algebra_dual (c); } static expr_t * diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index a0973228d..14fba3772 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -1773,6 +1773,7 @@ expr | expr CROSS expr { $$ = binary_expr (CROSS, $1, $3); } | expr DOT expr { $$ = binary_expr (DOT, $1, $3); } | expr WEDGE expr { $$ = binary_expr (WEDGE, $1, $3); } + | expr REGRESSIVE expr { $$ = binary_expr (REGRESSIVE, $1, $3); } ; texpr diff --git a/tools/qfcc/test/pga2d.r b/tools/qfcc/test/pga2d.r index eade23e33..6074fd46d 100644 --- a/tools/qfcc/test/pga2d.r +++ b/tools/qfcc/test/pga2d.r @@ -265,5 +265,10 @@ main (void) s.scalar, s.bvec); return 1; } + auto line = bvec ∨ bvecb; + if ((dvec3)line != '-11 8 34'd) { + printf ("bvec ∨ bvecb != '-11 8 34': %lv\n", line); + return 1; + } return 0; // to survive and prevail :) }