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