Skip to content

Commit

Permalink
impl Outermorphism for Matrix4x4
Browse files Browse the repository at this point in the history
  • Loading branch information
ickk committed May 5, 2024
1 parent a6ae309 commit 637903a
Show file tree
Hide file tree
Showing 11 changed files with 398 additions and 39 deletions.
39 changes: 39 additions & 0 deletions ega/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,43 @@ use ::libm::Libm;

mod operators;
mod optional_features;
mod outermorphisms;
mod values;

pub use operators::*;
pub use outermorphisms::*;
pub use values::*;

/// return `Empty`
#[inline]
fn return_empty<Lhs, Rhs>(_: Lhs, _: Rhs) -> Empty {
Empty
}

/// return the left-hand-side
#[inline]
fn return_lhs<Lhs, Rhs>(lhs: Lhs, _: Rhs) -> Lhs {
lhs
}

/// return the right-hand-side
#[inline]
fn return_rhs<Lhs, Rhs>(_: Lhs, rhs: Rhs) -> Rhs {
rhs
}

/// negate and return the right-hand-side
#[inline]
fn return_neg_rhs<Lhs, Rhs: Neg<Output = Rhs>>(_: Lhs, rhs: Rhs) -> Rhs {
-rhs
}

/// return zero
#[inline]
fn return_zero<Lhs, Rhs, Output: Zero>(_: Lhs, _: Rhs) -> Output {
Output::zero()
}

#[rustfmt::skip]
#[cfg(any(test, doctest))]
mod test_values {
Expand Down Expand Up @@ -83,4 +115,11 @@ mod test_values {
pub const PSEUDOSCALAR_A: Pseudoscalar = Pseudoscalar { e0123: 397. };
pub const PSEUDOSCALAR_B: Pseudoscalar = Pseudoscalar { e0123: 401. };
pub const PSEUDOSCALAR_C: Pseudoscalar = Pseudoscalar { e0123: -409. };

pub const MATRIX_4X4_A: Matrix4x4 = Matrix4x4 {
m00: 1.0, m01: 0.5, m02: 0.5, m03: 0.5,
m10: 0.5, m11: 0.9, m12: -0.5, m13: -1.5,
m20: 0.5, m21: -1.0, m22: 0.5, m23: -2.0,
m30: 0.5, m31: -0.9, m32: 2.0, m33: -1.0,
};
}
1 change: 0 additions & 1 deletion ega/src/operators/add.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::{return_lhs, return_rhs};
use crate::*;

pub use ::core::ops::Add;
Expand Down
1 change: 0 additions & 1 deletion ega/src/operators/dot.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::return_empty;
use crate::*;

/// The inner product
Expand Down
1 change: 0 additions & 1 deletion ega/src/operators/geometric_product.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::return_empty;
use crate::*;

/// The geometric product
Expand Down
1 change: 0 additions & 1 deletion ega/src/operators/join.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::return_empty;
use crate::*;

/// The regressive product
Expand Down
1 change: 0 additions & 1 deletion ega/src/operators/meet.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::return_empty;
use crate::*;

/// The outer product
Expand Down
32 changes: 0 additions & 32 deletions ega/src/operators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ pub use reverse::Reverse;
pub use scalar_product::ScalarProduct;
pub use sub::Sub;

use crate::{values::Empty, Zero};

/// Grade Involution
pub trait Involution {
type Output;
Expand All @@ -55,33 +53,3 @@ pub trait Exponent<Rhs> {
/// Exponentiation
fn exp(self, rhs: Rhs) -> Self::Output;
}

/// return `Empty`
#[inline]
fn return_empty<Lhs, Rhs>(_: Lhs, _: Rhs) -> Empty {
Empty
}

/// return the left-hand-side
#[inline]
fn return_lhs<Lhs, Rhs>(lhs: Lhs, _: Rhs) -> Lhs {
lhs
}

/// return the right-hand-side
#[inline]
fn return_rhs<Lhs, Rhs>(_: Lhs, rhs: Rhs) -> Rhs {
rhs
}

/// negate and return the right-hand-side
#[inline]
fn return_neg_rhs<Lhs, Rhs: Neg<Output = Rhs>>(_: Lhs, rhs: Rhs) -> Rhs {
-rhs
}

/// return zero
#[inline]
fn return_zero<Lhs, Rhs, Output: Zero>(_: Lhs, _: Rhs) -> Output {
Output::zero()
}
1 change: 0 additions & 1 deletion ega/src/operators/scalar_product.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::return_zero;
use crate::*;

/// Scalar Product
Expand Down
1 change: 0 additions & 1 deletion ega/src/operators/sub.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::{return_lhs, return_neg_rhs};
use crate::*;

pub use core::ops::Sub;
Expand Down
Loading

0 comments on commit 637903a

Please sign in to comment.