Fixed transposition.
This commit is contained in:
parent
cd2aeb4861
commit
4ea1dd92e6
|
@ -340,7 +340,7 @@ macro_rules! transpose_impl(
|
||||||
{
|
{
|
||||||
for iterate(1u, $dim) |i|
|
for iterate(1u, $dim) |i|
|
||||||
{
|
{
|
||||||
for iterate(0u, $dim - 1) |j|
|
for iterate(0u, i) |j|
|
||||||
{ self.swap((i, j), (j, i)) }
|
{ self.swap((i, j), (j, i)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,10 @@ use std::rand::random;
|
||||||
#[test]
|
#[test]
|
||||||
use std::cmp::ApproxEq;
|
use std::cmp::ApproxEq;
|
||||||
#[test]
|
#[test]
|
||||||
|
use traits::norm::Norm;
|
||||||
|
#[test]
|
||||||
|
use traits::scalar_op::ScalarMul;
|
||||||
|
#[test]
|
||||||
use traits::inv::Inv;
|
use traits::inv::Inv;
|
||||||
#[test]
|
#[test]
|
||||||
use traits::rotation::{Rotation, Rotatable};
|
use traits::rotation::{Rotation, Rotatable};
|
||||||
|
@ -13,7 +17,7 @@ use traits::indexable::Indexable;
|
||||||
#[test]
|
#[test]
|
||||||
use traits::transpose::Transpose;
|
use traits::transpose::Transpose;
|
||||||
#[test]
|
#[test]
|
||||||
use vec::Vec1;
|
use vec::{Vec1, Vec3};
|
||||||
#[test]
|
#[test]
|
||||||
use mat::{Mat1, Mat2, Mat3, Mat4, Mat5, Mat6};
|
use mat::{Mat1, Mat2, Mat3, Mat4, Mat5, Mat6};
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -30,6 +34,41 @@ macro_rules! test_inv_mat_impl(
|
||||||
);
|
);
|
||||||
)
|
)
|
||||||
|
|
||||||
|
macro_rules! test_transpose_mat_impl(
|
||||||
|
($t: ty) => (
|
||||||
|
for 10000.times
|
||||||
|
{
|
||||||
|
let randmat : $t = random();
|
||||||
|
|
||||||
|
assert!(randmat.transposed().transposed().eq(&randmat));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
)
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_transpose_mat1()
|
||||||
|
{ test_transpose_mat_impl!(Mat1<f64>); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_transpose_mat2()
|
||||||
|
{ test_transpose_mat_impl!(Mat2<f64>); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_transpose_mat3()
|
||||||
|
{ test_transpose_mat_impl!(Mat3<f64>); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_transpose_mat4()
|
||||||
|
{ test_transpose_mat_impl!(Mat4<f64>); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_transpose_mat5()
|
||||||
|
{ test_transpose_mat_impl!(Mat5<f64>); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_transpose_mat6()
|
||||||
|
{ test_transpose_mat_impl!(Mat6<f64>); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_inv_mat1()
|
fn test_inv_mat1()
|
||||||
{ test_inv_mat_impl!(Mat1<f64>); }
|
{ test_inv_mat_impl!(Mat1<f64>); }
|
||||||
|
@ -73,3 +112,17 @@ fn test_index_mat2()
|
||||||
|
|
||||||
assert!(mat.at((0, 1)) == mat.transposed().at((1, 0)));
|
assert!(mat.at((0, 1)) == mat.transposed().at((1, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_inv_rotation3()
|
||||||
|
{
|
||||||
|
for 10000.times
|
||||||
|
{
|
||||||
|
let randmat = One::one::<Rotmat<Mat3<f64>>>();
|
||||||
|
let dir: Vec3<f64> = random();
|
||||||
|
let ang = &dir.normalized().scalar_mul(&(abs::<f64>(random()) % Real::pi()));
|
||||||
|
let rot = randmat.rotated(ang);
|
||||||
|
|
||||||
|
assert!((rot.transposed() * rot).approx_eq(&One::one()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue