shProd
This commit is contained in:
parent
b2b0e4f92a
commit
cc44b3e57b
@ -247,8 +247,8 @@ B rank_c1(Md2D* d, B x) { B f = d->f; B g = d->g;
|
|||||||
if (Q_BI(f,lt) && a(x)->ia!=0 && rnk(x)>1) return toKCells(x, k);
|
if (Q_BI(f,lt) && a(x)->ia!=0 && rnk(x)>1) return toKCells(x, k);
|
||||||
|
|
||||||
usz* xsh = a(x)->sh;
|
usz* xsh = a(x)->sh;
|
||||||
usz cam = 1; for (usz i = 0; i < k; i++) cam*= xsh[i];
|
usz cam = shProd(xsh, 0, k);
|
||||||
usz csz = 1; for (usz i = k; i < xr; i++) csz*= xsh[i];
|
usz csz = shProd(xsh, k, xr);
|
||||||
ShArr* csh;
|
ShArr* csh;
|
||||||
if (cr>1) {
|
if (cr>1) {
|
||||||
csh = m_shArr(cr);
|
csh = m_shArr(cr);
|
||||||
@ -298,8 +298,8 @@ B rank_c2(Md2D* d, B w, B x) { B f = d->f; B g = d->g;
|
|||||||
} else {
|
} else {
|
||||||
i32 k = xr - xc;
|
i32 k = xr - xc;
|
||||||
usz* xsh = a(x)->sh;
|
usz* xsh = a(x)->sh;
|
||||||
usz cam = 1; for (usz i = 0; i < k; i++) cam*= xsh[i];
|
usz cam = shProd(xsh, 0, k);
|
||||||
usz csz = 1; for (usz i = k; i < xr; i++) csz*= xsh[i];
|
usz csz = shProd(xsh, k, xr);
|
||||||
if (cam == 0) { return m2c2(rt_rank, f, g, w, x); } // TODO
|
if (cam == 0) { return m2c2(rt_rank, f, g, w, x); } // TODO
|
||||||
ShArr* csh;
|
ShArr* csh;
|
||||||
if (xc>1) { csh=m_shArr(xc); shcpy(csh->a, xsh+k, xc); }
|
if (xc>1) { csh=m_shArr(xc); shcpy(csh->a, xsh+k, xc); }
|
||||||
@ -322,8 +322,8 @@ B rank_c2(Md2D* d, B w, B x) { B f = d->f; B g = d->g;
|
|||||||
} else if (xr == xc) {
|
} else if (xr == xc) {
|
||||||
i32 k = wr - wc;
|
i32 k = wr - wc;
|
||||||
usz* wsh = a(w)->sh;
|
usz* wsh = a(w)->sh;
|
||||||
usz cam = 1; for (usz i = 0; i < k; i++) cam*= wsh[i];
|
usz cam = shProd(wsh, 0, k);
|
||||||
usz csz = 1; for (usz i = k; i < wr; i++) csz*= wsh[i];
|
usz csz = shProd(wsh, k, wr);
|
||||||
if (cam == 0) { return m2c2(rt_rank, f, g, w, x); } // TODO
|
if (cam == 0) { return m2c2(rt_rank, f, g, w, x); } // TODO
|
||||||
ShArr* csh;
|
ShArr* csh;
|
||||||
if (wc>1) { csh=m_shArr(wc); shcpy(csh->a, wsh+k, wc); }
|
if (wc>1) { csh=m_shArr(wc); shcpy(csh->a, wsh+k, wc); }
|
||||||
@ -353,9 +353,9 @@ B rank_c2(Md2D* d, B w, B x) { B f = d->f; B g = d->g;
|
|||||||
if (wl != xl) thrF("⎉: Argument frames don't agree (%H ≡ ≢𝕨, %H ≡ ≢𝕩, common frame of %s axes)", w, x, k);
|
if (wl != xl) thrF("⎉: Argument frames don't agree (%H ≡ ≢𝕨, %H ≡ ≢𝕩, common frame of %s axes)", w, x, k);
|
||||||
cam*= wsh[i];
|
cam*= wsh[i];
|
||||||
}
|
}
|
||||||
usz ext = 1; for (usz i = k; i < zk; i++) ext*= zsh[i];
|
usz ext = shProd(zsh, k, zk);
|
||||||
usz wsz = 1; for (usz i = wk; i < wr; i++) wsz*= wsh[i];
|
usz wsz = shProd(wsh, wk, wr);
|
||||||
usz xsz = 1; for (usz i = xk; i < xr; i++) xsz*= xsh[i];
|
usz xsz = shProd(xsh, xk, xr);
|
||||||
cam *= ext;
|
cam *= ext;
|
||||||
if (cam == 0) { return m2c2(rt_rank, f, g, w, x); } // TODO
|
if (cam == 0) { return m2c2(rt_rank, f, g, w, x); } // TODO
|
||||||
|
|
||||||
|
|||||||
@ -82,13 +82,15 @@ static void shcpy(usz* dst, usz* src, size_t len) {
|
|||||||
NOUNROLL for (size_t i = 0; i < len; i++) dst[i] = src[i];
|
NOUNROLL for (size_t i = 0; i < len; i++) dst[i] = src[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static usz shProd(usz* sh, usz s, usz e) {
|
||||||
|
usz r = 1;
|
||||||
|
NOUNROLL for (i32 i = s; i < e; i++) r*= sh[i];
|
||||||
|
return r;
|
||||||
|
}
|
||||||
static usz arr_csz(B x) {
|
static usz arr_csz(B x) {
|
||||||
ur xr = rnk(x);
|
ur xr = rnk(x);
|
||||||
if (xr<=1) return 1;
|
if (xr<=1) return 1;
|
||||||
usz* sh = a(x)->sh;
|
return shProd(a(x)->sh, 1, xr);
|
||||||
usz r = 1;
|
|
||||||
NOUNROLL for (i32 i = 1; i < xr; i++) r*= sh[i];
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
static bool eqShPart(usz* w, usz* x, usz len) {
|
static bool eqShPart(usz* w, usz* x, usz len) {
|
||||||
// return memcmp(w, x, len*sizeof(usz))==0;
|
// return memcmp(w, x, len*sizeof(usz))==0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user