diff --git a/Makefile b/Makefile index 8c990b8f..68005dea 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ nalgebra_lib_path=lib nalgebra_doc_path=doc all: mkdir -p $(nalgebra_lib_path) - rust build src/nalgebra.rc --out-dir $(nalgebra_lib_path) + rust build src/nalgebra.rc --out-dir $(nalgebra_lib_path) --opt-level 3 test: mkdir -p $(nalgebra_lib_path) diff --git a/src/adaptors/rotmat.rs b/src/adaptors/rotmat.rs index 8ff29df5..5e65ebf3 100644 --- a/src/adaptors/rotmat.rs +++ b/src/adaptors/rotmat.rs @@ -6,7 +6,7 @@ use traits::dim::Dim; use traits::inv::Inv; use traits::transpose::Transpose; use traits::rotation::Rotation; -use traits::delta_transform::DeltaTransform; +use traits::delta_transform::{DeltaTransform, DeltaTransformVector}; use dim1::vec1::Vec1; use dim2::mat2::Mat2; use dim3::mat3::Mat3; @@ -141,6 +141,12 @@ impl DeltaTransform for Rotmat { self.submat } } +impl + Copy, V: Copy> DeltaTransformVector for Rotmat +{ + fn delta_transform_vector(&self, v: &V) -> V + { self.submat.rmul(v) } +} + impl Inv for Rotmat { fn invert(&mut self) diff --git a/src/adaptors/transform.rs b/src/adaptors/transform.rs index b0811522..201e48bd 100644 --- a/src/adaptors/transform.rs +++ b/src/adaptors/transform.rs @@ -6,7 +6,7 @@ use traits::inv::Inv; use traits::rotation::Rotation; use traits::translation::Translation; use traits::transpose::Transpose; -use traits::delta_transform::DeltaTransform; +use traits::delta_transform::{DeltaTransform, DeltaTransformVector}; use traits::workarounds::rlmul::{RMul, LMul}; #[deriving(Eq, ToStr)] @@ -51,16 +51,16 @@ Mul, Transform> for Transform } } -impl, V> RMul for Transform +impl, V: Add> RMul for Transform { fn rmul(&self, other: &V) -> V - { self.submat.rmul(other) } + { self.submat.rmul(other) + self.subtrans } } -impl, V> LMul for Transform +impl, V: Add> LMul for Transform { fn lmul(&self, other: &V) -> V - { self.submat.lmul(other) } + { self.submat.lmul(other) + self.subtrans } } impl> Translation for Transform @@ -104,6 +104,12 @@ impl DeltaTransform for Transform { self.submat } } +impl + Copy, V> DeltaTransformVector for Transform +{ + fn delta_transform_vector(&self, v: &V) -> V + { self.submat.rmul(v) } +} + impl, V:Copy + Neg> Inv for Transform { diff --git a/src/traits/delta_transform.rs b/src/traits/delta_transform.rs index 73f16c33..5db90891 100644 --- a/src/traits/delta_transform.rs +++ b/src/traits/delta_transform.rs @@ -7,6 +7,13 @@ pub trait DeltaTransform
{ /// Extracts the delta transformation associated with this transformation. fn delta_transform(&self) -> DT; - // FIXME: add functions to apply the delta-transform to a vector without - // explicit computation of the transform (does this avoid some matrix copy?) +} + +/** + * Trait of delta-transformations on vectors. + */ +pub trait DeltaTransformVector +{ + /// Applies a delta-transform to a vector. + fn delta_transform_vector(&self, &V) -> V; }