Skip to content

Commit

Permalink
Document the shapes of the Jacobians (#62)
Browse files Browse the repository at this point in the history
* Document the shapes of the Jacobians

* Documentation fixes
  • Loading branch information
JeffLIrion committed Nov 10, 2023
1 parent f83b969 commit 7113c2c
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 49 deletions.
145 changes: 144 additions & 1 deletion graphslam/pose/base_pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ def __iadd__(self, other):
def jacobian_self_oplus_other_wrt_self(self, other):
r"""Compute the Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1`.
Let
.. code::
# The dimensionality of `self`
n_self = len(self.to_array())
# The dimensionality of `self + other`
n_oplus = len((self + other).to_array())
Then the shape of the Jacobian will be ``n_oplus x n_self``.
Parameters
----------
other : BasePose
Expand All @@ -192,6 +204,18 @@ def jacobian_self_oplus_other_wrt_self(self, other):
def jacobian_self_oplus_other_wrt_self_compact(self, other):
r"""Compute the Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1`.
Let
.. code::
# The dimensionality of `self`
n_self = len(self.to_array())
# The compact dimensionality of `self + other`
n_compact = (self + other).COMPACT_DIMENSIONALITY
Then the shape of the Jacobian will be ``n_compact x n_self``.
Parameters
----------
other : BasePose
Expand All @@ -208,6 +232,18 @@ def jacobian_self_oplus_other_wrt_self_compact(self, other):
def jacobian_self_oplus_other_wrt_other(self, other):
r"""Compute the Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2`.
Let
.. code::
# The dimensionality of `other`
n_other = len(other.to_array())
# The dimensionality of `self + other`
n_oplus = len((self + other).to_array())
Then the shape of the Jacobian will be ``n_oplus x n_other``.
Parameters
----------
other : BasePose
Expand All @@ -224,6 +260,18 @@ def jacobian_self_oplus_other_wrt_other(self, other):
def jacobian_self_oplus_other_wrt_other_compact(self, other):
r"""Compute the Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2`.
Let
.. code::
# The dimensionality of `other`
n_other = len(other.to_array())
# The compact dimensionality of `self + other`
n_compact = (self + other).COMPACT_DIMENSIONALITY
Then the shape of the Jacobian will be ``n_compact x n_other``.
Parameters
----------
other : BasePose
Expand All @@ -240,6 +288,18 @@ def jacobian_self_oplus_other_wrt_other_compact(self, other):
def jacobian_self_ominus_other_wrt_self(self, other):
r"""Compute the Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_1`.
Let
.. code::
# The dimensionality of `self`
n_self = len(self.to_array())
# The dimensionality of `self - other`
n_ominus = len((self - other).to_array())
Then the shape of the Jacobian will be ``n_ominus x n_self``.
Parameters
----------
other : BasePose
Expand All @@ -256,6 +316,18 @@ def jacobian_self_ominus_other_wrt_self(self, other):
def jacobian_self_ominus_other_wrt_self_compact(self, other):
r"""Compute the Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_1`.
Let
.. code::
# The dimensionality of `self`
n_self = len(self.to_array())
# The compact dimensionality of `self - other`
n_compact = (self - other).COMPACT_DIMENSIONALITY
Then the shape of the Jacobian will be ``n_compact x n_self``.
Parameters
----------
other : BasePose
Expand All @@ -272,6 +344,18 @@ def jacobian_self_ominus_other_wrt_self_compact(self, other):
def jacobian_self_ominus_other_wrt_other(self, other):
r"""Compute the Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_2`.
Let
.. code::
# The dimensionality of `other`
n_other = len(other.to_array())
# The dimensionality of `self - other`
n_ominus = len((self - other).to_array())
Then the shape of the Jacobian will be ``n_ominus x n_other``.
Parameters
----------
other : BasePose
Expand All @@ -288,6 +372,18 @@ def jacobian_self_ominus_other_wrt_other(self, other):
def jacobian_self_ominus_other_wrt_other_compact(self, other):
r"""Compute the Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_2`.
Let
.. code::
# The dimensionality of `other`
n_other = len(other.to_array())
# The compact dimensionality of `self - other`
n_compact = (self - other).COMPACT_DIMENSIONALITY
Then the shape of the Jacobian will be ``n_compact x n_other``.
Parameters
----------
other : BasePose
Expand All @@ -304,6 +400,20 @@ def jacobian_self_ominus_other_wrt_other_compact(self, other):
def jacobian_boxplus(self):
r"""Compute the Jacobian of :math:`p_1 \boxplus \Delta \mathbf{x}` w.r.t. :math:`\Delta \mathbf{x}` evaluated at :math:`\Delta \mathbf{x} = \mathbf{0}`.
Let
.. code::
# The dimensionality of :math:`\Delta \mathbf{x}`, which should be the same as
# the compact dimensionality of `self`
n_dx = self.COMPACT_DIMENSIONALITY
# The dimensionality of :math:`p_1 \boxplus \Delta \mathbf{x}`, which should be
# the same as the dimensionality of `self`
n_boxplus = len(self.to_array())
Then the shape of the Jacobian will be ``n_boxplus x n_dx``.
Returns
-------
np.ndarray
Expand All @@ -315,6 +425,18 @@ def jacobian_boxplus(self):
def jacobian_self_oplus_point_wrt_self(self, point):
r"""Compute the Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1`, where `:math:p_2` is a point.
Let
.. code::
# The dimensionality of `self`
n_self = len(self.to_array())
# The dimensionality of `self + point`
n_oplus = len((self + point).to_array())
Then the shape of the Jacobian will be ``n_oplus x n_self``.
Parameters
----------
point : BasePose
Expand All @@ -331,6 +453,18 @@ def jacobian_self_oplus_point_wrt_self(self, point):
def jacobian_self_oplus_point_wrt_point(self, point):
r"""Compute the Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2`, where `:math:p_2` is a point.
Let
.. code::
# The dimensionality of `point`
n_point = len(point.to_array())
# The dimensionality of `self + point`
n_oplus = len((self + point).to_array())
Then the shape of the Jacobian will be ``n_oplus x n_point``.
Parameters
----------
point : BasePose
Expand All @@ -347,10 +481,19 @@ def jacobian_self_oplus_point_wrt_point(self, point):
def jacobian_inverse(self):
r"""Compute the Jacobian of :math:`p^{-1}`.
Let
.. code::
# The dimensionality of `self`
n_self = len(self.to_array())
Then the shape of the Jacobian will be ``n_self x n_self``.
Returns
-------
np.ndarray
The Jacobian of :math:`p^{-1}
The Jacobian of :math:`p^{-1}`
"""
raise NotImplementedError
24 changes: 12 additions & 12 deletions graphslam/pose/r2.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def jacobian_self_oplus_other_wrt_self(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1`.
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -181,7 +181,7 @@ def jacobian_self_oplus_other_wrt_self_compact(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1`.
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -197,7 +197,7 @@ def jacobian_self_oplus_other_wrt_other(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2`.
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -213,7 +213,7 @@ def jacobian_self_oplus_other_wrt_other_compact(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2`.
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -229,7 +229,7 @@ def jacobian_self_ominus_other_wrt_self(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_1`.
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_1` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -245,7 +245,7 @@ def jacobian_self_ominus_other_wrt_self_compact(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_1`.
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_1` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -261,7 +261,7 @@ def jacobian_self_ominus_other_wrt_other(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_2`.
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_2` (shape: ``2 x 2``)
"""
return -np.eye(2)
Expand All @@ -277,7 +277,7 @@ def jacobian_self_ominus_other_wrt_other_compact(self, other):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_2`.
The Jacobian of :math:`p_1 \ominus p_2` w.r.t. :math:`p_2` (shape: ``2 x 2``)
"""
return -np.eye(2)
Expand All @@ -288,7 +288,7 @@ def jacobian_boxplus(self):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \boxplus \Delta \mathbf{x}` w.r.t. :math:`\Delta \mathbf{x}` evaluated at :math:`\Delta \mathbf{x} = \mathbf{0}`
The Jacobian of :math:`p_1 \boxplus \Delta \mathbf{x}` w.r.t. :math:`\Delta \mathbf{x}` evaluated at :math:`\Delta \mathbf{x} = \mathbf{0}` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -304,7 +304,7 @@ def jacobian_self_oplus_point_wrt_self(self, point):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1`.
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_1` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -320,7 +320,7 @@ def jacobian_self_oplus_point_wrt_point(self, point):
Returns
-------
np.ndarray
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2`.
The Jacobian of :math:`p_1 \oplus p_2` w.r.t. :math:`p_2` (shape: ``2 x 2``)
"""
return np.eye(2)
Expand All @@ -331,7 +331,7 @@ def jacobian_inverse(self):
Returns
-------
np.ndarray
The Jacobian of :math:`p^{-1}
The Jacobian of :math:`p^{-1}` (shape: ``2 x 2``)
"""
return -np.eye(2)

0 comments on commit 7113c2c

Please sign in to comment.