the goober

This commit is contained in:
Quaternions 2023-10-26 20:20:12 -07:00
parent f7ee18076a
commit 0ec0d24302

View File

@ -2,31 +2,32 @@
use crate::integer::Planar64; use crate::integer::Planar64;
#[inline] #[inline]
pub fn zeroes2(a0:Planar64,a1:Planar64,a2:Planar64)->impl std::iter::IntoIterator{ pub fn zeroes2(a0:Planar64,a1:Planar64,a2:Planar64)->([Planar64;2],usize){
// if a2==Planar64::ZERO{ if a2==Planar64::ZERO{
// return zeroes1(a0,a1); let ([ret],ret_len)=zeroes1(a0,a1);
// } return ([ret,Planar64::ZERO],ret_len);
}
let radicand=a1.get() as i128*a1.get() as i128-a2.get() as i128*a0.get() as i128*4; let radicand=a1.get() as i128*a1.get() as i128-a2.get() as i128*a0.get() as i128*4;
if 0<radicand{ if 0<radicand{
//start with f64 sqrt //start with f64 sqrt
let planar_radicand=Planar64::raw(unsafe{(radicand as f64).sqrt().to_int_unchecked()}); let planar_radicand=Planar64::raw(unsafe{(radicand as f64).sqrt().to_int_unchecked()});
//TODO: one or two newtons //TODO: one or two newtons
if Planar64::ZERO<a2{ if Planar64::ZERO<a2{
[(-a1-planar_radicand)/(a2*2),(-a1+planar_radicand)/(a2*2)].into_iter() ([(-a1-planar_radicand)/(a2*2),(-a1+planar_radicand)/(a2*2)],2)
}else{ }else{
[(-a1+planar_radicand)/(a2*2),(-a1-planar_radicand)/(a2*2)].into_iter() ([(-a1+planar_radicand)/(a2*2),(-a1-planar_radicand)/(a2*2)],2)
} }
}else if radicand==0{ }else if radicand==0{
[a1/(a2*-2),Planar64::ZERO].into_iter() ([a1/(a2*-2),Planar64::ZERO],1)
}else{ }else{
[Planar64::ZERO,Planar64::ZERO].into_iter() ([Planar64::ZERO,Planar64::ZERO],0)
} }
} }
#[inline] #[inline]
pub fn zeroes1(a0:Planar64,a1:Planar64)->impl std::iter::IntoIterator{ pub fn zeroes1(a0:Planar64,a1:Planar64)->([Planar64;1],usize){
if a1==Planar64::ZERO{ if a1==Planar64::ZERO{
return [Planar64::ZERO].into_iter(); return ([Planar64::ZERO],0);
}else{ }else{
return [-a0/a1].into_iter(); return ([-a0/a1],1);
} }
} }