Refactor inclusion of system.i to one place
[Math-GSL.git] / t / CBLAS.t
blob0ff70b47e66e5f8cf1480b4c8dcdcbe4802bc0d4
1 package Math::GSL::CBLAS::Test;
2 use base q{Test::Class};
3 use Test::More tests => 5;
4 use Math::GSL::Test  qw/:all/;
5 use Math::GSL::CBLAS qw/:all/;
6 use Math::GSL        qw/:all/;
7 use Math::GSL::Errno qw/:all/;
8 use Data::Dumper;
9 use strict;
11 BEGIN{ gsl_set_error_handler_off() }
13 sub make_fixture : Test(setup) {
16 sub teardown : Test(teardown) {
19 sub TEST_CBLAS : Tests {
20        local $TODO = "need to figure out how to reture more that just first element";
22        my $A = [ 0.11, 0.12, 0.13,
23                   0.21, 0.22, 0.23 ];
24        my $lda = 3;
25        my $B   = [ 1011, 1012,
26                    1021, 1022,
27                    1031, 1032 ];
28        my $ldb = 2;
29        my $C    = [0.00, 0.00,
30                   0.00, 0.00 ];
31        my $ldc = 2.0;
33        # Compute C = A * B 
34        # C  = [ 367.76 368.12 ]
35         #     [ 674.06 674.72 ]
36        my @stuff = cblas_sgemm ($CblasRowMajor,
37                     $CblasNoTrans, $CblasNoTrans, 2, 2, 3,
38                     1.0, $A, $lda, $B, $ldb, 0.0, $ldc);
39        #warn Dumper [ @stuff ];
40        ok(is_similar_relative( \@stuff, [ 367.76, 368.12 , 674.06, 674.72 ], '.01' ),'cblas_sgemm');
43 sub CBLAS_IDAMAX : Tests {
44    my $N = 1;
45    my $X = 0.247;
46    my $incX = -1;
47    my $expected = 0;
48    my $k;
49    $k = cblas_idamax($N, $X, $incX);
50    is($k, $expected);
53 sub CBLAS_ISAMAX : Tests {
54    my $N = 1;
55    my $X = -0.388;
56    my $incX = -1;
57    my $expected = 0;
58    my $k = cblas_isamax($N, $X, $incX);
59    is($k, $expected);
62 sub CBLAS_SASUM : Tests  {
63    my $N = 1;
64    my $X = 0.239;
65    my $incX = -1;
66    my $expected = 0.0; 
67    my $f = cblas_sasum($N, $X, $incX);
68    is($f, $expected);
72 sub CBLAS_DASUM : Tests {
73  my $N = 1;
74  my $X = -0.413;
75  my $incX = -1;
76  my $expected = 0; 
77  my $f = cblas_dasum($N, $X, $incX);
78  is($f, $expected);
81 Test::Class->runtests;