pub fn hadamard<T, U>(a: U, b: U) -> Uwhere
T: Float,
U: QuaternionOps<T>,
Expand description
Calculate the element-wise product of two quaternions (or vectors)
ยงExamples
// --- Vector3 --- //
let v1: Vector3<f64> = [1.0, 2.0, 3.0];
let v2: Vector3<f64> = [0.1, 0.2, 0.3];
let v_result = hadamard(v1, v2);
assert!( (0.1 - v_result[0]).abs() < 1e-12 );
assert!( (0.4 - v_result[1]).abs() < 1e-12 );
assert!( (0.9 - v_result[2]).abs() < 1e-12 );
// --- Quaternion --- //
let q1: Quaternion<f64> = (1.0, [2.0, 3.0, 4.0]);
let q2: Quaternion<f64> = (0.1, [0.2, 0.3, 0.4]);
let q_result = hadamard(q1, q2);
assert!( (0.1 - q_result.0).abs() < 1e-12 );
assert!( (0.4 - q_result.1[0]).abs() < 1e-12 );
assert!( (0.9 - q_result.1[1]).abs() < 1e-12 );
assert!( (1.6 - q_result.1[2]).abs() < 1e-12 );