File: SimpleUnitTests.java

package info (click to toggle)
libejml-java 0.41%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 7,376 kB
  • sloc: java: 82,734; python: 81; makefile: 22
file content (95 lines) | stat: -rw-r--r-- 2,860 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * Copyright (c) 2009-2017, Peter Abeles. All Rights Reserved.
 *
 * This file is part of Efficient Java Matrix Library (EJML).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.ejml.simple;

import org.ejml.EjmlUnitTests;
import org.ejml.data.DMatrixRMaj;

/**
 * Unit testing functions for {@link SimpleMatrix}
 *
 * @author Peter Abeles
 */
public class SimpleUnitTests {
    /**
     * Checks to see if every element in A is countable.  A doesn't have any element with
     * a value of NaN or infinite.
     *
     * @param A Matrix
     */
    public static void assertCountable( SimpleMatrix A ) {
        EjmlUnitTests.assertCountable((DMatrixRMaj)A.getMatrix());
    }

    /**
     * <p>
     * Checks to see if A and B have the same shape.
     * </p>
     *
     * @param A Matrix
     * @param B Matrix
     */
    public static void assertShape( SimpleMatrix A , SimpleMatrix B ) {
        EjmlUnitTests.assertShape(A.getMatrix(), B.getMatrix());
    }

    /**
     * <p>
     * Checks to see if each element in the matrix is within tolerance of each other:
     * </p>
     *
     * <p>
     * The two matrices are identical with in tolerance if:<br>
     * |a<sub>ij</sub> - b<sub>ij</sub>| &le; tol
     * </p>
     *
     * <p>
     * In addition if an element is NaN or infinite in one matrix it must be the same in the other.
     * </p>
     *
     * @param A Matrix A
     * @param B Matrix B
     * @param tol Tolerance
     */
    public static void assertEqualsUncountable( SimpleMatrix A , SimpleMatrix B , double tol ) {
        EjmlUnitTests.assertEqualsUncountable((DMatrixRMaj)A.getMatrix(), (DMatrixRMaj)B.getMatrix(), tol);
    }

    /**
     * <p>
     * Checks to see if each element in the matrices are within tolerance of each other and countable:
     * </p>
     *
     * <p>
     * The two matrices are identical with in tolerance if:<br>
     * |a<sub>ij</sub> - b<sub>ij</sub>| &le; tol
     * </p>
     *
     * <p>
     * The test will fail if any element in either matrix is NaN or infinite.
     * </p>
     *
     * @param A Matrix A
     * @param B Matrix B
     * @param tol Tolerance
     */
    public static void assertEquals( SimpleMatrix A , SimpleMatrix B , double tol ) {
        EjmlUnitTests.assertEquals((DMatrixRMaj)A.getMatrix(), (DMatrixRMaj)B.getMatrix(), tol);
    }
}