30 os <<
"PreconditionerParameters" << endl
31 <<
"kernel: " << kernelTranslator(kernel_) << endl
32 <<
"verbosity: " << verbosityTranslator(verbosity_) << endl;
46 if (
s ==
"GTSAM")
return PreconditionerParameters::GTSAM;
47 else if (
s ==
"CHOLMOD")
return PreconditionerParameters::CHOLMOD;
49 else return PreconditionerParameters::CHOLMOD;
57 if (
s ==
"SILENT")
return PreconditionerParameters::SILENT;
58 else if (
s ==
"COMPLEXITY")
return PreconditionerParameters::COMPLEXITY;
59 else if (
s ==
"ERROR")
return PreconditionerParameters::ERROR;
61 else return PreconditionerParameters::SILENT;
66 if ( k == GTSAM )
return "GTSAM";
67 if ( k == CHOLMOD )
return "CHOLMOD";
68 else return "UNKNOWN";
73 if (verbosity == SILENT)
return "SILENT";
74 else if (verbosity == COMPLEXITY)
return "COMPLEXITY";
75 else if (verbosity == ERROR)
return "ERROR";
76 else return "UNKNOWN";
80 BlockJacobiPreconditioner::BlockJacobiPreconditioner()
81 :
Base(), buffer_(0), bufferSize_(0), nnz_(0) {}
89 const size_t n =
dims_.size();
90 double *ptr =
buffer_, *dst =
x.data();
92 std::copy(
y.data(),
y.data() +
y.rows(),
x.data());
94 for (
size_t i = 0 ;
i <
n ; ++
i ) {
96 const size_t sz =
d*
d;
109 const size_t n =
dims_.size();
110 double *ptr =
buffer_, *dst =
x.data();
112 std::copy(
y.data(),
y.data() +
y.rows(),
x.data());
114 for (
size_t i = 0 ;
i <
n ; ++
i ) {
116 const size_t sz =
d*
d;
132 const size_t n = keyInfo.size();
137 std::vector<Matrix> blocks; blocks.reserve(
n);
141 for (
size_t i = 0 ;
i <
n ; ++
i ) {
142 const size_t dim =
dims_[
i];
150 for (
const auto& [
key, hessian]: hessianMap) {
151 blocks.push_back(hessian);
164 for (
size_t i = 0 ;
i <
n ; ++
i ) {
167 const Matrix L = blocks[
i].llt().matrixL();
171 std::copy(
L.data(),
L.data() + sz, ptr);
190 const std::shared_ptr<PreconditionerParameters>
params) {
191 using std::dynamic_pointer_cast;
192 if (dynamic_pointer_cast<DummyPreconditionerParameters>(
params)) {
193 return std::make_shared<DummyPreconditioner>();
194 }
else if (dynamic_pointer_cast<BlockJacobiPreconditionerParameters>(
196 return std::make_shared<BlockJacobiPreconditioner>();
197 }
else if (
auto subgraph =
198 dynamic_pointer_cast<SubgraphPreconditionerParameters>(
200 return std::make_shared<SubgraphPreconditioner>(*subgraph);
203 throw invalid_argument(
204 "createPreconditioner: unexpected preconditioner parameter type");