1 /*
2 * Copyright (C) 2023 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.integration;
17
18 import com.irurueta.numerical.SingleDimensionFunctionEvaluatorListener;
19
20 /**
21 * Computes function integration by using Mid-Point quadrature up to desired accuracy.
22 */
23 public class MidPointQuadratureIntegrator extends QuadratureIntegrator<MidPointQuadrature> {
24
25 /**
26 * Constructor.
27 *
28 * @param a Lower limit of integration.
29 * @param b Upper limit of integration.
30 * @param listener listener to evaluate a single dimension function at required points.
31 * @param eps required accuracy.
32 */
33 public MidPointQuadratureIntegrator(
34 final double a, final double b, final SingleDimensionFunctionEvaluatorListener listener, final double eps) {
35 super(new MidPointQuadrature(a, b, listener), eps);
36 }
37
38 /**
39 * Constructor with default accuracy.
40 *
41 * @param a Lower limit of integration.
42 * @param b Upper limit of integration.
43 * @param listener listener to evaluate a single dimension function at required points.
44 */
45 public MidPointQuadratureIntegrator(
46 final double a, final double b, final SingleDimensionFunctionEvaluatorListener listener) {
47 this(a, b, listener, EPS);
48 }
49
50 /**
51 * Gets type of quadrature.
52 *
53 * @return type of quadrature.
54 */
55 @Override
56 public QuadratureType getQuadratureType() {
57 return QuadratureType.MID_POINT;
58 }
59 }