From 7f66d444451dab0e831cc0f14cc77ad691936f42 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 26 Jan 2022 13:00:39 +0000 Subject: =?UTF-8?q?Implement=20inner=20product=20.=20and=20outer=20product?= =?UTF-8?q?=20=E2=8C=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- array.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'array.c') diff --git a/array.c b/array.c index 7efc1b0..a4bde78 100644 --- a/array.c +++ b/array.c @@ -335,7 +335,23 @@ fillelement(Array *a) case AtypeInt: return mkscalarint(0); case AtypeFloat: return mkscalarfloat(0); case AtypeRune: return mkscalarrune(' '); - case AtypeArray: + case AtypeMixed:{ + Array *first = arrayitem(a, 0); + Array *fill = fillelement(first); + freearray(first); + return fill; + } + case AtypeArray:{ + Array *b = duparrayshape(a, a->type); + for(int i = 0; i < b->size; i++){ + Array *fill = fillelement(a->arraydata[i]); + Array *shape = fnShape(a->arraydata[i]); + b->arraydata[i] = fnReshape(shape, fill); + freearray(fill); + freearray(shape); + } + return b; + } default: print("Can't make fill element of array type %d\n", a->type); exits(nil); -- cgit v1.2.3