return Arr* from m_(i32|c32|f64)arrp
This commit is contained in:
parent
49810ce8bc
commit
daa8294252
@ -233,10 +233,10 @@ B indexOf_c2(B t, B w, B x) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dec(w); dec(x);
|
dec(w); dec(x);
|
||||||
i32* rp; B r = m_i32arrp(&rp, 1);
|
i32* rp; Arr* r = m_i32arrp(&rp, 1);
|
||||||
arr_shAllocR(r,0);
|
arrP_shAllocR(r, 0);
|
||||||
rp[0] = res;
|
rp[0] = res;
|
||||||
return r;
|
return tag(r, ARR_TAG);
|
||||||
} else if (rnk(x)==1) {
|
} else if (rnk(x)==1) {
|
||||||
usz wia = a(w)->ia;
|
usz wia = a(w)->ia;
|
||||||
usz xia = a(x)->ia;
|
usz xia = a(x)->ia;
|
||||||
|
|||||||
@ -20,11 +20,11 @@ static B m_c32arrc(u32** p, B x) { assert(isArr(x));
|
|||||||
arrP_shCopy((Arr*)r, x);
|
arrP_shCopy((Arr*)r, x);
|
||||||
return tag(r, ARR_TAG);
|
return tag(r, ARR_TAG);
|
||||||
}
|
}
|
||||||
static B m_c32arrp(u32** p, usz ia) { // doesn't write shape/rank
|
static Arr* m_c32arrp(u32** p, usz ia) { // doesn't write shape/rank
|
||||||
C32Arr* r = mm_alloc(fsizeof(C32Arr,a,u32,ia), t_c32arr);
|
C32Arr* r = mm_alloc(fsizeof(C32Arr,a,u32,ia), t_c32arr);
|
||||||
*p = r->a;
|
*p = r->a;
|
||||||
r->ia = ia;
|
r->ia = ia;
|
||||||
return tag(r, ARR_TAG);
|
return (Arr*)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
B m_str8(usz sz, char* s);
|
B m_str8(usz sz, char* s);
|
||||||
|
|||||||
@ -20,11 +20,11 @@ static B m_f64arrc(f64** p, B x) { assert(isArr(x));
|
|||||||
arrP_shCopy((Arr*)r, x);
|
arrP_shCopy((Arr*)r, x);
|
||||||
return tag(r, ARR_TAG);
|
return tag(r, ARR_TAG);
|
||||||
}
|
}
|
||||||
static B m_f64arrp(f64** p, usz ia) { // doesn't write shape/rank
|
static Arr* m_f64arrp(f64** p, usz ia) { // doesn't write shape/rank
|
||||||
F64Arr* r = mm_alloc(fsizeof(F64Arr,a,f64,ia), t_f64arr);
|
F64Arr* r = mm_alloc(fsizeof(F64Arr,a,f64,ia), t_f64arr);
|
||||||
*p = r->a;
|
*p = r->a;
|
||||||
r->ia = ia;
|
r->ia = ia;
|
||||||
return tag(r, ARR_TAG);
|
return (Arr*)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
B m_caf64(usz sz, f64* a);
|
B m_caf64(usz sz, f64* a);
|
||||||
|
|||||||
@ -93,17 +93,17 @@ static B m_unit(B x) {
|
|||||||
|
|
||||||
static B m_atomUnit(B x) {
|
static B m_atomUnit(B x) {
|
||||||
if (isNum(x)) {
|
if (isNum(x)) {
|
||||||
B r;
|
Arr* r;
|
||||||
if (q_i32(x)) { i32* rp; r=m_i32arrp(&rp, 1); rp[0] = o2iu(x); }
|
if (q_i32(x)) { i32* rp; r = m_i32arrp(&rp, 1); rp[0] = o2iu(x); }
|
||||||
else { f64* rp; r=m_f64arrp(&rp, 1); rp[0] = o2fu(x); }
|
else { f64* rp; r = m_f64arrp(&rp, 1); rp[0] = o2fu(x); }
|
||||||
arr_shAllocR(r,0);
|
arrP_shAllocR(r, 0);
|
||||||
return r;
|
return tag(r, ARR_TAG);
|
||||||
}
|
}
|
||||||
if (isC32(x)) {
|
if (isC32(x)) {
|
||||||
u32* rp; B r = m_c32arrp(&rp, 1);
|
u32* rp; Arr* r = m_c32arrp(&rp, 1);
|
||||||
rp[0] = o2cu(x);
|
rp[0] = o2cu(x);
|
||||||
arr_shAllocR(r,0);
|
arrP_shAllocR(r,0);
|
||||||
return r;
|
return tag(r, ARR_TAG);
|
||||||
}
|
}
|
||||||
return m_unit(x);
|
return m_unit(x);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,11 +20,11 @@ static B m_i32arrc(i32** p, B x) { assert(isArr(x));
|
|||||||
arrP_shCopy((Arr*)r, x);
|
arrP_shCopy((Arr*)r, x);
|
||||||
return tag(r, ARR_TAG);
|
return tag(r, ARR_TAG);
|
||||||
}
|
}
|
||||||
static B m_i32arrp(i32** p, usz ia) { // doesn't write shape/rank
|
static Arr* m_i32arrp(i32** p, usz ia) { // doesn't write shape/rank
|
||||||
I32Arr* r = mm_alloc(fsizeof(I32Arr,a,i32,ia), t_i32arr);
|
I32Arr* r = mm_alloc(fsizeof(I32Arr,a,i32,ia), t_i32arr);
|
||||||
*p = r->a;
|
*p = r->a;
|
||||||
r->ia = ia;
|
r->ia = ia;
|
||||||
return tag(r, ARR_TAG);
|
return (Arr*)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
B m_cai32(usz ia, i32* a);
|
B m_cai32(usz ia, i32* a);
|
||||||
|
|||||||
@ -19,10 +19,10 @@ static void mut_to(Mut* m, u8 n) {
|
|||||||
m->type = n;
|
m->type = n;
|
||||||
if (o==el_MAX) {
|
if (o==el_MAX) {
|
||||||
switch(n) { default: UD;
|
switch(n) { default: UD;
|
||||||
case el_i32: m->val = a(m_i32arrp(&m->ai32, m->ia)); return;
|
case el_i32: m->val = m_i32arrp(&m->ai32, m->ia); return;
|
||||||
case el_f64: m->val = a(m_f64arrp(&m->af64, m->ia)); return;
|
case el_f64: m->val = m_f64arrp(&m->af64, m->ia); return;
|
||||||
case el_c32: m->val = a(m_c32arrp(&m->ac32, m->ia)); return;
|
case el_c32: m->val = m_c32arrp(&m->ac32, m->ia); return;
|
||||||
case el_B :; HArr_p t = m_harrUp( m->ia); m->val = (Arr*)t.c; m->aB = t.c->a; return;
|
case el_B :; HArr_p t = m_harrUp( m->ia); m->val = (Arr*)t.c; m->aB = t.c->a; return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprnk(m->val, 1);
|
sprnk(m->val, 1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user