diff --git a/src/builtins/transpose.c b/src/builtins/transpose.c index fc4d3c5c..6855e6a2 100644 --- a/src/builtins/transpose.c +++ b/src/builtins/transpose.c @@ -379,7 +379,43 @@ B transp_uc1(B t, B o, B x) { return transp_im(m_f64(0), c1(o, transp_c1(t, x))); } -void transp_init(void) { - c(BFn,bi_transp)->uc1 = transp_uc1; - c(BFn,bi_transp)->im = transp_im; +B transp_ix(B t, B w, B x) { + if (isAtm(x)) thrM("ā‰ā¼: š•© must not be an atom"); + ur xr=RNK(x); + + if (isAtm(w)) { + if (xr<1) thrM("ā‰ā¼: Length of š•Ø must be at most rank of š•©"); + usz a=o2s(w); + if (a>=xr) thrF("ā‰ā¼: Axis %s does not exist (%i≔=š•©)", a, xr); + i32* wp; w = m_i32arrv(&wp, a); + PLAINLOOP for (usz i=0; i1) thrM("ā‰ā¼: š•Ø must have rank at most 1"); + usz wia = IA(w); + if (wia==0) { decG(w); return x; } + if (xr=xr) thrF("ā‰ā¼: Axis %s does not exist (%i≔=š•©)", a, xr); + if (p[i]!=xr) thrM("ā‰ā¼: Duplicate axes"); + max = a>max? a : max; + p[a] = i; + } + decG(w); + usz n = max+1; + i32* wp; w = m_i32arrv(&wp, n); + for (usz i=0, j=wia; iim = transp_im; + c(BFn,bi_transp)->ix = transp_ix; + c(BFn,bi_transp)->uc1 = transp_uc1; }