1 /*
2 * Copyright (C) 2016 Alberto Irurueta Carro (alberto@irurueta.com)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.irurueta.numerical.polynomials.estimators;
17
18 /**
19 * Contains an evaluation of an interval of the nth-integral of a polynomial.
20 */
21 public class IntegralIntervalPolynomialEvaluation extends PolynomialEvaluation {
22
23 /**
24 * Minimum allowed integral order.
25 */
26 public static final int MIN_INTEGRAL_ORDER = 1;
27
28 /**
29 * Start point of interval being integrated.
30 */
31 private double startX;
32
33 /**
34 * End point of interval being integrated.
35 */
36 private double endX;
37
38 /**
39 * Order of integral.
40 */
41 private int integralOrder;
42
43 /**
44 * Constant terms of integral.
45 */
46 private double[] constants;
47
48 /**
49 * Constructor.
50 */
51 public IntegralIntervalPolynomialEvaluation() {
52 super();
53 setIntegralOrder(MIN_INTEGRAL_ORDER);
54 }
55
56 /**
57 * Constructor.
58 *
59 * @param startX start point of interval being integrated.
60 * @param endX end point of interval being integrated.
61 * @param evaluation evaluation of nth-integral of polynomial between startX
62 * and endX.
63 * @param integralOrder order of integral.
64 * @throws IllegalArgumentException if order of integral is less than 1.
65 */
66 public IntegralIntervalPolynomialEvaluation(
67 final double startX, final double endX, final double evaluation, final int integralOrder) {
68 super(evaluation);
69 this.startX = startX;
70 this.endX = endX;
71 setIntegralOrder(integralOrder);
72 }
73
74 /**
75 * Constructor.
76 *
77 * @param startX start point of interval being integrated.
78 * @param endX end point of interval being integrated.
79 * @param evaluation evaluation of nth-integral of polynomial between startX
80 * and endX.
81 */
82 public IntegralIntervalPolynomialEvaluation(final double startX, final double endX, final double evaluation) {
83 this(startX, endX, evaluation, MIN_INTEGRAL_ORDER);
84 }
85
86 /**
87 * Gets start point of interval being integrated.
88 *
89 * @return start point of interval being integrated.
90 */
91 public double getStartX() {
92 return startX;
93 }
94
95 /**
96 * Sets start point of interval being integrated.
97 *
98 * @param startX start point of interval being integrated.
99 */
100 public void setStartX(final double startX) {
101 this.startX = startX;
102 }
103
104 /**
105 * Gets end point of interval being integrated.
106 *
107 * @return end point of interval being integrated.
108 */
109 public double getEndX() {
110 return endX;
111 }
112
113 /**
114 * Sets end point of interval being integrated.
115 *
116 * @param endX end point of interval being integrated.
117 */
118 public void setEndX(final double endX) {
119 this.endX = endX;
120 }
121
122 /**
123 * Gets integral order.
124 *
125 * @return integral order.
126 */
127 public int getIntegralOrder() {
128 return integralOrder;
129 }
130
131 /**
132 * Sets integral order.
133 *
134 * @param integralOrder integral order.
135 * @throws IllegalArgumentException if integral order is less than 1.
136 */
137 public final void setIntegralOrder(final int integralOrder) {
138 if (integralOrder < MIN_INTEGRAL_ORDER) {
139 throw new IllegalArgumentException("integral order must be at least 1");
140 }
141
142 this.integralOrder = integralOrder;
143 }
144
145 /**
146 * Gets constant terms of integral.
147 *
148 * @return constant terms of integral.
149 */
150 public double[] getConstants() {
151 return constants;
152 }
153
154 /**
155 * Sets constant terms of integral.
156 *
157 * @param constants constant terms of integral.
158 */
159 public void setConstants(final double[] constants) {
160 this.constants = constants;
161 }
162
163 /**
164 * Gets type of polynomial evaluation.
165 *
166 * @return type of polynomial evaluation.
167 */
168 @Override
169 public PolynomialEvaluationType getType() {
170 return PolynomialEvaluationType.INTEGRAL_INTERVAL;
171 }
172 }