1 // ==========================================================================
2 //                 SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2018, Knut Reinert, FU Berlin
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 //     * Redistributions of source code must retain the above copyright
11 //       notice, this list of conditions and the following disclaimer.
12 //     * Redistributions in binary form must reproduce the above copyright
13 //       notice, this list of conditions and the following disclaimer in the
14 //       documentation and/or other materials provided with the distribution.
15 //     * Neither the name of Knut Reinert or the FU Berlin nor the names of
16 //       its contributors may be used to endorse or promote products derived
17 //       from this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
23 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 //
31 // ==========================================================================
32 
33 #ifndef TESTS_ALIGN_TEST_ALIGN_MATRIX_H_
34 #define TESTS_ALIGN_TEST_ALIGN_MATRIX_H_
35 
SEQAN_DEFINE_TEST(test_align_matrix)36 SEQAN_DEFINE_TEST(test_align_matrix)
37 {
38     using namespace std;
39     using namespace seqan;
40 
41     // Resize the matrix.
42     Matrix<double,2> matrix1;
43 
44     setLength(matrix1, 0, 2);
45     setLength(matrix1, 1, 2);
46     resize(matrix1);
47     value(matrix1,0,0) = 3.0;
48     value(matrix1,0,1) = 3.5;
49     value(matrix1,1,0) = 14.5;
50     value(matrix1,1,1) = -6.0;
51 
52     Matrix<double,2> matrix2;
53 
54     setLength(matrix2, 0, 2);
55     setLength(matrix2, 1, 2);
56     resize(matrix2,1.0);
57 
58     // Basic 2D operations, A+B,A-B,A*a,A*B, A==B
59 
60     Matrix<double,2> matrix3;
61 
62     matrix3 = matrix1 + matrix2;
63     SEQAN_ASSERT_EQ(value(matrix3,0,0), value(matrix1,0,0) + value(matrix2,0,0));
64     SEQAN_ASSERT_EQ(value(matrix3,0,1), value(matrix1,0,1) + value(matrix2,0,1));
65     SEQAN_ASSERT_EQ(value(matrix3,1,0), value(matrix1,1,0) + value(matrix2,1,0));
66     SEQAN_ASSERT_EQ(value(matrix3,1,1), value(matrix1,1,1) + value(matrix2,1,1));
67     SEQAN_ASSERT_EQ(matrix1 + matrix2, matrix2 + matrix1);
68     matrix3 = matrix1 - matrix2;
69     SEQAN_ASSERT_EQ(value(matrix3,0,0), value(matrix1,0,0) - value(matrix2,0,0));
70     SEQAN_ASSERT_EQ(value(matrix3,0,1), value(matrix1,0,1) - value(matrix2,0,1));
71     SEQAN_ASSERT_EQ(value(matrix3,1,0), value(matrix1,1,0) - value(matrix2,1,0));
72     SEQAN_ASSERT_EQ(value(matrix3,1,1), value(matrix1,1,1) - value(matrix2,1,1));
73 
74     SEQAN_ASSERT_EQ(matrix1-matrix2, matrix1+(matrix2*(-1.0)));
75     matrix3=matrix1*matrix2;
76     matrix3=matrix1*5.0;
77     SEQAN_ASSERT_EQ(matrix1 * 5.0, 5.0 * matrix1);
78 
79     // n-dimensional matrix
80     Matrix<double> matrixN;
81     setDimension(matrixN,2);
82     setLength(matrix2, 0, 3);
83     setLength(matrix2, 1, 2);
84     resize(matrixN,1.0);
85 }
86 
87 #endif  // TESTS_ALIGN_TEST_ALIGN_MATRIX_H_
88