/// Implement nalgebra traits for complex numbers from `extra::complex::Cmplex`. use std::num::Zero; use extra::complex::Cmplx; use traits::operations::{Absolute, Inv}; use traits::structure::{Dim}; impl Absolute> for Cmplx { #[inline] fn absolute(&self) -> Cmplx { Cmplx::new(self.re.clone(), self.im.clone()) } } impl Inv for Cmplx { #[inline] fn inverse(&self) -> Option> { if self.is_zero() { None } else { let _1: N = NumCast::from(1.0); let divisor = _1 / (self.re * self.re - self.im * self.im); Some(Cmplx::new(self.re * divisor, -self.im * divisor)) } } #[inline] fn inplace_inverse(&mut self) -> bool { if self.is_zero() { false } else { let _1: N = NumCast::from(1.0); let divisor = _1 / (self.re * self.re - self.im * self.im); self.re = self.re * divisor; self.im = -self.im * divisor; true } } } impl Dim for Cmplx { #[inline] fn dim(unsused_self: Option>) -> uint { 2 } } impl Rotation> for Cmplx { #[inline] fn rotation(&self) -> Vec2 { } #[inline] fn inv_rotation(&self) -> Vec2 { -self.rotation(); } #[inline] fn rotate_by(&mut self, rotation: &Vec2) { } #[inline] fn rotated(&self, rotation: &Vec2) -> Cmplx { } #[inline] fn set_rotation(&mut self, rotation: Vec2) { } } impl Rotate> for Cmplx { #[inline] fn rotate(&self, rotation: &V) -> V { } #[inline] fn inv_rotate(&self, rotation: &V) -> V { } } impl RotationMatrix, Vec2, Rotmat>> for Cmplx { #[inline] fn to_rot_mat(&self) -> Rotmat> { } } impl Norm for Cmplx { #[inline] fn sqnorm(&self) -> N { } #[inline] fn normalized(&self) -> Self { } #[inline] fn normalize(&mut self) -> N { } } impl AbsoluteRotate { #[inline] fn absolute_rotate(&elf, v: &V) -> V { } }