Skip to content

Commit

Permalink
fix (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
prehner authored Oct 23, 2024
1 parent f289344 commit 4bcdc9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ num-traits = "0.2"
typenum = "1.17"
pyo3 = { version = "0.22", optional = true }
numpy = { version = "0.22", optional = true }
num-dual = { version = "0.10", optional = true }

[features]
default = []
Expand Down
21 changes: 21 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,15 @@ impl<T, U> Quantity<T, U> {
{
&self.0 / unit.0
}

/// Convert a quantity into the given unit and return it
/// as a float or array.
pub fn convert_into<T2>(self, unit: Quantity<T2, U>) -> Quot<T, T2>
where
T: Div<T2>,
{
self.0 / unit.0
}
}

impl<U> Zero for Quantity<f64, U> {
Expand All @@ -454,3 +463,15 @@ impl<U> Zero for Quantity<f64, U> {
self.0.is_zero()
}
}

#[cfg(feature = "num-dual")]
mod num_dual {
use super::Quantity;
use num_dual::DualNum;

impl<D: DualNum<f64>, U> Quantity<D, U> {
pub fn re(&self) -> Quantity<f64, U> {
Quantity::new(self.0.re())
}
}
}

0 comments on commit 4bcdc9f

Please sign in to comment.