Go to the documentation of this file.
37 using namespace gtsam;
81 for (
size_t mode : {0, 1}) {
103 for (
size_t mode : {0, 1}) {
128 std::vector<DiscreteKey> discrete_keys = {
mode};
135 std::vector<double>
ratio(2);
136 for (
size_t mode : {0, 1}) {
162 EXPECT(continuousParentKeys.size() == 1);
163 EXPECT(continuousParentKeys[0] ==
X(0));
177 double negLogConstant0 =
conditionals[0]->negLogConstant();
178 double negLogConstant1 =
conditionals[1]->negLogConstant();
179 double minErrorConstant =
std::min(negLogConstant0, negLogConstant1);
184 std::vector<double> leaves = {
192 for (
size_t mode : {0, 1}) {
221 const auto jf1 = std::dynamic_pointer_cast<JacobianFactor>(gf1);
233 std::vector<double>
ratio(2);
234 for (
size_t mode : {0, 1}) {
246 const std::vector<GaussianConditional::shared_ptr>
gcs = {
263 keys.push_back({
M(3), 2});
265 for (
size_t i = 0;
i < 8;
i++) {
266 std::vector<double> potentials{0, 0, 0, 0, 0, 0, 0, 0};
277 const std::vector<double> potentials{0, 0, 0.5, 0,
289 hgc->conditionals()({{M(1), 0}, {M(2), 1}})->negLogConstant(),
290 pruned->negLogConstant(), 1
e-9);
293 const std::vector<double> potentials{0.2, 0, 0.3, 0,
322 std::dynamic_pointer_cast<HybridConditional>(
hc->restrict({}));
325 EXPECT(same->asHybrid()->nrComponents() == 4);
327 const auto oneParent =
328 std::dynamic_pointer_cast<HybridConditional>(
hc->restrict({{M(1), 0}}));
330 EXPECT(oneParent->isHybrid());
331 EXPECT(oneParent->asHybrid()->nrComponents() == 2);
333 const auto oneParent2 = std::dynamic_pointer_cast<HybridConditional>(
334 hc->restrict({{M(7), 0}, {M(1), 0}}));
336 EXPECT(oneParent2->isHybrid());
337 EXPECT(oneParent2->asHybrid()->nrComponents() == 2);
339 const auto gaussian = std::dynamic_pointer_cast<HybridConditional>(
340 hc->restrict({{M(1), 0}, {M(2), 1}}));
342 EXPECT(gaussian->asGaussian());
static int runAllTests(TestResult &result)
Eigen::Matrix< double, 1, 1 > Vector1
Conditional Gaussian Base class.
A hybrid conditional in the Conditional Linear Gaussian scheme.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
AlgebraicDecisionTree< Key > errorTree(const VectorValues &continuousValues) const override
Compute error of the HybridGaussianFactor as a tree.
#define EXPECT_LONGS_EQUAL(expected, actual)
#define EXPECT(condition)
const HybridGaussianConditional hybrid_conditional(mode, conditionals)
static const DiscreteValues assignment0
DiscreteKeys is a set of keys that can be assembled using the & operator.
static const VectorValues vv
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
A set of GaussianFactors, indexed by a set of discrete keys.
static const DiscreteValues assignment1
const std::vector< GaussianConditional::shared_ptr > gcs
double evaluate(const HybridValues &values) const override
Calculate probability density for given values.
double logProbability(const HybridValues &values) const override
Compute the logProbability of this hybrid Gaussian conditional.
static const DiscreteKey mode(modeKey, 2)
Decision Tree for use in DiscreteFactors.
static bool CheckInvariants(const HybridGaussianConditional &conditional, const VALUES &x)
A conditional of gaussian conditionals indexed by discrete variables, as part of a Bayes Network....
KeyVector continuousParents() const
Returns the continuous keys among the parents.
std::shared_ptr< HybridGaussianFactor > likelihood(const VectorValues &given) const
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
specialized key for discrete variables
a decision tree is a function from assignments to values.
TEST(SmartFactorBase, Pinhole)
std::pair< Key, size_t > DiscreteKey
const HybridGaussianConditional::Conditionals conditionals(modes, gcs)
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size ratio
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
double negLogConstant() const override
Return log normalization constant in negative log space.
static const HybridValues hv0
double error(const HybridValues &values) const override
Compute the log-likelihood, including the log-normalizing constant.
abc_eqf_lib::State< N > M
std::uint64_t Key
Integer nonlinear key type.
static const HybridValues hv1
constexpr descr< N - 1 > _(char const (&text)[N])
static shared_ptr sharedMeanAndStddev(Args &&... args)
Create shared pointer by forwarding arguments to fromMeanAndStddev.
gtsam
Author(s):
autogenerated on Wed May 28 2025 03:06:34