diff options
Diffstat (limited to 'packages/base/src/Internal/C')
-rw-r--r-- | packages/base/src/Internal/C/lapack-aux.c | 38 | ||||
-rw-r--r-- | packages/base/src/Internal/C/vector-aux.c | 32 |
2 files changed, 41 insertions, 29 deletions
diff --git a/packages/base/src/Internal/C/lapack-aux.c b/packages/base/src/Internal/C/lapack-aux.c index 7da6f6a..1601bef 100644 --- a/packages/base/src/Internal/C/lapack-aux.c +++ b/packages/base/src/Internal/C/lapack-aux.c | |||
@@ -1290,29 +1290,25 @@ int multiplyQ(int ta, int tb, KQMAT(a),KQMAT(b),QMAT(r)) { | |||
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | 1292 | ||
1293 | int multiplyI(KOIMAT(a), KOIMAT(b), OIMAT(r)) { | 1293 | #define MULT_IMP_VER(OP) \ |
1294 | { TRAV(r,i,j) { | 1294 | { TRAV(r,i,j) { \ |
1295 | int k; | 1295 | int k; \ |
1296 | AT(r,i,j) = 0; | 1296 | AT(r,i,j) = 0; \ |
1297 | for (k=0;k<ac;k++) { | 1297 | for (k=0;k<ac;k++) { \ |
1298 | AT(r,i,j) += AT(a,i,k) * AT(b,k,j); | 1298 | OP \ |
1299 | } | 1299 | } \ |
1300 | } | 1300 | } \ |
1301 | } | 1301 | } |
1302 | OK | ||
1303 | } | ||
1304 | 1302 | ||
1305 | int multiplyL(KOLMAT(a), KOLMAT(b), OLMAT(r)) { | 1303 | #define MULT_IMP { \ |
1306 | { TRAV(r,i,j) { | 1304 | if (m==1) { \ |
1307 | int k; | 1305 | MULT_IMP_VER( AT(r,i,j) += AT(a,i,k) * AT(b,k,j); ) \ |
1308 | AT(r,i,j) = 0; | 1306 | } else { \ |
1309 | for (k=0;k<ac;k++) { | 1307 | MULT_IMP_VER( AT(r,i,j) = (AT(r,i,j) + (AT(a,i,k) * AT(b,k,j)) % m) % m ; ) \ |
1310 | AT(r,i,j) += AT(a,i,k) * AT(b,k,j); | 1308 | } OK } |
1311 | } | 1309 | |
1312 | } | 1310 | int multiplyI(int m, KOIMAT(a), KOIMAT(b), OIMAT(r)) MULT_IMP |
1313 | } | 1311 | int multiplyL(int32_t m, KOLMAT(a), KOLMAT(b), OLMAT(r)) MULT_IMP |
1314 | OK | ||
1315 | } | ||
1316 | 1312 | ||
1317 | 1313 | ||
1318 | ////////////////// sparse matrix-product /////////////////////////////////////// | 1314 | ////////////////// sparse matrix-product /////////////////////////////////////// |
diff --git a/packages/base/src/Internal/C/vector-aux.c b/packages/base/src/Internal/C/vector-aux.c index 70e46bc..580aa1c 100644 --- a/packages/base/src/Internal/C/vector-aux.c +++ b/packages/base/src/Internal/C/vector-aux.c | |||
@@ -58,20 +58,28 @@ int sumR(KDVEC(x),DVEC(r)) { | |||
58 | OK | 58 | OK |
59 | } | 59 | } |
60 | 60 | ||
61 | int sumI(KIVEC(x),IVEC(r)) { | 61 | int sumI(int m, KIVEC(x),IVEC(r)) { |
62 | REQUIRES(rn==1,BAD_SIZE); | 62 | REQUIRES(rn==1,BAD_SIZE); |
63 | int i; | 63 | int i; |
64 | int res = 0; | 64 | int res = 0; |
65 | for (i = 0; i < xn; i++) res += xp[i]; | 65 | if (m==1) { |
66 | for (i = 0; i < xn; i++) res += xp[i]; | ||
67 | } else { | ||
68 | for (i = 0; i < xn; i++) res = (res + xp[i]) % m; | ||
69 | } | ||
66 | rp[0] = res; | 70 | rp[0] = res; |
67 | OK | 71 | OK |
68 | } | 72 | } |
69 | 73 | ||
70 | int sumL(KLVEC(x),LVEC(r)) { | 74 | int sumL(int32_t m, KLVEC(x),LVEC(r)) { |
71 | REQUIRES(rn==1,BAD_SIZE); | 75 | REQUIRES(rn==1,BAD_SIZE); |
72 | int i; | 76 | int i; |
73 | int res = 0; | 77 | int res = 0; |
74 | for (i = 0; i < xn; i++) res += xp[i]; | 78 | if (m==1) { |
79 | for (i = 0; i < xn; i++) res += xp[i]; | ||
80 | } else { | ||
81 | for (i = 0; i < xn; i++) res = (res + xp[i]) % m; | ||
82 | } | ||
75 | rp[0] = res; | 83 | rp[0] = res; |
76 | OK | 84 | OK |
77 | } | 85 | } |
@@ -127,20 +135,28 @@ int prodR(KDVEC(x),DVEC(r)) { | |||
127 | OK | 135 | OK |
128 | } | 136 | } |
129 | 137 | ||
130 | int prodI(KIVEC(x),IVEC(r)) { | 138 | int prodI(int m, KIVEC(x),IVEC(r)) { |
131 | REQUIRES(rn==1,BAD_SIZE); | 139 | REQUIRES(rn==1,BAD_SIZE); |
132 | int i; | 140 | int i; |
133 | int res = 1; | 141 | int res = 1; |
134 | for (i = 0; i < xn; i++) res *= xp[i]; | 142 | if (m==1) { |
143 | for (i = 0; i < xn; i++) res *= xp[i]; | ||
144 | } else { | ||
145 | for (i = 0; i < xn; i++) res = (res * xp[i]) % m; | ||
146 | } | ||
135 | rp[0] = res; | 147 | rp[0] = res; |
136 | OK | 148 | OK |
137 | } | 149 | } |
138 | 150 | ||
139 | int prodL(KLVEC(x),LVEC(r)) { | 151 | int prodL(int32_t m, KLVEC(x),LVEC(r)) { |
140 | REQUIRES(rn==1,BAD_SIZE); | 152 | REQUIRES(rn==1,BAD_SIZE); |
141 | int i; | 153 | int i; |
142 | int res = 1; | 154 | int res = 1; |
143 | for (i = 0; i < xn; i++) res *= xp[i]; | 155 | if (m==1) { |
156 | for (i = 0; i < xn; i++) res *= xp[i]; | ||
157 | } else { | ||
158 | for (i = 0; i < xn; i++) res = (res * xp[i]) % m; | ||
159 | } | ||
144 | rp[0] = res; | 160 | rp[0] = res; |
145 | OK | 161 | OK |
146 | } | 162 | } |