-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::{ | ||
approx::sqrt::RawApprox, fraction::approx::Accuracy, generic::GenericInteger, GenericDecimal, | ||
}; | ||
use num::{ | ||
bigint::{ToBigInt, ToBigUint}, | ||
BigUint, Integer, | ||
}; | ||
use std::borrow::Borrow; | ||
|
||
impl< | ||
T: Clone + Integer + ToBigUint + ToBigInt + GenericInteger, | ||
P: Copy + Integer + Into<usize>, | ||
> GenericDecimal<T, P> | ||
{ | ||
/// See `GenericFraction::sqrt_abs_with_accuracy_raw`. | ||
pub fn sqrt_abs_with_accuracy_raw(&self, accuracy: impl Borrow<Accuracy>) -> RawApprox { | ||
self.0.sqrt_abs_with_accuracy_raw(accuracy) | ||
} | ||
|
||
/// See `GenericFraction::sqrt_abs_with_accuracy`. | ||
pub fn sqrt_abs_with_accuracy( | ||
&self, | ||
accuracy: impl Borrow<Accuracy>, | ||
) -> GenericDecimal<BigUint, P> { | ||
GenericDecimal(self.0.sqrt_abs_with_accuracy(accuracy), self.1) | ||
} | ||
|
||
/// See `GenericFraction::sqrt_abs_raw`. | ||
pub fn sqrt_abs_raw(&self, decimal_places: u32) -> RawApprox { | ||
self.0.sqrt_abs_raw(decimal_places) | ||
} | ||
|
||
/// See `GenericFraction::sqrt_abs`. | ||
pub fn sqrt_abs(&self, decimal_places: u32) -> GenericDecimal<BigUint, P> { | ||
GenericDecimal(self.0.sqrt_abs(decimal_places), self.1) | ||
} | ||
|
||
/// See `GenericFraction::sqrt_with_accuracy_raw`. | ||
pub fn sqrt_with_accuracy_raw(&self, accuracy: impl Borrow<Accuracy>) -> RawApprox { | ||
self.0.sqrt_with_accuracy_raw(accuracy) | ||
} | ||
|
||
/// See `GenericFraction::sqrt_with_accuracy`. | ||
pub fn sqrt_with_accuracy( | ||
&self, | ||
accuracy: impl Borrow<Accuracy>, | ||
) -> GenericDecimal<BigUint, P> { | ||
GenericDecimal(self.0.sqrt_with_accuracy(accuracy), self.1) | ||
} | ||
|
||
/// See `GenericFraction::sqrt_raw`. | ||
pub fn sqrt_raw(&self, decimal_places: u32) -> RawApprox { | ||
self.0.sqrt_raw(decimal_places) | ||
} | ||
|
||
/// See `GenericFraction::sqrt`. | ||
pub fn sqrt(&self, decimal_places: u32) -> GenericDecimal<BigUint, P> { | ||
GenericDecimal(self.0.sqrt(decimal_places), self.1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters