01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package test.org.mandarax.lib.math;
19:
20: import org.mandarax.kernel.Fact;
21: import org.mandarax.lib.math.DoubleArithmetic;
22:
23: /**
24: * Test case for double arithmetic.<br>
25: * <em>tested predicate(s): </em>DoubleArithmetic.EQUAL<br>
26: * <em>tested function(s): </em>DoubleArithmetic.PLUS,DoubleArithmetic.TIMES,DoubleArithmetic.SQRT<br>
27: * Note that we compute numbers satisfying the theorem of pythagoras!
28: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
29: * @version 3.4 <7 March 05>
30: * @since 1.6
31: */
32: public class DoubleArithmeticTest13 extends DoubleArithmeticTest {
33:
34: /**
35: * Constructor.
36: */
37: public DoubleArithmeticTest13() {
38: super ();
39: }
40:
41: /**
42: * Get the expected number of generated facts.
43: * @return the number of facts expected
44: */
45: protected int getExpected() {
46:
47: // pythag. numbers are 3,4,5 (4,3,5) and 6,8,10 (8,6,10)
48: return 4;
49: }
50:
51: /**
52: * Get the query fact.
53: * @return a query fact.
54: */
55: protected Fact getQueryFact() {
56:
57: // this is basically the theorem of pythagoras
58: return buildFact(DoubleArithmetic.EQUAL, "x", buildComplexTerm(
59: DoubleArithmetic.SQRT, buildComplexTerm(
60: DoubleArithmetic.PLUS, buildComplexTerm(
61: DoubleArithmetic.TIMES, "y", "y"),
62: buildComplexTerm(DoubleArithmetic.TIMES, "z",
63: "z"))));
64: }
65:
66: /**
67: * Get the set of numbers used for testing.
68: * @return an array of doubles
69: */
70: protected double[] getTestSet() {
71: double[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
72:
73: return array;
74: }
75: }
|