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;
120 R.transpose().triangularView<
Eigen::Upper>().solveInPlace(b);
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");
const gtsam::Symbol key('X', 0)
void transposeSolve(const Vector &y, Vector &x) const override
implement x = L^{-T} y
A matrix or vector expression mapping an existing array of data.
Rot2 R(Rot2::fromAngle(0.1))
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
~BlockJacobiPreconditioner() override
static const SmartProjectionParams params
std::vector< size_t > dims_
virtual std::map< Key, Matrix > hessianBlockDiagonal() const
Linear Factor Graph where all factors are Gaussians.
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
void build(const GaussianFactorGraph &gfg, const KeyInfo &info, const std::map< Key, Vector > &lambda) override
build/factorize the preconditioner
cout<< "The eigenvalues of A are:"<< endl<< ces.eigenvalues()<< endl;cout<< "The matrix of eigenvectors, V, is:"<< endl<< ces.eigenvectors()<< endl<< endl;complex< float > lambda
ofstream os("timeSchurFactors.csv")
ostream & operator<<(ostream &os, const PreconditionerParameters &p)
void solve(const Vector &y, Vector &x) const override
implement x = L^{-1} y
std::vector< size_t > colSpec() const
Return a vector of dimensions ordered by ordering()
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
std::shared_ptr< Preconditioner > createPreconditioner(const std::shared_ptr< PreconditionerParameters > params)