diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-26 13:00:39 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-26 13:00:39 +0000 |
commit | 7f66d444451dab0e831cc0f14cc77ad691936f42 (patch) | |
tree | 99317b43b795d040c78490769738ef0171168e7d /array.c | |
parent | a328d13015fc4cbe34d99ddcfd36754e860dac00 (diff) |
Implement inner product . and outer product ⌾
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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); |