From d3029e12e0b5e3f3940bb652276eeeb6daf4a4b7 Mon Sep 17 00:00:00 2001 From: roman shushakov Date: Sun, 28 Nov 2021 08:17:58 +0300 Subject: [PATCH] init --- .gitignore | 2 + Cargo.lock | 7 +++ src/lib.rs | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4570d34 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.toml diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..992a226 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "extended_matrix_float" +version = "0.1.0" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..95a84f8 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,145 @@ +pub trait MyFloatTrait +{ + type Other; + + fn my_powi(&self, n: i32) -> Self; + fn my_sqrt(&self) -> Self; + fn my_acos(&self) -> Self; + fn my_cos(&self) -> Self; + fn my_sin(&self) -> Self; + fn my_abs(&self) -> Self; + fn my_asin(&self) -> Self; + fn my_atan2(&self, other: Self::Other) -> Self; + fn my_atan(&self) -> Self; + fn my_to_degrees(&self) -> Self; +} + + +impl MyFloatTrait for f32 +{ + type Other = f32; + + fn my_powi(&self, n: i32) -> Self + { + self.powi(n) + } + + + fn my_sqrt(&self) -> Self + { + self.sqrt() + } + + + fn my_acos(&self) -> Self + { + self.acos() + } + + + fn my_cos(&self) -> Self + { + self.cos() + } + + + fn my_sin(&self) -> Self + { + self.sin() + } + + + fn my_abs(&self) -> Self + { + self.abs() + } + + + fn my_asin(&self) -> Self + { + self.asin() + } + + + fn my_atan2(&self, other: Self::Other) -> Self + { + self.atan2(other) + } + + + fn my_atan(&self) -> Self + { + self.atan() + } + + + fn my_to_degrees(&self) -> Self + { + self.to_degrees() + } +} + + +impl MyFloatTrait for f64 +{ + type Other = f64; + + fn my_powi(&self, n: i32) -> Self + { + self.powi(n) + } + + + fn my_sqrt(&self) -> Self + { + self.sqrt() + } + + + fn my_acos(&self) -> Self + { + self.acos() + } + + + fn my_cos(&self) -> Self + { + self.cos() + } + + + fn my_sin(&self) -> Self + { + self.sin() + } + + + fn my_abs(&self) -> Self + { + self.abs() + } + + + fn my_asin(&self) -> Self + { + self.asin() + } + + + fn my_atan2(&self, other: Self::Other) -> Self + { + self.atan2(other) + } + + + fn my_atan(&self) -> Self + { + self.atan() + } + + + fn my_to_degrees(&self) -> Self + { + self.to_degrees() + } +}