summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-07 13:58:27 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-07 13:58:27 +0200
commitca0329fb7490b66b836448fea90d33a9658065b2 (patch)
tree0b7fe0ca1f2eeedcdbc3d99fe1b7cf271daaa06e
parentff81b0d3388b205044b88517a45d692bb3c24d7b (diff)
downloadct_sequence-ca0329fb7490b66b836448fea90d33a9658065b2.tar.gz
vork
-rw-r--r--src/a3.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/a3.c b/src/a3.c
index 7b0e80e..61c1b71 100644
--- a/src/a3.c
+++ b/src/a3.c
@@ -22,11 +22,14 @@ static uint8_t *m24;
static uint32_t *m32;
static size_t m24_n;
static size_t m32_n;
+static uint32_t bias;
-static void inner(uint32_t x);
+static void inner (uint32_t x);
+static void inner_bias(uint32_t x);
void a3_init(uint64_t n){
t = 0;
+ bias = 0;
m24_n = n > CROSSOVER ? CROSSOVER : n;
m32_n = n-m24_n;
m24 = calloc(sizeof(uint8_t)*M24_SIZE*m24_n,1);
@@ -41,21 +44,27 @@ void a3_loop(uint64_t x0,uint64_t x1){
if(x+M24_RANGE >= x1_32){
printf("LAST %10u -> %10u\n",x,x1_32);
for(;x < x1_32;x++){
- inner(x);
+ inner_bias(x); //TODO blabla
}
break;
}else{
printf(" %10u -> %10u\n",x,x+M24_RANGE);
uint32_t max = x+M24_RANGE;
- for(;x < max;x++){
- inner(x);
+ if(bias == 0){
+ for(;x < max;x++){
+ inner(x);
+ }
+ }else{
+ for(;x < max;x++){
+ inner_bias(x);
+ }
}
+ bias += M24_RANGE;
}
}
}
static void inner(uint32_t x){
- return;
uint32_t r;
if(t < CROSSOVER){
@@ -65,12 +74,32 @@ static void inner(uint32_t x){
p = m24+(t*M24_SIZE);
memcpy(&r,p,M24_SIZE);
memcpy(p,&x,M24_SIZE);
+ t = r == 0 ? 0 : x-r;
}else{
uint64_t i = t-m24_n;
r = m32[i];
m32[i] = x;
+ t = r == 0 ? 0 : x-r;
}
+}
+
+static void inner_bias(uint32_t x){
+ uint32_t r;
- t = r == 0 ? 0 : x-r;
+ if(t < CROSSOVER){
+ uint8_t *p;
+
+ r = 0;
+ p = m24+(t*M24_SIZE);
+ uint32_t i = x & 0x00FFFFFF;
+ memcpy(&r,p,M24_SIZE);
+ memcpy(p,&i,M24_SIZE);
+ t = (i-r) & 0x00FFFFFF;
+ }else{
+ uint64_t i = t-m24_n;
+ r = m32[i];
+ m32[i] = x;
+ t = r == 0 ? 0 : x-r;
+ }
}