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.algebra.WrongSizeException;
19
20 /**
21 * Computes function integration by using Simpson's rule and infinity mid-point quadrature.
22 * This type of integrator will in general be more efficient than Trapezoidal quadrature
23 * integrators (i.e., require fewer function evaluations) when the function
24 * to be integrated has a finite fourth derivative (i.e., a continuous third derivative).
25 * If you need to integrate from a negative lower limit to positive infinity, you do this by
26 * breaking the integral into two pieces at some positive value:
27 * SimpsonInfinityMidPointQuadratureMatrixIntegrator integrator1 =
28 * new SimpsonInfinityMidPointQuadratureMatrixIntegrator(-5.0, 2.0, listener);
29 * SimpsonInfinityMidPointQuadratureMatrixIntegrator integrator2 =
30 * new SimpsonInfinityMidPointQuadratureMatrixIntegrator(2.0, 1e99, listener);
31 * double integral = integrator1.integrate() + integrator2.integrate();
32 */
33 public class SimpsonInfinityMidPointQuadratureMatrixIntegrator
34 extends SimpsonMatrixIntegrator<InfinityMidPointMatrixQuadrature> {
35
36 /**
37 * Constructor.
38 *
39 * @param a Lower limit of integration.
40 * @param b Upper limit of integration.
41 * @param listener listener to evaluate a single dimension matrix (multivariate) function at
42 * required points.
43 * @param eps required accuracy.
44 * @throws WrongSizeException if size notified by provided listener is invalid.
45 */
46 public SimpsonInfinityMidPointQuadratureMatrixIntegrator(
47 final double a, final double b, final MatrixSingleDimensionFunctionEvaluatorListener listener,
48 final double eps) throws WrongSizeException {
49 super(new InfinityMidPointMatrixQuadrature(a, b, listener), eps);
50 }
51
52 /**
53 * Constructor with default accuracy.
54 *
55 * @param a Lower limit of integration.
56 * @param b Upper limit of integration.
57 * @param listener listener to evaluate a single dimension function at required points.
58 * @throws WrongSizeException if size notified by provided listener is invalid.
59 */
60 public SimpsonInfinityMidPointQuadratureMatrixIntegrator(
61 final double a, final double b, final MatrixSingleDimensionFunctionEvaluatorListener listener)
62 throws WrongSizeException {
63 this(a, b, listener, EPS);
64 }
65
66 /**
67 * Gets type of quadrature.
68 *
69 * @return type of quadrature.
70 */
71 @Override
72 public QuadratureType getQuadratureType() {
73 return QuadratureType.INFINITY_MID_POINT;
74 }
75 }