clean(maths::*): move fn
This commit is contained in:
parent
1e1a8457fa
commit
b48b516102
13
src/maths.rs
13
src/maths.rs
|
@ -3,6 +3,19 @@ use std::ops;
|
||||||
pub mod evaluator;
|
pub mod evaluator;
|
||||||
pub mod solver;
|
pub mod solver;
|
||||||
|
|
||||||
|
|
||||||
|
fn zero() -> GaussianRational {
|
||||||
|
GaussianRational::new(Rational::new(0, 1), Rational::new(0, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn minus_one() -> GaussianRational {
|
||||||
|
GaussianRational::new(Rational::new(-1, 1), Rational::new(0, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn one() -> GaussianRational {
|
||||||
|
GaussianRational::new(Rational::new(1, 1), Rational::new(0, 1))
|
||||||
|
}
|
||||||
|
|
||||||
//TODO slow ? check Stein's algorithm (binaryGCD) + tests
|
//TODO slow ? check Stein's algorithm (binaryGCD) + tests
|
||||||
fn gcd(a: i128, b: i128) -> i128 {
|
fn gcd(a: i128, b: i128) -> i128 {
|
||||||
if b == 0 {
|
if b == 0 {
|
||||||
|
|
|
@ -2,18 +2,6 @@ use super::*;
|
||||||
use crate::parser::Token;
|
use crate::parser::Token;
|
||||||
use crate::Node;
|
use crate::Node;
|
||||||
|
|
||||||
fn zero() -> GaussianRational {
|
|
||||||
GaussianRational::new(Rational::new(0, 1), Rational::new(0, 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn one() -> GaussianRational {
|
|
||||||
GaussianRational::new(Rational::new(1, 1), Rational::new(0, 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn minus_one() -> GaussianRational {
|
|
||||||
GaussianRational::new(Rational::new(-1, 1), Rational::new(0, 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add(lhs: Vec<GaussianRational>, rhs: Vec<GaussianRational>) -> Vec<GaussianRational> {
|
fn add(lhs: Vec<GaussianRational>, rhs: Vec<GaussianRational>) -> Vec<GaussianRational> {
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
let mut len = lhs.len();
|
let mut len = lhs.len();
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn zero() -> GaussianRational {
|
|
||||||
GaussianRational::new(Rational::new(0, 1), Rational::new(0, 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn minus_one() -> GaussianRational {
|
|
||||||
GaussianRational::new(Rational::new(-1, 1), Rational::new(0, 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn degree_zero(equation: Vec<GaussianRational>) {
|
fn degree_zero(equation: Vec<GaussianRational>) {
|
||||||
println!("Polynomial degree: 0");
|
println!("Polynomial degree: 0");
|
||||||
if equation[0] == zero() {
|
if equation[0] == zero() {
|
||||||
|
|
Loading…
Reference in New Issue