int gsl_linalg_pcholesky_solve(const gsl_matrix * LDLT, const gsl_permutation * p, const gsl_vector * b, gsl_vector * x) { if (LDLT->size1 != LDLT->size2) { GSL_ERROR ("LDLT matrix must be square", GSL_ENOTSQR); } else if (LDLT->size1 != p->size) { GSL_ERROR ("matrix size must match permutation size", GSL_EBADLEN); } else if (LDLT->size1 != b->size) { GSL_ERROR ("matrix size must match b size", GSL_EBADLEN); } else if (LDLT->size2 != x->size) { GSL_ERROR ("matrix size must match solution size", GSL_EBADLEN); } else { int status; gsl_vector_memcpy (x, b); status = gsl_linalg_pcholesky_svx (LDLT, p, x); return status; } }
/* x := A^{-1} x = A^{-t} x, A = L D L^T */ static int cholesky_LDLT_Ainv(CBLAS_TRANSPOSE_t TransA, gsl_vector * x, void * params) { int status; pcholesky_params *par = (pcholesky_params *) params; (void) TransA; /* unused parameter warning */ status = gsl_linalg_pcholesky_svx(par->LDLT, par->perm, x); return status; }
int gsl_linalg_pcholesky_svx2(const gsl_matrix * LDLT, const gsl_permutation * p, const gsl_vector * S, gsl_vector * x) { if (LDLT->size1 != LDLT->size2) { GSL_ERROR ("LDLT matrix must be square", GSL_ENOTSQR); } else if (LDLT->size1 != p->size) { GSL_ERROR ("matrix size must match permutation size", GSL_EBADLEN); } else if (LDLT->size1 != S->size) { GSL_ERROR ("matrix size must match S", GSL_EBADLEN); } else if (LDLT->size2 != x->size) { GSL_ERROR ("matrix size must match solution size", GSL_EBADLEN); } else { int status; /* x := S b */ gsl_vector_mul(x, S); /* solve: A~ x~ = b~, with A~ = S A S, b~ = S b */ status = gsl_linalg_pcholesky_svx(LDLT, p, x); if (status) return status; /* compute: x = S x~ */ gsl_vector_mul(x, S); return GSL_SUCCESS; } }