View Javadoc
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 double exponential quadrature.
22   * Double exponential quadrature allows improper integrands containing singularities to be
23   * integrated.
24   *
25   * @see DoubleExponentialRuleMatrixQuadrature
26   */
27  public class RombergDoubleExponentialRuleQuadratureMatrixIntegrator
28          extends RombergMatrixIntegrator<DoubleExponentialRuleMatrixQuadrature> {
29  
30     /**
31      * Constructor.
32      *
33      * @param a        Lower limit of integration.
34      * @param b        Upper limit of integration.
35      * @param hmax     Maximum step size. This quadrature transforms the range of integration to
36      *                 [-hmax, hmax].
37      * @param listener listener to evaluate a single dimension matrix (multivariate) function at
38      *                 required points.
39      * @param eps      required accuracy.
40      * @throws WrongSizeException if size notified by provided listener is invalid.
41      */
42     public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
43             final double a, final double b, final double hmax,
44             final MatrixSingleDimensionFunctionEvaluatorListener listener, final double eps) throws WrongSizeException {
45        super(new DoubleExponentialRuleMatrixQuadrature(listener, a, b, hmax), eps);
46     }
47  
48     /**
49      * Constructor.
50      *
51      * @param a        Lower limit of integration.
52      * @param b        Upper limit of integration.
53      * @param listener listener to evaluate a single dimension matrix (multivariate) function at
54      *                 required points.
55      * @param eps      required accuracy.
56      * @throws WrongSizeException if size notified by provided listener is invalid.
57      */
58     public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
59             final double a, final double b, final MatrixSingleDimensionFunctionEvaluatorListener listener,
60             final double eps) throws WrongSizeException {
61        super(new DoubleExponentialRuleMatrixQuadrature(listener, a, b), eps);
62     }
63  
64     /**
65      * Constructor with default accuracy.
66      *
67      * @param a        Lower limit of integration.
68      * @param b        Upper limit of integration.
69      * @param listener listener to evaluate a single dimension matrix (multivariate) function at
70      *                 required points.
71      * @param hmax     Maximum step size. This quadrature transforms the range of integration to
72      *                 [-hmax, hmax].
73      * @throws WrongSizeException if size notified by provided listener is invalid.
74      */
75     public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
76             final double a, final double b, final double hmax,
77             final MatrixSingleDimensionFunctionEvaluatorListener listener) throws WrongSizeException {
78        this(a, b, hmax, listener, EPS);
79     }
80  
81     /**
82      * Constructor with default accuracy and default maximum step size.
83      *
84      * @param a        Lower limit of integration.
85      * @param b        Upper limit of integration.
86      * @param listener listener to evaluate a single dimension matrix (multivariate) function at
87      *                 required points.
88      * @throws WrongSizeException if size notified by provided listener is invalid.
89      */
90     public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
91             final double a, final double b, final MatrixSingleDimensionFunctionEvaluatorListener listener)
92             throws WrongSizeException {
93        this(a, b, listener, EPS);
94     }
95  
96     /**
97      * Constructor.
98      *
99      * @param a        Lower limit of integration.
100     * @param b        Upper limit of integration.
101     * @param hmax     Maximum step size. This quadrature transforms the range of integration to
102     *                 [-hmax, hmax].
103     * @param listener listener to evaluate a single dimension matrix (multivariate) function at
104     *                 required points.
105     * @param eps      required accuracy.
106     * @throws WrongSizeException if size notified by provided listener is invalid.
107     */
108    public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
109            final double a, final double b, final double hmax,
110            final DoubleExponentialMatrixSingleDimensionFunctionEvaluatorListener listener, final double eps)
111            throws WrongSizeException {
112       super(new DoubleExponentialRuleMatrixQuadrature(listener, a, b, hmax), eps);
113    }
114 
115    /**
116     * Constructor.
117     *
118     * @param a        Lower limit of integration.
119     * @param b        Upper limit of integration.
120     * @param listener listener to evaluate a single dimension matrix (multivariate) function at
121     *                 required points.
122     * @param eps      required accuracy.
123     * @throws WrongSizeException if size notified by provided listener is invalid.
124     */
125    public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
126            final double a, final double b,
127            final DoubleExponentialMatrixSingleDimensionFunctionEvaluatorListener listener, final double eps)
128            throws WrongSizeException {
129       super(new DoubleExponentialRuleMatrixQuadrature(listener, a, b), eps);
130    }
131 
132    /**
133     * Constructor with default accuracy.
134     *
135     * @param a        Lower limit of integration.
136     * @param b        Upper limit of integration.
137     * @param listener listener to evaluate a single dimension matrix (multivariate) function at
138     *                 required points.
139     * @param hmax     Maximum step size. This quadrature transforms the range of integration to
140     *                 [-hmax, hmax].
141     * @throws WrongSizeException if size notified by provided listener is invalid.
142     */
143    public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
144            final double a, final double b, final double hmax,
145            final DoubleExponentialMatrixSingleDimensionFunctionEvaluatorListener listener) throws WrongSizeException {
146       this(a, b, hmax, listener, EPS);
147    }
148 
149    /**
150     * Constructor with default accuracy and default maximum step size.
151     *
152     * @param a        Lower limit of integration.
153     * @param b        Upper limit of integration.
154     * @param listener listener to evaluate a single dimension matrix (multivariate) function at
155     *                 required points.
156     * @throws WrongSizeException if size notified by provided listener is invalid.
157     */
158    public RombergDoubleExponentialRuleQuadratureMatrixIntegrator(
159            final double a, final double b,
160            final DoubleExponentialMatrixSingleDimensionFunctionEvaluatorListener listener) throws WrongSizeException {
161       this(a, b, listener, EPS);
162    }
163 
164    /**
165     * Gets type of quadrature.
166     *
167     * @return type of quadrature.
168     */
169    @Override
170    public QuadratureType getQuadratureType() {
171       return QuadratureType.DOUBLE_EXPONENTIAL_RULE;
172    }
173 }