Priv * initPriv(const AMatrix * A, const Settings * stgs) { Priv * p = scs_calloc(1, sizeof(Priv)); p->p = scs_malloc((A->n) * sizeof(scs_float)); p->r = scs_malloc((A->n) * sizeof(scs_float)); p->Gp = scs_malloc((A->n) * sizeof(scs_float)); p->tmp = scs_malloc((A->m) * sizeof(scs_float)); /* memory for A transpose */ p->At = scs_malloc(sizeof(AMatrix)); p->At->m = A->n; p->At->n = A->m; p->At->i = scs_malloc((A->p[A->n]) * sizeof(scs_int)); p->At->p = scs_malloc((A->m + 1) * sizeof(scs_int)); p->At->x = scs_malloc((A->p[A->n]) * sizeof(scs_float)); transpose(A, p); /* preconditioner memory */ p->z = scs_malloc((A->n) * sizeof(scs_float)); p->M = scs_malloc((A->n) * sizeof(scs_float)); getPreconditioner(A, stgs, p); totalSolveTime = 0; totCgIts = 0; if (!p->p || !p->r || !p->Gp || !p->tmp || !p->At || !p->At->i || !p->At->p || !p->At->x) { freePriv(p); return NULL; } return p; }
void scs_finish(Data * d, Work * w) { finishCone(); if (w) { if (d && d->NORMALIZE) unNormalizeA(d, w); freePriv(w->p); freeWork(w); } }
Priv * initPriv(const AMatrix * A, const Settings * stgs) { Priv * p = scs_calloc(1, sizeof(Priv)); scs_int n_plus_m = A->n + A->m; p->P = scs_malloc(sizeof(scs_int) * n_plus_m); p->L = scs_malloc(sizeof(cs)); p->bp = scs_malloc(n_plus_m * sizeof(scs_float)); p->L->m = n_plus_m; p->L->n = n_plus_m; p->L->nz = -1; if (factorize(A, stgs, p) < 0) { freePriv(p); return NULL; } totalSolveTime = 0.0; return p; }