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 an infinity mid-point quadrature.
22 * If you need to integrate from a negative lower limit to positive infinity, you do this by
23 * breaking the integral into two pieces at some positive value:
24 * InfinityMidPointQuadratureIntegrator integrator1 =
25 * new InfinityMidPointQuadratureIntegrator(-5.0, 2.0, listener);
26 * InfinityMidPointQuadratureIntegrator integrator2 =
27 * new InfinityMidPointQuadratureIntegrator(2.0, 1e99, listener);
28 * double integral = integrator1.integrate() + integrator2.integrate();
29 */
30 public class InfinityMidPointQuadratureIntegrator extends QuadratureIntegrator<InfinityMidPointQuadrature> {
31
32 /**
33 * Constructor.
34 *
35 * @param a Lower limit of integration.
36 * @param b Upper limit of integration.
37 * @param listener listener to evaluate a single dimension function at required points.
38 * @param eps required accuracy.
39 */
40 public InfinityMidPointQuadratureIntegrator(
41 final double a, final double b, final SingleDimensionFunctionEvaluatorListener listener, final double eps) {
42 super(new InfinityMidPointQuadrature(a, b, listener), eps);
43 }
44
45 /**
46 * Constructor.
47 *
48 * @param a Lower limit of integration.
49 * @param b Upper limit of integration.
50 * @param listener listener to evaluate a single dimension function at required points.
51 */
52 public InfinityMidPointQuadratureIntegrator(
53 final double a, final double b, final SingleDimensionFunctionEvaluatorListener listener) {
54 this(a, b, listener, EPS);
55 }
56
57 /**
58 * Gets type of quadrature.
59 *
60 * @return type of quadrature.
61 */
62 @Override
63 public QuadratureType getQuadratureType() {
64 return QuadratureType.INFINITY_MID_POINT;
65 }
66 }