summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/C/vector-aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Internal/C/vector-aux.c')
-rw-r--r--packages/base/src/Internal/C/vector-aux.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/packages/base/src/Internal/C/vector-aux.c b/packages/base/src/Internal/C/vector-aux.c
index 1cef27d..dcd6c0b 100644
--- a/packages/base/src/Internal/C/vector-aux.c
+++ b/packages/base/src/Internal/C/vector-aux.c
@@ -1533,3 +1533,54 @@ int chooseQ(KIVEC(cond),KQVEC(lt),KQVEC(eq),KQVEC(gt),QVEC(r)) {
1533 CHOOSE_IMP 1533 CHOOSE_IMP
1534} 1534}
1535 1535
1536//////////////////// reorder /////////////////////////
1537
1538#define REORDER_IMP \
1539 REQUIRES(kn == stridesn && stridesn == dimsn ,BAD_SIZE); \
1540 int i,j,l; \
1541 for (i=1,j=0,l=0;l<kn;++l) { \
1542 kp[l] = 0; \
1543 i *= dimsp[l]; \
1544 j += (dimsp[l]-1) * stridesp[l]; \
1545 } \
1546 REQUIRES(i <= vn && j < rn ,BAD_SIZE); \
1547 for (i=0,j=0;;i++) { \
1548 rp[i] = vp[j]; \
1549 for(l=kn-1;;l--) { \
1550 ++kp[l]; \
1551 if (kp[l] < dimsp[l]) { \
1552 j += stridesp[l]; \
1553 break; \
1554 } else { \
1555 if (l == 0) { \
1556 return 0; \
1557 } \
1558 kp[l] = 0; \
1559 j -= (dimsp[l]-1) * stridesp[l]; \
1560 } \
1561 } \
1562 }
1563
1564int reorderF(IVEC(k), KIVEC(strides),KIVEC(dims),KFVEC(v),FVEC(r)) {
1565 REORDER_IMP
1566}
1567
1568int reorderD(IVEC(k), KIVEC(strides),KIVEC(dims),KDVEC(v),DVEC(r)) {
1569 REORDER_IMP
1570}
1571
1572int reorderI(IVEC(k), KIVEC(strides),KIVEC(dims),KIVEC(v),IVEC(r)) {
1573 REORDER_IMP
1574}
1575
1576int reorderL(IVEC(k), KIVEC(strides),KIVEC(dims),KLVEC(v),LVEC(r)) {
1577 REORDER_IMP
1578}
1579
1580int reorderC(IVEC(k), KIVEC(strides),KIVEC(dims),KCVEC(v),CVEC(r)) {
1581 REORDER_IMP
1582}
1583
1584int reorderQ(IVEC(k), KIVEC(strides),KIVEC(dims),KQVEC(v),QVEC(r)) {
1585 REORDER_IMP
1586}