Untitled

unknown
plain_text
2 years ago
1.5 kB
5
Indexable
Never
```node_t* extend(node_t* p, int m, int n, double** a, double* b, double* c, int k, double ak, double bk) {
node_t* q = calloc(1, sizeof(node_t));
q->k = k;
q->ak = ak;
q->bk = bk;
if (ak > 0 && p.max[k] < HUGE_VAL) {
q->m = p->m;
} else if (ak < 0 && p->min[k] > 0) {
q->m = p->m;
} else {
q->m = p->m + 1;
}
q->n = p->n;
q->h = -1;
q->a = make_matrix(q->m+1, q->n+1);
q->b = calloc(q->m+1, sizeof(double));
q->c = calloc(q->n+1, sizeof(double));
q->x = calloc(q->n+1, sizeof(double));
q->min = calloc(n, sizeof(double));
q->max = calloc(n, sizeof(double));
int i, j;
for(i = 0; i < n; i++) {
q->min[i] = p->min[i];
q->max[i] = p->max[i];
}
for(i = 0; i < m; i++) {
for(j = 0; j < n + 1; j++) {
q->a[i][j] = a[i][j];
}
q->b[i] = b[i];
}
//Eller n? Hur lång är c?
for(i = 0; i < n+1; i++) {
q->c[i] = c[i];
}
if(ak > 0) {
if(q->max[k] = HUGE_VAL || bk < q->max[k]) {
q->max[k] = bk;
}
} else if (q->min[k] = -HUGE_VAL ||bk > q->min[k]) {
q->min[k] = -bk;
}
for(i = m, j = 0; j < n; j++) {
if(q->min[j] > -HUGE_VAL) {
q->a[i][j] = -1;
q->b[i] = -q->min[j];
i++;
}
if(q->max[j] < HUGE_VAL) {
q->a[i][j] = 1;
q->b[i] = q->max[j];
i++;
}
}
return q;
}```