Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added matrix assign ops and col_mut methods.
- Loading branch information
1 parent
1b403ee
commit e0adc30
Showing
10 changed files
with
284 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Adds common vector trait implementations. | ||
// The traits here should be supported for all types of $t and all sizes of vector. | ||
macro_rules! impl_matn_common_traits { | ||
($t:ty, $matn:ident, $vecn:ident) => { | ||
impl Default for $matn { | ||
#[inline(always)] | ||
fn default() -> Self { | ||
Self::IDENTITY | ||
} | ||
} | ||
|
||
impl Add<$matn> for $matn { | ||
type Output = Self; | ||
#[inline(always)] | ||
fn add(self, other: Self) -> Self::Output { | ||
Self(self.0.add_matrix(&other.0)) | ||
} | ||
} | ||
|
||
impl AddAssign<$matn> for $matn { | ||
#[inline(always)] | ||
fn add_assign(&mut self, other: Self) { | ||
self.0 = self.0.add_matrix(&other.0); | ||
} | ||
} | ||
|
||
impl Sub<$matn> for $matn { | ||
type Output = Self; | ||
#[inline(always)] | ||
fn sub(self, other: Self) -> Self::Output { | ||
Self(self.0.sub_matrix(&other.0)) | ||
} | ||
} | ||
|
||
impl SubAssign<$matn> for $matn { | ||
#[inline(always)] | ||
fn sub_assign(&mut self, other: Self) { | ||
self.0 = self.0.sub_matrix(&other.0); | ||
} | ||
} | ||
|
||
impl Mul<$matn> for $matn { | ||
type Output = Self; | ||
#[inline(always)] | ||
fn mul(self, other: Self) -> Self::Output { | ||
Self(self.0.mul_matrix(&other.0)) | ||
} | ||
} | ||
|
||
impl MulAssign<$matn> for $matn { | ||
#[inline(always)] | ||
fn mul_assign(&mut self, other: Self) { | ||
self.0 = self.0.mul_matrix(&other.0); | ||
} | ||
} | ||
|
||
impl Mul<$vecn> for $matn { | ||
type Output = $vecn; | ||
#[inline(always)] | ||
fn mul(self, other: $vecn) -> Self::Output { | ||
$vecn(self.0.mul_vector(other.0)) | ||
} | ||
} | ||
|
||
impl Mul<$matn> for $t { | ||
type Output = $matn; | ||
#[inline(always)] | ||
fn mul(self, other: $matn) -> Self::Output { | ||
$matn(other.0.mul_scalar(self)) | ||
} | ||
} | ||
|
||
impl Mul<$t> for $matn { | ||
type Output = Self; | ||
#[inline(always)] | ||
fn mul(self, other: $t) -> Self::Output { | ||
Self(self.0.mul_scalar(other)) | ||
} | ||
} | ||
|
||
impl MulAssign<$t> for $matn { | ||
#[inline(always)] | ||
fn mul_assign(&mut self, other: $t) { | ||
self.0 = self.0.mul_scalar(other); | ||
} | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl<'a> Sum<&'a Self> for $matn { | ||
fn sum<I>(iter: I) -> Self | ||
where | ||
I: Iterator<Item = &'a Self>, | ||
{ | ||
iter.fold(Self::ZERO, |a, &b| Self::add(a, b)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl<'a> Product<&'a Self> for $matn { | ||
fn product<I>(iter: I) -> Self | ||
where | ||
I: Iterator<Item = &'a Self>, | ||
{ | ||
iter.fold(Self::IDENTITY, |a, &b| Self::mul(a, b)) | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.