helpers for creating empty arrays
This commit is contained in:
parent
6c4eae5e28
commit
8146040c15
@ -251,13 +251,13 @@ NOINLINE B any_squeeze(B x) {
|
||||
NOINLINE B num_squeeze(B x) {
|
||||
assert(isArr(x));
|
||||
u8 xe = TI(x,elType);
|
||||
if (IA(x) == 0) return xe==el_bit? x : taga(cpyBitArr(x));
|
||||
if (IA(x) == 0) return xe==el_bit? x : emptyNumsWithShape(x);
|
||||
return squeeze_numFns[xe](x,a(x),TY(x),IA(x));
|
||||
}
|
||||
NOINLINE B chr_squeeze(B x) {
|
||||
assert(isArr(x));
|
||||
u8 xe = TI(x,elType);
|
||||
if (IA(x) == 0) return xe==el_c8? x : taga(cpyC8Arr(x));
|
||||
if (IA(x) == 0) return xe==el_c8? x : emptyChrsWithShape(x);
|
||||
return squeeze_chrFns[xe](x,a(x),TY(x),IA(x));
|
||||
}
|
||||
|
||||
|
||||
@ -233,4 +233,21 @@ NOINLINE Arr* emptyWithFill(B fill) {
|
||||
Arr* r;
|
||||
m_tyarrp(&r, 0, 0, type);
|
||||
return r;
|
||||
}
|
||||
|
||||
NOINLINE B emptyNumsWithShape(B x) {
|
||||
assert(IA(x)==0);
|
||||
if (RNK(x)==1) { decG(x); return emptyIVec(); }
|
||||
u64* tmp;
|
||||
B r = m_bitarrc(&tmp, x);
|
||||
decG(x);
|
||||
return r;
|
||||
}
|
||||
NOINLINE B emptyChrsWithShape(B x) {
|
||||
assert(IA(x)==0);
|
||||
if (RNK(x)==1) { decG(x); return emptyCVec(); }
|
||||
u8* tmp;
|
||||
B r = m_c8arrc(&tmp, x);
|
||||
decG(x);
|
||||
return r;
|
||||
}
|
||||
@ -207,6 +207,8 @@ Arr* customizeShape(B x); // consumes; returns new array with unset shape
|
||||
Arr* cpyWithShape(B x); // consumes; returns new array with the same shape as x (SH(x) will be dangling, PSH(result) must be used to access it)
|
||||
Arr* emptyArr(B x, ur xr); // doesn't consume; returns an empty array with the same fill as x; if xr>1, shape must be set
|
||||
NOINLINE Arr* emptyWithFill(B fill); // consumes; returns new array with unset shape and the specified fill
|
||||
B emptyNumsWithShape(B x); // consumes; empty bitarr with shape ≢x
|
||||
B emptyChrsWithShape(B x); // consumes; empty c8arr with shape ≢x
|
||||
|
||||
B m_vec1(B a); // complete fills
|
||||
B m_vec2(B a, B b); // incomplete fills
|
||||
|
||||
Loading…
Reference in New Issue
Block a user