ceres之cholesky求解器

2021-10-07 05:29:56 字數 2572 閱讀 8217

normal_sparse_cholesky:

dense_cholesky:

normal_sparse_cholesky:

輸入:a,b,d,求解(a'*a+d'*d)x = a'*b

主調函式:

dynamicsparsenormalcholeskysolver::dynamicsparsenormalcholeskysolver(

const linearsolver::options& options)

: options_(options) {}

linearsolver::summary dynamicsparsenormalcholeskysolver::solveimpl(

compressedrowsparsematrix* a,

const double* b,

const linearsolver::persolveoptions& per_solve_options,

double* x) else

} linearsolver::summary summary;

switch (options_.sparse_linear_algebra_library_type)

if (per_solve_options.d != null)

return summary;

}

主要步驟:1)x = a'*b:

a->leftmultiply(b, x);

2)若d不等於0:a = a+diag(d)

3)solve(ax=b):

以eigen求解為例:

linearsolver::summary dynamicsparsenormalcholeskysolver::solveimplusingeigen(

compressedrowsparsematrix* a, double* rhs_and_solution)

event_logger.addevent("analyze");

if (solver.info() != eigen::success)

solver.factorize(lhs);

event_logger.addevent("factorize");

if (solver.info() != eigen::success)

const vector rhs = vectorref(rhs_and_solution, lhs.cols());

vectorref(rhs_and_solution, lhs.cols()) = solver.solve(rhs);

event_logger.addevent("solve");

if (solver.info() != eigen::success)

return summary;

#endif // ceres_use_eigen_sparse

}

(3.1)a = a'*a+d'*d

(3.2)通過eigen庫內置的cholesky求解器:

eigen::simplicialldlt> solver

求解ax=b得到x值

dense_cholesky:

linearsolver::summary densenormalcholeskysolver::solveimpl(

densesparsematrix* a,

const double* b,

const linearsolver::persolveoptions& per_solve_options,

double* x) else

}linearsolver::summary densenormalcholeskysolver::solveusingeigen(

densesparsematrix* a,

const double* b,

const linearsolver::persolveoptions& per_solve_options,

double* x)

event_logger.addevent("product");

linearsolver::summary summary;

summary.num_iterations = 1;

summary.termination_type = linear_solver_success;

eigen::lltllt =

lhs.selfadjointview().llt();

if (llt.info() != eigen::success) else

vectorref(x, num_cols) = llt.solve(rhs);

event_logger.addevent("solve");

return summary;

}

跟稀疏chloesky分解差不多,區別在於係數矩陣是不是稀疏矩陣,然後求解器變成了:

eigen::lltllt =lhs.selfadjointview().llt();

Ceres學習筆記之CMakeLists寫法總結

高博說 不要長期徘徊在自己的舒適區里猶豫不決,這樣是沒有進步的。這句話開啟了我的slam後端優化學習之路。本文從cmakelists開始,總結常用的各個庫在cmakelists中的寫法。眾人 哇!又是這麼小兒科的嗎?博主 哎呀 不要這樣講嘛 qwq我會一直努力的 通常的cmakelists結構是 c...

通過前代法後代法列主元Cholesky求解Ax b

矩陣分解 function a matrix builder n 對於乙個n,我們按課本120頁要求生成 n 1 2 n 1 2的矩陣 a diag repmat 4 1,n 1 2 diag repmat 1 1,n n 2 1 diag repmat 1 1,n n 2 1 diag repma...

遞迴之求冪

剛開始學習用遞迴實現x的n次方時,其思想 或者遞推式 一般如下 x n x x n 1 n 0 x n 1 n 0 c語言 如下 int64為有符號8位元組整數 int64 power int x,int n return x power x,n 1 這種簡單的求冪演算法的時間複雜度為o n 下面介...