From b0e3574e370644b2b768bbaa3c8078dbadbf7f07 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 21 Dec 2008 23:22:45 -0800 Subject: [PATCH] Move HERMITIAN test to MatrixComplex.t --- t/Matrix.t | 27 ++++----------------------- t/MatrixComplex.t | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/t/Matrix.t b/t/Matrix.t index 04984fb..dcd9765 100644 --- a/t/Matrix.t +++ b/t/Matrix.t @@ -1,6 +1,8 @@ package Math::GSL::Matrix::Test; +use Test::More tests => 225; use base q{Test::Class}; -use Test::More tests => 226; +use strict; + use Math::GSL qw/:all/; use Math::GSL::Test qw/:all/; use Math::GSL::Matrix qw/:all/; @@ -8,9 +10,8 @@ use Math::GSL::Vector qw/:all/; use Math::GSL::Complex qw/:all/; use Math::GSL::Errno qw/:all/; use Test::Exception; -use Data::Dumper; use Math::Complex; -use strict; +use Data::Dumper; BEGIN{ gsl_set_error_handler_off(); } @@ -511,26 +512,6 @@ sub NEW_SETS_VALUES_TO_ZERO : Tests { ok( $sum == 0, 'new sets values to zero'); } -sub HERMITIAN : Tests { - my $matrix = gsl_matrix_complex_alloc(2,2); - my $transpose = gsl_matrix_complex_alloc(2,2); - gsl_matrix_complex_set($matrix, 0, 0, gsl_complex_rect(3,0)); - gsl_matrix_complex_set($matrix, 0, 1, gsl_complex_rect(2,1)); - gsl_matrix_complex_set($matrix, 1, 0, gsl_complex_rect(2,-1)); - gsl_matrix_complex_set($matrix, 1, 1, gsl_complex_rect(1,0)); - gsl_matrix_complex_memcpy($transpose, $matrix); - gsl_matrix_complex_transpose($transpose); - - for my $row (0..1) { - map { gsl_matrix_complex_set($transpose, $row, $_, gsl_complex_conjugate(gsl_matrix_complex_get($transpose, $row, $_))) } (0..1); - } - - my $upper_right = gsl_matrix_complex_get($matrix, 0, 1 ); - my $lower_left = gsl_matrix_complex_get($matrix, 1, 0 ); - - ok( gsl_complex_eq( gsl_complex_conjugate($upper_right), $lower_left ), 'hermitian' ); -} - sub SET_ROW : Tests { my $m = Math::GSL::Matrix->new(3,3); $m->set_row(0, [1,2,3]); diff --git a/t/MatrixComplex.t b/t/MatrixComplex.t index 0c874fa..e513dbd 100755 --- a/t/MatrixComplex.t +++ b/t/MatrixComplex.t @@ -1,6 +1,8 @@ package Math::GSL::MatrixComplex::Test; +use Test::More tests => 13; use base q{Test::Class}; -use Test::More tests => 12; +use strict; + use Math::GSL qw/:all/; use Math::GSL::Test qw/:all/; use Math::GSL::Errno qw/:all/; @@ -8,7 +10,6 @@ use Math::GSL::MatrixComplex qw/:all/; use Math::GSL::Complex qw/:all/; use Math::Complex; use Data::Dumper; -use strict; BEGIN{ gsl_set_error_handler_off(); } @@ -55,4 +56,24 @@ sub GSL_MATRIX_COMPLEX_SET_OO : Tests(2) { ok_similar( [ map { Im $_ } $u->as_list ], [ 7, 2, 3, 0 ] ); } +sub HERMITIAN : Tests(1) { + my $matrix = gsl_matrix_complex_alloc(2,2); + my $transpose = gsl_matrix_complex_alloc(2,2); + gsl_matrix_complex_set($matrix, 0, 0, gsl_complex_rect(3,0)); + gsl_matrix_complex_set($matrix, 0, 1, gsl_complex_rect(2,1)); + gsl_matrix_complex_set($matrix, 1, 0, gsl_complex_rect(2,-1)); + gsl_matrix_complex_set($matrix, 1, 1, gsl_complex_rect(1,0)); + gsl_matrix_complex_memcpy($transpose, $matrix); + gsl_matrix_complex_transpose($transpose); + + for my $row (0..1) { + map { gsl_matrix_complex_set($transpose, $row, $_, gsl_complex_conjugate(gsl_matrix_complex_get($transpose, $row, $_))) } (0..1); + } + + my $upper_right = gsl_matrix_complex_get($matrix, 0, 1 ); + my $lower_left = gsl_matrix_complex_get($matrix, 1, 0 ); + + ok( gsl_complex_eq( gsl_complex_conjugate($upper_right), $lower_left ), 'hermitian' ); +} + Test::Class->runtests; -- 2.11.4.GIT