示例#1
0
文件: scs.c 项目: tkelman/scs
static void updateWork(Data * d, Work * w, Sol * sol) {
	/* before normalization */
	idxint n = d->n;
	idxint m = d->m;
	w->nm_b = calcNorm(d->b, m);
	w->nm_c = calcNorm(d->c, n);
#ifdef EXTRAVERBOSE
	printArray(d->b, d->m, "b");
	scs_printf("pre-normalized norm b = %4f\n", calcNorm(d->b, d->m));
	printArray(d->c, d->n, "c");
	scs_printf("pre-normalized norm c = %4f\n", calcNorm(d->c, d->n));
#endif
	if (d->NORMALIZE) {
		normalizeBC(d, w);
#ifdef EXTRAVERBOSE
		printArray(d->b, d->m, "bn");
		scs_printf("sc_b = %4f\n", w->sc_b);
		scs_printf("post-normalized norm b = %4f\n", calcNorm(d->b, d->m));
		printArray(d->c, d->n, "cn");
		scs_printf("sc_c = %4f\n", w->sc_c);
		scs_printf("post-normalized norm c = %4f\n", calcNorm(d->c, d->n));
#endif
	}
	if (d->WARM_START) {
		warmStartVars(d, w, sol);
	} else {
		coldStartVars(d, w);
	}
	memcpy(w->h, d->c, n * sizeof(pfloat));
	memcpy(&(w->h[d->n]), d->b, m * sizeof(pfloat));
	memcpy(w->g, w->h, (n + m) * sizeof(pfloat));
	solveLinSys(d, w->p, w->g, NULL, -1);
	scaleArray(&(w->g[d->n]), -1, m);
	w->gTh = innerProd(w->h, w->g, n + m);
}
示例#2
0
文件: scs.c 项目: tkelman/scs
/* status < 0 indicates failure */
static idxint projectLinSys(Data * d, Work * w, idxint iter) {
	/* ut = u + v */
	idxint n = d->n, m = d->m, l = n + m + 1, status;
	memcpy(w->u_t, w->u, l * sizeof(pfloat));
	addScaledArray(w->u_t, w->v, l, 1.0);

	scaleArray(w->u_t, d->RHO_X, n);

	addScaledArray(w->u_t, w->h, l - 1, -w->u_t[l - 1]);
	addScaledArray(w->u_t, w->h, l - 1, -innerProd(w->u_t, w->g, l - 1) / (w->gTh + 1));
	scaleArray(&(w->u_t[n]), -1, m);

	status = solveLinSys(d, w->p, w->u_t, w->u, iter);

	w->u_t[l - 1] += innerProd(w->u_t, w->h, l - 1);

	return status;
}
示例#3
0
// Konstruiere die Umkugel fuer vier Punkte
Sphere::Sphere(Vector3d& a, Vector3d& b, Vector3d& c, Vector3d& d) {
    center=solveLinSys(a,b,c,d);
    radius=(a-center).length();
}