## 2 Fast Sweep with Segmentation and Spline Interpolation  
To perform the fast sweep, we use an electromagnetic solver to compute the multimodal circuital matrix of each building block in a reduced number of frequency points. Let \(S_{ij}^{(n,m)}\) be the scattering parameter of a given building block that relates the \(m\)th mode accessing the building block by the \(j\)th access port and the \(n\)th mode exiting by the \(i\)th access port. Let \(f_{p}\) with \(p\in[1,\cdots,P]\) be the frequency points where the electromagnetic solver is used to accurately compute the scattering parameters of each building block.  
Therefore, the value of \(S_{ij}^{(n,m)}(f_{p})\) is known in \(P\) points along the operational frequency band. \(S_{ij}^{(n,m)}\) is not a very complex function since it characterizes a simple building block. Now, the problem is to accurately interpolate this function and estimate its value in any point inside the frequency band. In this work, we have chosen the cubic spline in order to perform the interpolation.  
In mathematics, a spline [21] is a special function defined piecewise by polynomials. To per form the interpolation, splines are preferred to the use of a single polynomial for all the domain because they yield similar results when using low degrees, and they avoid the [PERSON]'s phenomenon of oscillationsat the edges that happens with polynomials for high degrees. Another advantages of splines are the ease of representation and computation.  
Among all splines, the cubic spline [22] is the most frequently used due to the optimum compromise between accuracy and simplicity, so this is the choice adopted in this work. Let \(\hat{S}_{ij}^{(n,m)}(f)\) be the spline function that interpolates and approximates \(S_{ij}^{(n,m)}\). Therefore, \(\hat{S}_{ij}^{(n,m)}(f)\) is defined as a different cubic polynomial in each interval \([f_{1},f_{2}],[f_{2},f_{3}],\ldots,[f_{P-1},f_{P}]\). Let \(A_{i,i+  
Two more equations are still needed to determine the \(P\) unknowns. In the case of _natural_ splines, the choice is to enforce that the second derivative at the extremes of the interpolation domain be zero, that is  
\[A^{\prime\prime}_{1,2}(f_{1}) = 0 \tag{11}\] \[A^{\prime\prime}_{P-1,P}(fp) = 0 \tag{12}\]  
which gives the following two equations  
\[\frac{2k_{1}}{f_{2}-f_{1}}+\frac{k_{2}}{(f_{2}-f_{1})^{2}} = \frac{3(y_{2}-y_{1})}{(f_{2}-f_{1})^{2}}\] \[\frac{k_{P-1}}{(fp-f_{P-1})^{2}}+\frac{2k_{P}}{f_{P}-f_{P-1}} = \frac{3(y_{p}-y_{P-1})}{(f_{P}-f_{P-1})^{2}} \tag{13}\]  
The \(P-2\) equations of Equation (10) and the two equations of Equation (13) constitute a linear system of \(P\) equations with \(P\) unknowns. The solution of this system are the coefficients \(k_{i}\) (\(i\in[1,\cdots,P]\)). With those coefficients, all the cubic polynomials \(A_{i,i+1}(f)\) are completely determined, and the approximation \(\delta_{ij}^{(n,m)}(f)\) of the element \(S_{ij}^{(n,m)}(f)\) of the generalized scattering parameter, as defined in Equation (1), is accomplished using only the information of \(P\) discrete frequency points.  
The number of discrete points \(P\) used to approximate the response of each building block depends on the complexity of the block. As shown in Section 5, even with complex building blocks, such as a resonant post, it is enough to use only five points (\(P=5\)). With simpler building blocks, \(P\) can be even smaller. This small number of points is possible even for long and complex devices, such as coupled cavities filters with many resonant cavities, thanks to the segmentation into simple building blocks and the approximation with splines of the individual response of each block, instead of approximating the response of the whole device.