summaryrefslogtreecommitdiff
path: root/packages/base
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base')
-rw-r--r--packages/base/src/Internal/C/lapack-aux.c101
-rw-r--r--packages/base/src/Internal/C/lapack-aux.h6
-rw-r--r--packages/base/src/Internal/C/vector-aux.c300
3 files changed, 276 insertions, 131 deletions
diff --git a/packages/base/src/Internal/C/lapack-aux.c b/packages/base/src/Internal/C/lapack-aux.c
index 063e601..7da6f6a 100644
--- a/packages/base/src/Internal/C/lapack-aux.c
+++ b/packages/base/src/Internal/C/lapack-aux.c
@@ -3,6 +3,8 @@
3#include <string.h> 3#include <string.h>
4#include <math.h> 4#include <math.h>
5#include <time.h> 5#include <time.h>
6#include <inttypes.h>
7
6#include "lapack-aux.h" 8#include "lapack-aux.h"
7 9
8#define MACRO(B) do {B} while (0) 10#define MACRO(B) do {B} while (0)
@@ -1300,6 +1302,18 @@ int multiplyI(KOIMAT(a), KOIMAT(b), OIMAT(r)) {
1300 OK 1302 OK
1301} 1303}
1302 1304
1305int multiplyL(KOLMAT(a), KOLMAT(b), OLMAT(r)) {
1306 { TRAV(r,i,j) {
1307 int k;
1308 AT(r,i,j) = 0;
1309 for (k=0;k<ac;k++) {
1310 AT(r,i,j) += AT(a,i,k) * AT(b,k,j);
1311 }
1312 }
1313 }
1314 OK
1315}
1316
1303 1317
1304////////////////// sparse matrix-product /////////////////////////////////////// 1318////////////////// sparse matrix-product ///////////////////////////////////////
1305 1319
@@ -1331,67 +1345,23 @@ int smTXv(KDVEC(vals),KIVEC(cols),KIVEC(rows),KDVEC(x),DVEC(r)) {
1331 1345
1332//////////////////// transpose ///////////////////////// 1346//////////////////// transpose /////////////////////////
1333 1347
1334int transF(KFMAT(x),FMAT(t)) { 1348#define TRANS_IMP { \
1335 REQUIRES(xr==tc && xc==tr,BAD_SIZE); 1349 REQUIRES(xr==tc && xc==tr,BAD_SIZE); \
1336 DEBUGMSG("transF"); 1350 DEBUGMSG("trans"); \
1337 int i,j; 1351 int i,j; \
1338 for (i=0; i<tr; i++) { 1352 for (i=0; i<tr; i++) { \
1339 for (j=0; j<tc; j++) { 1353 for (j=0; j<tc; j++) { \
1340 tp[i*tc+j] = xp[j*xc+i]; 1354 tp[i*tc+j] = xp[j*xc+i]; \
1341 } 1355 } \
1342 } 1356 } \
1343 OK 1357 OK }
1344} 1358
1345 1359int transF(KFMAT(x),FMAT(t)) TRANS_IMP
1346int transR(KDMAT(x),DMAT(t)) { 1360int transR(KDMAT(x),DMAT(t)) TRANS_IMP
1347 REQUIRES(xr==tc && xc==tr,BAD_SIZE); 1361int transQ(KQMAT(x),QMAT(t)) TRANS_IMP
1348 DEBUGMSG("transR"); 1362int transC(KCMAT(x),CMAT(t)) TRANS_IMP
1349 int i,j; 1363int transI(KIMAT(x),IMAT(t)) TRANS_IMP
1350 for (i=0; i<tr; i++) { 1364int transL(KLMAT(x),LMAT(t)) TRANS_IMP
1351 for (j=0; j<tc; j++) {
1352 tp[i*tc+j] = xp[j*xc+i];
1353 }
1354 }
1355 OK
1356}
1357
1358int transQ(KQMAT(x),QMAT(t)) {
1359 REQUIRES(xr==tc && xc==tr,BAD_SIZE);
1360 DEBUGMSG("transQ");
1361 int i,j;
1362 for (i=0; i<tr; i++) {
1363 for (j=0; j<tc; j++) {
1364 tp[i*tc+j] = xp[j*xc+i];
1365 }
1366 }
1367 OK
1368}
1369
1370int transC(KCMAT(x),CMAT(t)) {
1371 REQUIRES(xr==tc && xc==tr,BAD_SIZE);
1372 DEBUGMSG("transC");
1373 int i,j;
1374 for (i=0; i<tr; i++) {
1375 for (j=0; j<tc; j++) {
1376 tp[i*tc+j] = xp[j*xc+i];
1377 }
1378 }
1379 OK
1380}
1381
1382
1383int transI(KIMAT(x),IMAT(t)) {
1384 REQUIRES(xr==tc && xc==tr,BAD_SIZE);
1385 DEBUGMSG("transI");
1386 int i,j;
1387 for (i=0; i<tr; i++) {
1388 for (j=0; j<tc; j++) {
1389 tp[i*tc+j] = xp[j*xc+i];
1390 }
1391 }
1392 OK
1393}
1394
1395 1365
1396//////////////////////// extract ///////////////////////////////// 1366//////////////////////// extract /////////////////////////////////
1397 1367
@@ -1431,6 +1401,11 @@ int extractI(int modei, int modej, KIVEC(i), KIVEC(j), KOIMAT(m), OIMAT(r)) {
1431 EXTRACT_IMP 1401 EXTRACT_IMP
1432} 1402}
1433 1403
1404int extractL(int modei, int modej, KIVEC(i), KIVEC(j), KOLMAT(m), OLMAT(r)) {
1405 EXTRACT_IMP
1406}
1407
1408
1434//////////////////////// remap ///////////////////////////////// 1409//////////////////////// remap /////////////////////////////////
1435 1410
1436#define REMAP_IMP \ 1411#define REMAP_IMP \
@@ -1451,6 +1426,10 @@ int remapI(KOIMAT(i), KOIMAT(j), KOIMAT(m), OIMAT(r)) {
1451 REMAP_IMP 1426 REMAP_IMP
1452} 1427}
1453 1428
1429int remapL(KOIMAT(i), KOIMAT(j), KOLMAT(m), OLMAT(r)) {
1430 REMAP_IMP
1431}
1432
1454int remapC(KOIMAT(i), KOIMAT(j), KOCMAT(m), OCMAT(r)) { 1433int remapC(KOIMAT(i), KOIMAT(j), KOCMAT(m), OCMAT(r)) {
1455 REMAP_IMP 1434 REMAP_IMP
1456} 1435}
diff --git a/packages/base/src/Internal/C/lapack-aux.h b/packages/base/src/Internal/C/lapack-aux.h
index 6ffbef1..1549bb5 100644
--- a/packages/base/src/Internal/C/lapack-aux.h
+++ b/packages/base/src/Internal/C/lapack-aux.h
@@ -37,6 +37,7 @@ typedef short ftnlen;
37/********************************************************/ 37/********************************************************/
38 38
39#define IVEC(A) int A##n, int*A##p 39#define IVEC(A) int A##n, int*A##p
40#define LVEC(A) int A##n, int64_t*A##p
40#define FVEC(A) int A##n, float*A##p 41#define FVEC(A) int A##n, float*A##p
41#define DVEC(A) int A##n, double*A##p 42#define DVEC(A) int A##n, double*A##p
42#define QVEC(A) int A##n, complex*A##p 43#define QVEC(A) int A##n, complex*A##p
@@ -44,6 +45,7 @@ typedef short ftnlen;
44#define PVEC(A) int A##n, void* A##p, int A##s 45#define PVEC(A) int A##n, void* A##p, int A##s
45 46
46#define IMAT(A) int A##r, int A##c, int* A##p 47#define IMAT(A) int A##r, int A##c, int* A##p
48#define LMAT(A) int A##r, int A##c, int64_t* A##p
47#define FMAT(A) int A##r, int A##c, float* A##p 49#define FMAT(A) int A##r, int A##c, float* A##p
48#define DMAT(A) int A##r, int A##c, double* A##p 50#define DMAT(A) int A##r, int A##c, double* A##p
49#define QMAT(A) int A##r, int A##c, complex* A##p 51#define QMAT(A) int A##r, int A##c, complex* A##p
@@ -51,6 +53,7 @@ typedef short ftnlen;
51#define PMAT(A) int A##r, int A##c, void* A##p, int A##s 53#define PMAT(A) int A##r, int A##c, void* A##p, int A##s
52 54
53#define OIMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, int* A##p 55#define OIMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, int* A##p
56#define OLMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, int64_t* A##p
54#define OFMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, float* A##p 57#define OFMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, float* A##p
55#define ODMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, double* A##p 58#define ODMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, double* A##p
56#define OQMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, complex* A##p 59#define OQMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, complex* A##p
@@ -58,6 +61,7 @@ typedef short ftnlen;
58 61
59 62
60#define KIVEC(A) int A##n, const int*A##p 63#define KIVEC(A) int A##n, const int*A##p
64#define KLVEC(A) int A##n, const int64_t*A##p
61#define KFVEC(A) int A##n, const float*A##p 65#define KFVEC(A) int A##n, const float*A##p
62#define KDVEC(A) int A##n, const double*A##p 66#define KDVEC(A) int A##n, const double*A##p
63#define KQVEC(A) int A##n, const complex*A##p 67#define KQVEC(A) int A##n, const complex*A##p
@@ -65,6 +69,7 @@ typedef short ftnlen;
65#define KPVEC(A) int A##n, const void* A##p, int A##s 69#define KPVEC(A) int A##n, const void* A##p, int A##s
66 70
67#define KIMAT(A) int A##r, int A##c, const int* A##p 71#define KIMAT(A) int A##r, int A##c, const int* A##p
72#define KLMAT(A) int A##r, int A##c, const int64_t* A##p
68#define KFMAT(A) int A##r, int A##c, const float* A##p 73#define KFMAT(A) int A##r, int A##c, const float* A##p
69#define KDMAT(A) int A##r, int A##c, const double* A##p 74#define KDMAT(A) int A##r, int A##c, const double* A##p
70#define KQMAT(A) int A##r, int A##c, const complex* A##p 75#define KQMAT(A) int A##r, int A##c, const complex* A##p
@@ -72,6 +77,7 @@ typedef short ftnlen;
72#define KPMAT(A) int A##r, int A##c, const void* A##p, int A##s 77#define KPMAT(A) int A##r, int A##c, const void* A##p, int A##s
73 78
74#define KOIMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const int* A##p 79#define KOIMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const int* A##p
80#define KOLMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const int64_t* A##p
75#define KOFMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const float* A##p 81#define KOFMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const float* A##p
76#define KODMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const double* A##p 82#define KODMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const double* A##p
77#define KOQMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const complex* A##p 83#define KOQMAT(A) int A##r, int A##c, int A##Xr, int A##Xc, const complex* A##p
diff --git a/packages/base/src/Internal/C/vector-aux.c b/packages/base/src/Internal/C/vector-aux.c
index fcc9dbd..0921c18 100644
--- a/packages/base/src/Internal/C/vector-aux.c
+++ b/packages/base/src/Internal/C/vector-aux.c
@@ -1,4 +1,5 @@
1#include <complex.h> 1#include <complex.h>
2#include <inttypes.h>
2 3
3typedef double complex TCD; 4typedef double complex TCD;
4typedef float complex TCF; 5typedef float complex TCF;
@@ -66,6 +67,14 @@ int sumI(KIVEC(x),IVEC(r)) {
66 OK 67 OK
67} 68}
68 69
70int sumL(KLVEC(x),LVEC(r)) {
71 REQUIRES(rn==1,BAD_SIZE);
72 int i;
73 int res = 0;
74 for (i = 0; i < xn; i++) res += xp[i];
75 rp[0] = res;
76 OK
77}
69 78
70int sumQ(KQVEC(x),QVEC(r)) { 79int sumQ(KQVEC(x),QVEC(r)) {
71 DEBUGMSG("sumQ"); 80 DEBUGMSG("sumQ");
@@ -127,7 +136,14 @@ int prodI(KIVEC(x),IVEC(r)) {
127 OK 136 OK
128} 137}
129 138
130 139int prodL(KLVEC(x),LVEC(r)) {
140 REQUIRES(rn==1,BAD_SIZE);
141 int i;
142 int res = 1;
143 for (i = 0; i < xn; i++) res *= xp[i];
144 rp[0] = res;
145 OK
146}
131 147
132int prodQ(KQVEC(x),QVEC(r)) { 148int prodQ(KQVEC(x),QVEC(r)) {
133 DEBUGMSG("prodQ"); 149 DEBUGMSG("prodQ");
@@ -189,7 +205,7 @@ double vector_min(KDVEC(x)) {
189 return r; 205 return r;
190} 206}
191 207
192double vector_max_index(KDVEC(x)) { 208int vector_max_index(KDVEC(x)) {
193 int k, r = 0; 209 int k, r = 0;
194 for (k = 1; k<xn; k++) { 210 for (k = 1; k<xn; k++) {
195 if(xp[k]>xp[r]) { 211 if(xp[k]>xp[r]) {
@@ -199,7 +215,7 @@ double vector_max_index(KDVEC(x)) {
199 return r; 215 return r;
200} 216}
201 217
202double vector_min_index(KDVEC(x)) { 218int vector_min_index(KDVEC(x)) {
203 int k, r = 0; 219 int k, r = 0;
204 for (k = 1; k<xn; k++) { 220 for (k = 1; k<xn; k++) {
205 if(xp[k]<xp[r]) { 221 if(xp[k]<xp[r]) {
@@ -254,7 +270,7 @@ float vector_min_f(KFVEC(x)) {
254 return r; 270 return r;
255} 271}
256 272
257float vector_max_index_f(KFVEC(x)) { 273int vector_max_index_f(KFVEC(x)) {
258 int k, r = 0; 274 int k, r = 0;
259 for (k = 1; k<xn; k++) { 275 for (k = 1; k<xn; k++) {
260 if(xp[k]>xp[r]) { 276 if(xp[k]>xp[r]) {
@@ -264,7 +280,7 @@ float vector_max_index_f(KFVEC(x)) {
264 return r; 280 return r;
265} 281}
266 282
267float vector_min_index_f(KFVEC(x)) { 283int vector_min_index_f(KFVEC(x)) {
268 int k, r = 0; 284 int k, r = 0;
269 for (k = 1; k<xn; k++) { 285 for (k = 1; k<xn; k++) {
270 if(xp[k]<xp[r]) { 286 if(xp[k]<xp[r]) {
@@ -306,7 +322,7 @@ int vector_max_i(KIVEC(x)) {
306} 322}
307 323
308int vector_min_i(KIVEC(x)) { 324int vector_min_i(KIVEC(x)) {
309 float r = xp[0]; 325 int r = xp[0];
310 int k; 326 int k;
311 for (k = 1; k<xn; k++) { 327 for (k = 1; k<xn; k++) {
312 if(xp[k]<r) { 328 if(xp[k]<r) {
@@ -352,6 +368,64 @@ int toScalarI(int code, KIVEC(x), IVEC(r)) {
352} 368}
353 369
354 370
371int64_t vector_max_l(KLVEC(x)) {
372 int64_t r = xp[0];
373 int k;
374 for (k = 1; k<xn; k++) {
375 if(xp[k]>r) {
376 r = xp[k];
377 }
378 }
379 return r;
380}
381
382int64_t vector_min_l(KLVEC(x)) {
383 int64_t r = xp[0];
384 int k;
385 for (k = 1; k<xn; k++) {
386 if(xp[k]<r) {
387 r = xp[k];
388 }
389 }
390 return r;
391}
392
393int vector_max_index_l(KLVEC(x)) {
394 int k, r = 0;
395 for (k = 1; k<xn; k++) {
396 if(xp[k]>xp[r]) {
397 r = k;
398 }
399 }
400 return r;
401}
402
403int vector_min_index_l(KLVEC(x)) {
404 int k, r = 0;
405 for (k = 1; k<xn; k++) {
406 if(xp[k]<xp[r]) {
407 r = k;
408 }
409 }
410 return r;
411}
412
413
414int toScalarL(int code, KLVEC(x), LVEC(r)) {
415 REQUIRES(rn==1,BAD_SIZE);
416 int64_t res;
417 switch(code) {
418 case 2: { res = vector_max_index_l(V(x)); break; }
419 case 3: { res = vector_max_l(V(x)); break; }
420 case 4: { res = vector_min_index_l(V(x)); break; }
421 case 5: { res = vector_min_l(V(x)); break; }
422 default: ERROR(BAD_CODE);
423 }
424 rp[0] = res;
425 OK
426}
427
428
355double dznrm2_(integer*, const doublecomplex*, integer*); 429double dznrm2_(integer*, const doublecomplex*, integer*);
356double dzasum_(integer*, const doublecomplex*, integer*); 430double dzasum_(integer*, const doublecomplex*, integer*);
357 431
@@ -477,6 +551,17 @@ int mapI(int code, KIVEC(x), IVEC(r)) {
477} 551}
478 552
479 553
554int mapL(int code, KLVEC(x), LVEC(r)) {
555 int k;
556 REQUIRES(xn == rn,BAD_SIZE);
557 switch (code) {
558 OP(3,abs)
559 OP(15,sign)
560 default: ERROR(BAD_CODE);
561 }
562}
563
564
480 565
481inline double abs_complex(doublecomplex z) { 566inline double abs_complex(doublecomplex z) {
482 return sqrt(z.r*z.r + z.i*z.i); 567 return sqrt(z.r*z.r + z.i*z.i);
@@ -641,6 +726,32 @@ int mapValI(int code, int* pval, KIVEC(x), IVEC(r)) {
641} 726}
642 727
643 728
729int64_t mod_l (int64_t a, int64_t b) {
730 int64_t m = a % b;
731 if (b>0) {
732 return m >=0 ? m : m+b;
733 } else {
734 return m <=0 ? m : m+b;
735 }
736}
737
738int mapValL(int code, int64_t* pval, KLVEC(x), LVEC(r)) {
739 int k;
740 int64_t val = *pval;
741 REQUIRES(xn == rn,BAD_SIZE);
742 DEBUGMSG("mapValL");
743 switch (code) {
744 OPV(0,val*xp[k])
745 OPV(1,val/xp[k])
746 OPV(2,val+xp[k])
747 OPV(3,val-xp[k])
748 OPV(6,mod(val,xp[k]))
749 OPV(7,mod(xp[k],val))
750 default: ERROR(BAD_CODE);
751 }
752}
753
754
644 755
645inline doublecomplex complex_add(doublecomplex a, doublecomplex b) { 756inline doublecomplex complex_add(doublecomplex a, doublecomplex b) {
646 doublecomplex r; 757 doublecomplex r;
@@ -736,6 +847,19 @@ REQUIRES(an == bn && an == rn, BAD_SIZE);
736} 847}
737 848
738 849
850int zipL(int code, KLVEC(a), KLVEC(b), LVEC(r)) {
851REQUIRES(an == bn && an == rn, BAD_SIZE);
852 int k;
853 switch(code) {
854 OPZO(0,"zipI Add",+)
855 OPZO(1,"zipI Sub",-)
856 OPZO(2,"zipI Mul",*)
857 OPZO(3,"zipI Div",/)
858 OPZO(6,"zipI Mod",%)
859 default: ERROR(BAD_CODE);
860 }
861}
862
739 863
740#define OPZOb(C,msg,O) case C: {DEBUGMSG(msg) for(k=0;k<an;k++) r2p[k] = a2p[k] O b2p[k]; OK } 864#define OPZOb(C,msg,O) case C: {DEBUGMSG(msg) for(k=0;k<an;k++) r2p[k] = a2p[k] O b2p[k]; OK }
741#define OPZEb(C,msg,E) case C: {DEBUGMSG(msg) for(k=0;k<an;k++) r2p[k] = E(a2p[k],b2p[k]); OK } 865#define OPZEb(C,msg,E) case C: {DEBUGMSG(msg) for(k=0;k<an;k++) r2p[k] = E(a2p[k],b2p[k]); OK }
@@ -990,6 +1114,18 @@ int sort_valuesI(KIVEC(v),IVEC(r)) {
990 OK 1114 OK
991} 1115}
992 1116
1117int
1118compare_longs(const void *a, const void *b) {
1119 return *(int64_t*)a > *(int64_t*)b;
1120}
1121
1122int sort_valuesL(KLVEC(v),LVEC(r)) {
1123 memcpy(rp,vp,vn*sizeof(int64_t));
1124 qsort(rp,rn,sizeof(int64_t),compare_ints);
1125 OK
1126}
1127
1128
993//////////////////////////////////////// 1129////////////////////////////////////////
994 1130
995 1131
@@ -1010,7 +1146,7 @@ int sort_valuesI(KIVEC(v),IVEC(r)) {
1010 OK 1146 OK
1011 1147
1012 1148
1013typedef struct SDI { int pos; double val;} DI; 1149typedef struct DI { int pos; double val;} DI;
1014 1150
1015int compare_doubles_i (const void *a, const void *b) { 1151int compare_doubles_i (const void *a, const void *b) {
1016 return ((DI*)a)->val > ((DI*)b)->val; 1152 return ((DI*)a)->val > ((DI*)b)->val;
@@ -1043,6 +1179,17 @@ int sort_indexI(KIVEC(v),IVEC(r)) {
1043} 1179}
1044 1180
1045 1181
1182typedef struct LI { int pos; int64_t val;} LI;
1183
1184int compare_longs_i (const void *a, const void *b) {
1185 return ((II*)a)->val > ((II*)b)->val;
1186}
1187
1188int sort_indexL(KLVEC(v),LVEC(r)) {
1189 SORTIDX_IMP(II,compare_longs_i)
1190}
1191
1192
1046//////////////////////////////////////////////////////////////////////////////// 1193////////////////////////////////////////////////////////////////////////////////
1047 1194
1048int round_vector(KDVEC(v),DVEC(r)) { 1195int round_vector(KDVEC(v),DVEC(r)) {
@@ -1088,6 +1235,44 @@ int range_vector(IVEC(r)) {
1088 OK 1235 OK
1089} 1236}
1090 1237
1238///////////////////////////
1239
1240
1241int round_vector_l(KDVEC(v),LVEC(r)) {
1242 int k;
1243 for(k=0; k<vn; k++) {
1244 rp[k] = round(vp[k]);
1245 }
1246 OK
1247}
1248
1249
1250int mod_vector_l(int64_t m, KLVEC(v), LVEC(r)) {
1251 int k;
1252 for(k=0; k<vn; k++) {
1253 rp[k] = vp[k] % m;
1254 }
1255 OK
1256}
1257
1258int div_vector_l(int64_t m, KLVEC(v), LVEC(r)) {
1259 int k;
1260 for(k=0; k<vn; k++) {
1261 rp[k] = vp[k] / m;
1262 }
1263 OK
1264}
1265
1266int range_vector_l(LVEC(r)) {
1267 int k;
1268 for(k=0; k<rn; k++) {
1269 rp[k] = k;
1270 }
1271 OK
1272}
1273
1274
1275
1091//////////////////// constant ///////////////////////// 1276//////////////////// constant /////////////////////////
1092 1277
1093int constantF(float * pval, FVEC(r)) { 1278int constantF(float * pval, FVEC(r)) {
@@ -1143,65 +1328,46 @@ int constantI(int * pval, IVEC(r)) {
1143} 1328}
1144 1329
1145 1330
1146//////////////////// float-double conversion /////////////////////////
1147 1331
1148int float2double(FVEC(x),DVEC(y)) { 1332int constantL(int64_t * pval, LVEC(r)) {
1149 DEBUGMSG("float2double") 1333 DEBUGMSG("constantL")
1150 int k; 1334 int k;
1151 for(k=0;k<xn;k++) { 1335 int64_t val = *pval;
1152 yp[k]=xp[k]; 1336 for(k=0;k<rn;k++) {
1337 rp[k]=val;
1153 } 1338 }
1154 OK 1339 OK
1155} 1340}
1156 1341
1157int float2int(KFVEC(x),IVEC(y)) {
1158 DEBUGMSG("float2int")
1159 int k;
1160 for(k=0;k<xn;k++) {
1161 yp[k]=xp[k];
1162 }
1163 OK
1164}
1165 1342
1343//////////////////// type conversions /////////////////////////
1166 1344
1167int double2float(DVEC(x),FVEC(y)) { 1345#define CONVERT_IMP { \
1168 DEBUGMSG("double2float") 1346 int k; \
1169 int k; 1347 for(k=0;k<xn;k++) { \
1170 for(k=0;k<xn;k++) { 1348 yp[k]=xp[k]; \
1171 yp[k]=xp[k]; 1349 } \
1172 } 1350 OK }
1173 OK
1174}
1175 1351
1352int float2double(FVEC(x),DVEC(y)) CONVERT_IMP
1176 1353
1177int double2int(KDVEC(x),IVEC(y)) { 1354int float2int(KFVEC(x),IVEC(y)) CONVERT_IMP
1178 DEBUGMSG("double2int")
1179 int k;
1180 for(k=0;k<xn;k++) {
1181 yp[k]=xp[k];
1182 }
1183 OK
1184}
1185 1355
1356int double2float(DVEC(x),FVEC(y)) CONVERT_IMP
1186 1357
1187int int2float(KIVEC(x),FVEC(y)) { 1358int double2int(KDVEC(x),IVEC(y)) CONVERT_IMP
1188 DEBUGMSG("int2float")
1189 int k;
1190 for(k=0;k<xn;k++) {
1191 yp[k]=xp[k];
1192 }
1193 OK
1194}
1195 1359
1360int double2long(KDVEC(x),LVEC(y)) CONVERT_IMP
1196 1361
1197int int2double(KIVEC(x),DVEC(y)) { 1362int int2float(KIVEC(x),FVEC(y)) CONVERT_IMP
1198 DEBUGMSG("int2double") 1363
1199 int k; 1364int int2double(KIVEC(x),DVEC(y)) CONVERT_IMP
1200 for(k=0;k<xn;k++) { 1365
1201 yp[k]=xp[k]; 1366int int2long(KIVEC(x),LVEC(y)) CONVERT_IMP
1202 } 1367
1203 OK 1368int lont2int(KLVEC(x),IVEC(y)) CONVERT_IMP
1204} 1369
1370int long2double(KLVEC(x),DVEC(y)) CONVERT_IMP
1205 1371
1206 1372
1207//////////////////// conjugate ///////////////////////// 1373//////////////////// conjugate /////////////////////////
@@ -1249,6 +1415,11 @@ int stepI(KIVEC(x),IVEC(y)) {
1249 STEP_IMP 1415 STEP_IMP
1250} 1416}
1251 1417
1418int stepL(KLVEC(x),LVEC(y)) {
1419 STEP_IMP
1420}
1421
1422
1252//////////////////// cond ///////////////////////// 1423//////////////////// cond /////////////////////////
1253 1424
1254#define COMPARE_IMP \ 1425#define COMPARE_IMP \
@@ -1272,26 +1443,10 @@ int compareI(KIVEC(x),KIVEC(y),IVEC(r)) {
1272 COMPARE_IMP 1443 COMPARE_IMP
1273} 1444}
1274 1445
1275 1446int compareL(KLVEC(x),KLVEC(y),IVEC(r)) {
1276#define COND_IMP \ 1447 COMPARE_IMP
1277 REQUIRES(xn==yn && xn==ltn && xn==eqn && xn==gtn && xn==rn ,BAD_SIZE); \
1278 int k; \
1279 for(k=0;k<xn;k++) { \
1280 rp[k] = xp[k]<yp[k]?ltp[k]:(xp[k]>yp[k]?gtp[k]:eqp[k]); \
1281 } \
1282 OK
1283
1284int condF(FVEC(x),FVEC(y),FVEC(lt),FVEC(eq),FVEC(gt),FVEC(r)) {
1285 COND_IMP
1286}
1287
1288int condD(DVEC(x),DVEC(y),DVEC(lt),DVEC(eq),DVEC(gt),DVEC(r)) {
1289 COND_IMP
1290} 1448}
1291 1449
1292int condI(KIVEC(x),KIVEC(y),KIVEC(lt),KIVEC(eq),KIVEC(gt),IVEC(r)) {
1293 COND_IMP
1294}
1295 1450
1296 1451
1297#define CHOOSE_IMP \ 1452#define CHOOSE_IMP \
@@ -1314,6 +1469,11 @@ int chooseI(KIVEC(cond),KIVEC(lt),KIVEC(eq),KIVEC(gt),IVEC(r)) {
1314 CHOOSE_IMP 1469 CHOOSE_IMP
1315} 1470}
1316 1471
1472int chooseL(KIVEC(cond),KLVEC(lt),KLVEC(eq),KLVEC(gt),LVEC(r)) {
1473 CHOOSE_IMP
1474}
1475
1476
1317int chooseC(KIVEC(cond),KCVEC(lt),KCVEC(eq),KCVEC(gt),CVEC(r)) { 1477int chooseC(KIVEC(cond),KCVEC(lt),KCVEC(eq),KCVEC(gt),CVEC(r)) {
1318 CHOOSE_IMP 1478 CHOOSE_IMP
1319} 1479}