Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: sophus_core ==> {sophus_autodiff, sophus_spline, sophus_tensor, sophus_timeseries} #52

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[workspace]
members = [
"crates/sophus",
"crates/sophus_core",
"crates/sophus_lie",
"crates/sophus_autodiff",
"crates/sophus_tensor",
"crates/sophus_image",
"crates/sophus_lie",
"crates/sophus_geo",
"crates/sophus_spline",
"crates/sophus_sensor",
"crates/sophus_opt",
"crates/sophus_timeseries",
"crates/sophus_renderer",
"crates/sophus_viewer",
"crates/sophus_sim",
Expand All @@ -23,12 +26,15 @@ version = "0.11.0"

[workspace.dependencies]
sophus = { path = "crates/sophus", version = "0.11.0" }
sophus_core = { path = "crates/sophus_core", version = "0.11.0" }
sophus_autodiff = { path = "crates/sophus_autodiff", version = "0.11.0" }
sophus_tensor = { path = "crates/sophus_tensor", version = "0.11.0" }
sophus_image = { path = "crates/sophus_image", version = "0.11.0" }
sophus_lie = { path = "crates/sophus_lie", version = "0.11.0" }
sophus_geo = { path = "crates/sophus_geo", version = "0.11.0" }
sophus_opt = { path = "crates/sophus_opt", version = "0.11.0" }
sophus_spline = { path = "crates/sophus_spline", version = "0.11.0" }
sophus_sensor = { path = "crates/sophus_sensor", version = "0.11.0" }
sophus_opt = { path = "crates/sophus_opt", version = "0.11.0" }
sophus_timeseries = { path = "crates/sophus_timeseries", version = "0.11.0" }
sophus_renderer = { path = "crates/sophus_renderer", version = "0.11.0" }
sophus_sim = { path = "crates/sophus_sim", version = "0.11.0" }
sophus_viewer = { path = "crates/sophus_viewer", version = "0.11.0" }
Expand Down
6 changes: 3 additions & 3 deletions crates/sophus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository.workspace = true
version.workspace = true

[dependencies]
sophus_core.workspace = true
sophus_autodiff.workspace = true
sophus_geo.workspace = true
sophus_image.workspace = true
sophus_lie.workspace = true
Expand All @@ -37,14 +37,14 @@ wgpu.workspace = true

[features]
simd = [
"sophus_core/simd",
"sophus_autodiff/simd",
"sophus_image/simd",
"sophus_lie/simd",
"sophus_opt/simd",
"sophus_sensor/simd",
]
std = [
"sophus_core/std",
"sophus_autodiff/std",
"sophus_image/std",
"sophus_lie/std",
"sophus_opt/std",
Expand Down
6 changes: 3 additions & 3 deletions crates/sophus/src/examples/viewer_example.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sophus_core::linalg::SVec;
use sophus_core::linalg::VecF64;
use sophus_core::prelude::IsVector;
use sophus_autodiff::linalg::SVec;
use sophus_autodiff::linalg::VecF64;
use sophus_autodiff::prelude::IsVector;
use sophus_image::arc_image::ArcImage4U8;
use sophus_image::mut_image::MutImage4U8;
use sophus_image::mut_image_view::IsMutImageView;
Expand Down
2 changes: 1 addition & 1 deletion crates/sophus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![doc = include_str!(concat!("../", std::env!("CARGO_PKG_README")))]

#[doc(inline)]
pub use sophus_core as core;
pub use sophus_autodiff as core;
#[doc(inline)]
pub use sophus_geo as geo;
#[doc(inline)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
description = "sophus - geometry for robotics and computer vision"
name = "sophus_core"
name = "sophus_autodiff"
readme = "../../README.md"

edition.workspace = true
Expand All @@ -12,7 +12,6 @@ version.workspace = true

[dependencies]
approx.workspace = true
concat-arrays.workspace = true
log.workspace = true
nalgebra.workspace = true
ndarray.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ pub mod scalar;
pub mod vector;

#[cfg(feature = "simd")]
pub use crate::calculus::dual::dual_batch_matrix::DualBatchMatrix;
pub use crate::dual::dual_batch_matrix::DualBatchMatrix;
#[cfg(feature = "simd")]
pub use crate::calculus::dual::dual_batch_scalar::DualBatchScalar;
pub use crate::dual::dual_batch_scalar::DualBatchScalar;
#[cfg(feature = "simd")]
pub use crate::calculus::dual::dual_batch_vector::DualBatchVector;
pub use crate::calculus::dual::dual_matrix::DualMatrix;
pub use crate::calculus::dual::dual_scalar::DualScalar;
pub use crate::calculus::dual::dual_vector::DualVector;
pub use crate::dual::dual_batch_vector::DualBatchVector;
pub use crate::dual::dual_matrix::DualMatrix;
pub use crate::dual::dual_scalar::DualScalar;
pub use crate::dual::dual_vector::DualVector;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::calculus::dual::dual_batch_scalar::DualBatchScalar;
use crate::calculus::dual::DualBatchVector;
use crate::dual::dual_batch_scalar::DualBatchScalar;
use crate::dual::DualBatchVector;
use crate::linalg::batch_mask::BatchMask;
use crate::linalg::BatchMatF64;
use crate::linalg::BatchScalarF64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::dual_scalar::DualScalar;
pub use crate::calculus::dual::dual_batch_matrix::DualBatchMatrix;
pub use crate::calculus::dual::dual_batch_vector::DualBatchVector;
pub use crate::dual::dual_batch_matrix::DualBatchMatrix;
pub use crate::dual::dual_batch_vector::DualBatchVector;
use crate::linalg::batch_mask::BatchMask;
use crate::linalg::scalar::NumberCategory;
use crate::linalg::BatchMatF64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::vector::HasJacobian;
use super::vector::VectorValuedDerivative;
use crate::calculus::dual::dual_batch_scalar::DualBatchScalar;
use crate::calculus::dual::DualBatchMatrix;
use crate::dual::dual_batch_scalar::DualBatchScalar;
use crate::dual::DualBatchMatrix;
use crate::linalg::batch_mask::BatchMask;
use crate::linalg::BatchMatF64;
use crate::linalg::BatchScalarF64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::calculus::dual::DualScalar;
use crate::calculus::dual::DualVector;
use crate::dual::DualScalar;
use crate::dual::DualVector;
use crate::linalg::MatF64;
use crate::linalg::SMat;
use crate::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ pub trait IsDualMatrix<
#[test]
fn dual_matrix_tests() {
#[cfg(feature = "simd")]
use crate::calculus::dual::DualBatchScalar;
use crate::calculus::dual::DualScalar;
use crate::calculus::maps::matrix_valued_maps::MatrixValuedMatrixMap;
use crate::dual::DualBatchScalar;
use crate::dual::DualScalar;
#[cfg(feature = "simd")]
use crate::linalg::BatchScalarF64;
use crate::linalg::EPS_F64;
use crate::maps::matrix_valued_maps::MatrixValuedMatrixMap;
use crate::prelude::IsScalar;

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ pub trait IsDualScalar<const BATCH: usize, const DM: usize, const DN: usize>:
#[test]
fn dual_scalar_tests() {
#[cfg(feature = "simd")]
use crate::calculus::dual::DualBatchScalar;
use crate::calculus::dual::DualScalar;
use crate::calculus::maps::curves::ScalarValuedCurve;
use crate::dual::DualBatchScalar;
use crate::dual::DualScalar;
#[cfg(feature = "simd")]
use crate::linalg::BatchScalarF64;
use crate::linalg::EPS_F64;
use crate::maps::curves::ScalarValuedCurve;

trait DualScalarTest {
fn run_dual_scalar_test();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,18 @@ pub trait HasJacobian<

#[test]
fn dual_vector_tests() {
use crate::calculus::dual::dual_scalar::DualScalar;
use crate::calculus::maps::scalar_valued_maps::ScalarValuedVectorMap;
use crate::calculus::maps::vector_valued_maps::VectorValuedVectorMap;
use crate::dual::dual_scalar::DualScalar;
#[cfg(feature = "simd")]
use crate::dual::DualBatchScalar;
use crate::linalg::vector::IsVector;
#[cfg(feature = "simd")]
use crate::linalg::BatchScalarF64;
use crate::linalg::EPS_F64;
use crate::maps::scalar_valued_maps::ScalarValuedVectorMap;
use crate::maps::vector_valued_maps::VectorValuedVectorMap;
use crate::points::example_points;
use crate::prelude::IsScalar;

#[cfg(feature = "simd")]
use crate::calculus::dual::DualBatchScalar;
#[cfg(feature = "simd")]
use crate::linalg::BatchScalarF64;

#[cfg(test)]
trait Test {
fn run();
Expand Down
51 changes: 15 additions & 36 deletions crates/sophus_core/src/lib.rs → crates/sophus_autodiff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,46 @@
#![deny(missing_docs)]
#![no_std]
#![allow(clippy::needless_range_loop)]
//! Core math functionality including
//! Automatic differentiation module
//! - linear algebra types
//! * such as [linalg::VecF64], and [linalg::MatF64]
//! * batch types such as [linalg::BatchScalarF64], [linalg::BatchVecF64],
//! [linalg::BatchMatF64] - require the `simd` feature
//! - tensors
//! * design: dynamic tensor (ndarray) of static tensors (nalgebra)
//! - differentiation tools
//! * dual numbers: [calculus::dual::DualScalar], [calculus::dual::DualVector],
//! - dual numbers: [calculus::dual::DualScalar], [calculus::dual::DualVector],
//! [calculus::dual::DualMatrix]
//! * [calculus::maps::curves] f: ℝ -> ℝ, f: ℝ -> ℝʳ, f: ℝ -> ℝʳ x ℝᶜ
//! * [calculus::maps::scalar_valued_maps]: f: ℝᵐ -> ℝ, f: ℝᵐ x ℝⁿ -> ℝ
//! * [calculus::maps::vector_valued_maps]: f: ℝᵐ -> ℝᵖ, f: ℝᵐ x ℝⁿ -> ℝᵖ
//! * [calculus::maps::matrix_valued_maps]: f: ℝᵐ -> ℝʳ x ℝᶜ, f: ℝᵐ x ℝⁿ -> ℝʳ x ℝᶜ
//! - splines
//! * [calculus::spline::CubicBSpline]
//! - intervals, regions
//! * closed interval: [calculus::region::Interval]
//! * closed region: [calculus::region::Interval]
//! - manifolds: [manifold::traits]

#[cfg(feature = "std")]
extern crate std;

/// calculus - differentiation, splines, and more
pub mod calculus;
/// dual numbers - for automatic differentiation
pub mod dual;
/// floating point
pub mod floating_point;
/// linear algebra types
/// core linear algebra types
pub mod linalg;
/// manifolds
pub mod manifold;
/// curves, scalar-valued, vector-valued, and matrix-valued maps
pub mod maps;
/// params
pub mod params;
/// points
pub mod points;
/// time series
pub mod time_series;

pub use crate::manifold::*;
pub use crate::params::*;
pub use crate::points::*;

pub use nalgebra;
pub use ndarray;

/// tensors
pub mod tensor;
pub use crate::tensor::arc_tensor::*;
pub use crate::tensor::mut_tensor::*;
pub use crate::tensor::mut_tensor_view::*;
pub use crate::tensor::tensor_view::*;
pub use crate::points::*;

/// sophus_core prelude
/// sophus_autodiff prelude
pub mod prelude {
pub use crate::calculus::dual::matrix::IsDualMatrix;
pub use crate::calculus::dual::scalar::IsDualScalar;
pub use crate::calculus::dual::vector::IsDualVector;
pub use crate::calculus::region::IsRegion;
pub use crate::dual::matrix::IsDualMatrix;
pub use crate::dual::scalar::IsDualScalar;
pub use crate::dual::vector::IsDualVector;
pub use crate::linalg::bool_mask::IsBoolMask;
pub use crate::linalg::matrix::IsMatrix;
pub use crate::linalg::matrix::IsRealMatrix;
Expand All @@ -72,10 +53,8 @@ pub mod prelude {
pub use crate::linalg::vector::IsRealVector;
pub use crate::linalg::vector::IsSingleVector;
pub use crate::linalg::vector::IsVector;
pub use crate::manifold::traits::IsManifold;
pub use crate::manifold::IsManifold;
pub use crate::manifold::IsTangent;
pub use crate::params::HasParams;
pub use crate::tensor::element::IsStaticTensor;
pub use crate::tensor::mut_tensor_view::IsMutTensorLike;
pub use crate::tensor::tensor_view::IsTensorLike;
pub use crate::tensor::tensor_view::IsTensorView;
pub use crate::params::IsParamsImpl;
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::calculus::dual::DualBatchMatrix;
use crate::dual::DualBatchMatrix;
use crate::linalg::BatchMatF64;
use crate::linalg::BatchScalarF64;
use crate::linalg::BatchVecF64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::calculus::dual::DualBatchMatrix;
use crate::calculus::dual::DualBatchScalar;
use crate::calculus::dual::DualBatchVector;
use crate::dual::DualBatchMatrix;
use crate::dual::DualBatchScalar;
use crate::dual::DualBatchVector;
use crate::linalg::scalar::IsBatchScalar;
use crate::linalg::scalar::NumberCategory;
use crate::linalg::BatchMatF64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::calculus::dual::DualBatchVector;
use crate::dual::DualBatchVector;
use crate::linalg::BatchMatF64;
use crate::linalg::BatchScalarF64;
use crate::linalg::BatchVecF64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::calculus::dual::DualMatrix;
use crate::dual::dual_matrix::DualMatrix;
use crate::linalg::MatF64;
use crate::linalg::VecF64;
use crate::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::calculus::dual::DualMatrix;
use crate::calculus::dual::DualScalar;
use crate::calculus::dual::DualVector;
use crate::dual::dual_matrix::DualMatrix;
use crate::dual::dual_scalar::DualScalar;
use crate::dual::dual_vector::DualVector;
use crate::linalg::MatF64;
use crate::linalg::VecF64;
use crate::linalg::EPS_F64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::calculus::dual::DualVector;
use crate::dual::dual_vector::DualVector;
use crate::linalg::MatF64;
use crate::linalg::VecF64;
use crate::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::linalg::VecF64;
use crate::params::ParamsImpl;
use crate::prelude::*;
use crate::params::HasParams;
use crate::prelude::IsScalar;
extern crate alloc;

/// A tangent implementation.
pub trait TangentImpl<
pub trait IsTangent<
S: IsScalar<BATCH, DM, DN>,
const DOF: usize,
const BATCH: usize,
Expand All @@ -16,22 +16,6 @@ pub trait TangentImpl<
fn tangent_examples() -> alloc::vec::Vec<S::Vector<DOF>>;
}

/// A manifold implementation.
pub trait ManifoldImpl<
S: IsScalar<BATCH, DM, DN>,
const DOF: usize,
const PARAMS: usize,
const BATCH: usize,
const DM: usize,
const DN: usize,
>: ParamsImpl<S, PARAMS, BATCH, DM, DN> + TangentImpl<S, DOF, BATCH, DM, DN>
{
/// o-plus operation.
fn oplus(params: &S::Vector<PARAMS>, tangent: &S::Vector<DOF>) -> S::Vector<PARAMS>;
/// o-minus operation.
fn ominus(params1: &S::Vector<PARAMS>, params2: &S::Vector<PARAMS>) -> S::Vector<DOF>;
}

/// A manifold.
pub trait IsManifold<
S: IsScalar<BATCH, DM, DN>,
Expand Down
Loading
Loading