Skip to content

Commit 3f9b61c

Browse files
committed
Use array instead of A
1 parent 45fef08 commit 3f9b61c

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

jsrc/conversions.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ convert(J jt, array w, void *yv, Transform t) -> bool {
5555

5656
template <>
5757
[[nodiscard]] auto
58-
convert<D, bool>(J jt, A w, void *yv, D fuzz) -> bool {
58+
convert<D, bool>(J jt, array w, void *yv, D fuzz) -> bool {
5959
auto n = AN(w);
6060
auto v = pointer_to_values<double>(w);
6161
auto x = (B *)yv;
@@ -70,7 +70,7 @@ convert<D, bool>(J jt, A w, void *yv, D fuzz) -> bool {
7070

7171
template <>
7272
[[nodiscard]] auto
73-
convert<D, I>(J jt, A w, void *yv, D fuzz) -> bool {
73+
convert<D, I>(J jt, array w, void *yv, D fuzz) -> bool {
7474
auto n = AN(w);
7575
auto v = pointer_to_values<double>(w);
7676
auto x = (I *)yv;
@@ -95,7 +95,7 @@ convert<D, I>(J jt, A w, void *yv, D fuzz) -> bool {
9595

9696
template <>
9797
[[nodiscard]] auto
98-
convert<Z, D>(J jt, A w, void *yv, D fuzz) -> bool {
98+
convert<Z, D>(J jt, array w, void *yv, D fuzz) -> bool {
9999
auto const n = AN(w);
100100
auto const *v = pointer_to_values<Z>(w);
101101
auto x = (D *)yv;
@@ -116,7 +116,7 @@ convert<Z, D>(J jt, A w, void *yv, D fuzz) -> bool {
116116

117117
template <>
118118
[[nodiscard]] auto
119-
convert<bool, X>(J jt, A w, void *yv) -> bool {
119+
convert<bool, X>(J jt, array w, void *yv) -> bool {
120120
return convert<B, X>(jt,
121121
w,
122122
yv,
@@ -135,7 +135,7 @@ inplace_negate(T *u, int64_t n) {
135135

136136
template <>
137137
[[nodiscard]] auto
138-
convert<I, X>(J jt, A w, void *yv) -> bool {
138+
convert<I, X>(J jt, array w, void *yv) -> bool {
139139
I u[XIDIG];
140140
auto const convert_one = [&](auto c) {
141141
auto const b = c == IMIN;
@@ -170,7 +170,7 @@ jtxd1(J jt, D p, I mode) {
170170
}
171171
if (p == inf) return jtvci(jt, XPINF);
172172
if (p == -inf) return jtvci(jt, XNINF);
173-
A t;
173+
array t;
174174
GAT0(t, INT, 30, 1);
175175
auto u = pointer_to_values(t);
176176
int64_t m = 0;
@@ -191,22 +191,22 @@ jtxd1(J jt, D p, I mode) {
191191
} else if (0 > p) {
192192
inplace_negate(u, m);
193193
}
194-
A z = jtxstd(jt, jtvec(jt, INT, m, u));
194+
array z = jtxstd(jt, jtvec(jt, INT, m, u));
195195
EPILOG(z);
196196
}
197197

198198
template <>
199199
[[nodiscard]] auto
200-
convert<D, X>(J jt, A w, void *yv, I mode) -> bool {
200+
convert<D, X>(J jt, array w, void *yv, I mode) -> bool {
201201
return convert<D, X>(jt, w, yv, [=](auto v){ return jtxd1(jt, v, mode); }) && !jt->jerr;
202202
}
203203

204204
template <>
205205
[[nodiscard]] auto
206-
convert<X, bool>(J jt, A w, void *yv) -> bool {
206+
convert<X, bool>(J jt, array w, void *yv) -> bool {
207207
auto v = pointer_to_values<X>(w);
208208
auto x = (B *)yv;
209-
DO(AN(w), A q = v[i]; I e = pointer_to_values(q)[0]; if ((AN(q) ^ 1) | (e & -2)) return 0; x[i] = (B)e;);
209+
DO(AN(w), array q = v[i]; I e = pointer_to_values(q)[0]; if ((AN(q) ^ 1) | (e & -2)) return 0; x[i] = (B)e;);
210210
return 1;
211211
}
212212

@@ -220,7 +220,7 @@ value_from_X(X p) -> T {
220220

221221
template <>
222222
[[nodiscard]] auto
223-
convert<X, I>(J jt, A w, void *yv) -> bool {
223+
convert<X, I>(J jt, array w, void *yv) -> bool {
224224
auto v = pointer_to_values<X>(w);
225225
auto x = (I *)yv;
226226
auto n = AN(w);
@@ -237,7 +237,7 @@ convert<X, I>(J jt, A w, void *yv) -> bool {
237237

238238
template <>
239239
[[nodiscard]] auto
240-
convert<X, D>(J jt, A w, void *yv) -> bool {
240+
convert<X, D>(J jt, array w, void *yv) -> bool {
241241
return convert<X, D>(jt, w, yv, [](auto p) {
242242
auto const c = pointer_to_values(p)[AN(p) - 1];
243243
if (c == XPINF) return inf;
@@ -248,13 +248,13 @@ convert<X, D>(J jt, A w, void *yv) -> bool {
248248

249249
template <>
250250
[[nodiscard]] auto
251-
convert<X, Q>(J jt, A w, void *yv) -> bool {
251+
convert<X, Q>(J jt, array w, void *yv) -> bool {
252252
return convert<X, Q>(jt, w, yv, [](auto v) -> Q { return {v, iv1}; });
253253
}
254254

255255
template <>
256256
[[nodiscard]] auto
257-
convert<D, Q>(J jt, A w, void *yv, I mode) -> bool {
257+
convert<D, Q>(J jt, array w, void *yv, I mode) -> bool {
258258
if (!(w)) return 0;
259259
auto const n = AN(w);
260260
auto const wv = pointer_to_values<double>(w);
@@ -302,7 +302,7 @@ convert<D, Q>(J jt, A w, void *yv, I mode) -> bool {
302302

303303
template <>
304304
[[nodiscard]] auto
305-
convert<Q, D>(J jt, A w, void *yv) -> bool {
305+
convert<Q, D>(J jt, array w, void *yv) -> bool {
306306
auto const xb = (D)XBASE;
307307
auto const wn = AN(w);
308308
auto const wv = pointer_to_values<Q>(w);
@@ -352,7 +352,7 @@ convert<Q, D>(J jt, A w, void *yv) -> bool {
352352

353353
template <>
354354
[[nodiscard]] auto
355-
convert<Q, X>(J jt, A w, void *yv) -> bool {
355+
convert<Q, X>(J jt, array w, void *yv) -> bool {
356356
auto v = pointer_to_values<Q>(w);
357357
auto x = (X *)yv;
358358
DQ(AN(w), if (!(jtequ(jt, iv1, v->d))) return 0; *x++ = v->n; ++v;);
@@ -368,17 +368,17 @@ set_real_part(Z *z, int64_t n, T *t) {
368368
// Imaginary parts have already been cleared
369369
template <>
370370
[[nodiscard]] auto
371-
convert<D, Z>(J jt, A w, void *yv) -> bool {
371+
convert<D, Z>(J jt, array w, void *yv) -> bool {
372372
set_real_part(static_cast<Z*>(yv), AN(w), pointer_to_values<double>(w));
373373
return 1;
374374
}
375375

376-
// Convert the data in w to the type t. w and t must be noun types. A new buffer is always created (with a
376+
// Convert the data in w to the type t. w and t must be noun types. array new buffer is always created (with a
377377
// copy of the data if w is already of the right type), and returned in *y. Result is
378378
// 0 if error, 1 if success. If the conversion loses precision, error is returned
379379
// Calls through bcvt are tagged with a flag in jt, indicating to set fuzz=0
380380
B
381-
jtccvt(J jt, I tflagged, A w, A *y) {
381+
jtccvt(J jt, I tflagged, array w, array *y) {
382382
FPREFIP;
383383
I const t = tflagged & NOUN;
384384
if (!w) return 0;
@@ -423,7 +423,7 @@ jtccvt(J jt, I tflagged, A w, A *y) {
423423
// modified: the caller must restore AN(w) and AK(w) if it needs it
424424
// TODO: same-length conversion could be done in place
425425
auto n = AN(w);
426-
A d;
426+
array d;
427427
GA(d, t, n, r, s);
428428
auto yv = pointer_to_values<void>(d); // allocate the same # atoms, even if we will convert fewer
429429
if (tflagged & NOUNCVTVALIDCT) {
@@ -530,9 +530,9 @@ jtccvt(J jt, I tflagged, A w, A *y) {
530530
}
531531

532532
// clear rank before calling ccvt - needed for sparse arrays only but returns the block as the result
533-
A
534-
jtcvt(J jt, I t, A w) {
535-
A y;
533+
auto
534+
jtcvt(J jt, I t, array w) -> array {
535+
array y;
536536
bool const b = jtccvt(jt, t, w, &y);
537537
ASSERT(b, EVDOMAIN);
538538
return y;
@@ -542,8 +542,8 @@ jtcvt(J jt, I t, A w) {
542542
// and use 'exact' and 'no rank' for them. If mode=0, do not promote XNUM/RAT to fixed-length types.
543543
// If mode bit 1 is set, minimum precision is INT; if mode bit 2 is set, minimum precision is FL; if mode bit 3 is set,
544544
// minimum precision is CMPX Result is a new buffer, always
545-
A
546-
jtbcvt(J jt, C mode, A w) {
545+
auto
546+
jtbcvt(J jt, C mode, array w) -> array {
547547
FPREFIP;
548548
if (!w) return 0;
549549

@@ -556,7 +556,7 @@ jtbcvt(J jt, C mode, A w) {
556556
// to integer. If none of the imaginary parts were flags, we leave the input unchanged. If some were flags, we
557557
// convert the flagged values to float and keep the result as complex
558558
array result = w;
559-
if ((((AN(w) - 1) | (AT(w) & CMPX) - 1)) >= 0) { // not empty AND complex
559+
if ((((AN(w) - 1) | ((AT(w) & CMPX) - 1))) >= 0) { // not empty AND complex
560560
Z *wv = pointer_to_values<Z>(w);
561561
auto flags = std::transform_reduce(wv, wv + AN(w), int64_t{}, std::plus{}, isflag);
562562
if (flags) {
@@ -589,11 +589,11 @@ jtbcvt(J jt, C mode, A w) {
589589
RNE(result);
590590
} /* convert to lowest type. 0=mode: don't convert XNUM/RAT to other types */
591591

592-
A
593-
jticvt(J jt, A w) {
592+
auto
593+
jticvt(J jt, array w) -> array {
594594
auto const n = AN(w);
595595
auto const* v = pointer_to_values<double>(w);
596-
A z;
596+
array z;
597597
GATV(z, INT, n, AR(w), AS(w));
598598
auto u = pointer_to_values(z);
599599
for (int64_t i = 0; i < n; ++i) {
@@ -604,18 +604,18 @@ jticvt(J jt, A w) {
604604
return z;
605605
}
606606

607-
A
608-
jtpcvt(J jt, I t, A w) {
607+
auto
608+
jtpcvt(J jt, I t, array w) -> array {
609609
RANK2T oqr = jt->ranks;
610610
RESETRANK;
611-
A y;
611+
array y;
612612
bool const b = jtccvt(jt, t, w, &y);
613613
jt->ranks = oqr;
614614
return b ? y : w;
615615
} /* convert w to type t, if possible, otherwise just return w */
616616

617-
A
618-
jtcvt0(J jt, A w) {
617+
auto
618+
jtcvt0(J jt, array w) -> array {
619619
auto const t = AT(w);
620620
auto const n = (t & CMPX) ? 2 * AN(w) : AN(w);
621621
if (n && t & FL + CMPX) {
@@ -625,14 +625,14 @@ jtcvt0(J jt, A w) {
625625
return w;
626626
} /* convert -0 to 0 in place */
627627

628-
A
629-
jtxco1(J jt, A w) {
628+
auto
629+
jtxco1(J jt, array w) -> array {
630630
ASSERT(AT(w) & DENSE, EVNONCE);
631631
return jtcvt(jt, AT(w) & B01 + INT + XNUM ? XNUM : RAT, w);
632632
}
633633

634-
A
635-
jtxco2(J jt, A a, A w) {
634+
auto
635+
jtxco2(J jt, array a, array w) -> array {
636636
ASSERT(AT(w) & DENSE, EVNONCE);
637637
I j;
638638
RE(j = jti0(jt, a));
@@ -645,7 +645,7 @@ jtxco2(J jt, A a, A w) {
645645
{
646646
auto const n = AN(w);
647647
auto const r = AR(w);
648-
A z;
648+
array z;
649649
GATV(z, XNUM, 2 * n, r + 1, AS(w));
650650
AS(z)[r] = 2;
651651
memcpy(pointer_to_values(z), pointer_to_values(w), 2 * n * SZI);

0 commit comments

Comments
 (0)