1- using static MathCore . Polynom . Array ;
2-
3- namespace MathCore . DSP . Filters ;
1+ namespace MathCore . DSP . Filters ;
42
53public static partial class FilterEx
64{
@@ -117,7 +115,7 @@ public FixedPointIirSosCoefficients(FixedPointSosSection[] Sections, int BitDept
117115 /// <exception cref="NotSupportedException">Если фильтр не является <see cref="IIR"/></exception>
118116 public static FixedPointIirCoefficients ExportToFixedPoint ( this Filter Filter , int BitDepth = 16 , int ? FractionalBits = null )
119117 {
120- if ( Filter is null ) throw new ArgumentNullException ( nameof ( Filter ) ) ;
118+ ArgumentNullException . ThrowIfNull ( Filter ) ;
121119
122120 return Filter is IIR iir
123121 ? iir . ExportToFixedPoint ( BitDepth , FractionalBits )
@@ -132,7 +130,7 @@ public static FixedPointIirCoefficients ExportToFixedPoint(this Filter Filter, i
132130 /// <exception cref="ArgumentNullException">Если <paramref name="Filter"/> равен <see langword="null"/></exception>
133131 public static FixedPointIirCoefficients ExportToFixedPoint ( this IIR Filter , int BitDepth = 16 , int ? FractionalBits = null )
134132 {
135- if ( Filter is null ) throw new ArgumentNullException ( nameof ( Filter ) ) ;
133+ ArgumentNullException . ThrowIfNull ( Filter ) ;
136134
137135 ValidateBitDepth ( BitDepth ) ;
138136
@@ -157,7 +155,7 @@ public static FixedPointIirCoefficients ExportToFixedPoint(this IIR Filter, int
157155 /// <exception cref="NotSupportedException">Если фильтр не является <see cref="IIR"/></exception>
158156 public static FixedPointIirSosCoefficients ExportToFixedPointSos ( this Filter Filter , int BitDepth = 16 , int ? FractionalBits = null )
159157 {
160- if ( Filter is null ) throw new ArgumentNullException ( nameof ( Filter ) ) ;
158+ ArgumentNullException . ThrowIfNull ( Filter ) ;
161159
162160 return Filter is IIR iir
163161 ? iir . ExportToFixedPointSos ( BitDepth , FractionalBits )
@@ -173,7 +171,7 @@ public static FixedPointIirSosCoefficients ExportToFixedPointSos(this Filter Fil
173171 /// <exception cref="InvalidOperationException">Если не удалось выполнить секционное разложение фильтра</exception>
174172 public static FixedPointIirSosCoefficients ExportToFixedPointSos ( this IIR Filter , int BitDepth = 16 , int ? FractionalBits = null )
175173 {
176- if ( Filter is null ) throw new ArgumentNullException ( nameof ( Filter ) ) ;
174+ ArgumentNullException . ThrowIfNull ( Filter ) ;
177175
178176 ValidateBitDepth ( BitDepth ) ;
179177
@@ -222,8 +220,8 @@ public double PoleRadius
222220
223221 private static ( double [ ] B , double [ ] A ) Normalize ( IReadOnlyList < double > B , IReadOnlyList < double > A )
224222 {
225- if ( B is null ) throw new ArgumentNullException ( nameof ( B ) ) ;
226- if ( A is null ) throw new ArgumentNullException ( nameof ( A ) ) ;
223+ ArgumentNullException . ThrowIfNull ( B ) ;
224+ ArgumentNullException . ThrowIfNull ( A ) ;
227225 if ( B . Count == 0 ) throw new ArgumentException ( "Размер массива коэффициентов числителя должен быть больше 0" , nameof ( B ) ) ;
228226 if ( A . Count < 2 ) throw new ArgumentException ( "Размер массива коэффициентов знаменателя должен быть больше 1" , nameof ( A ) ) ;
229227
@@ -242,8 +240,8 @@ private static (double[] B, double[] A) Normalize(IReadOnlyList<double> B, IRead
242240
243241 private static void EnsureFinite ( IEnumerable < double > Values , string ParamName )
244242 {
245- if ( Values is null ) throw new ArgumentNullException ( nameof ( Values ) ) ;
246- if ( ParamName is null ) throw new ArgumentNullException ( nameof ( ParamName ) ) ;
243+ ArgumentNullException . ThrowIfNull ( Values ) ;
244+ ArgumentNullException . ThrowIfNull ( ParamName ) ;
247245
248246 foreach ( var value in Values )
249247 if ( ! IsFinite ( value ) )
@@ -254,13 +252,13 @@ private static void EnsureFinite(IEnumerable<double> Values, string ParamName)
254252
255253 private static void ValidateBitDepth ( int BitDepth )
256254 {
257- if ( BitDepth < 2 || BitDepth > 62 )
255+ if ( BitDepth is < 2 or > 62 )
258256 throw new ArgumentOutOfRangeException ( nameof ( BitDepth ) , BitDepth , "Разрядность коэффициентов должна находиться в диапазоне от 2 до 62 бит" ) ;
259257 }
260258
261259 private static int ResolveFractionalBits ( IReadOnlyList < double > Coefficients , int BitDepth , int ? FractionalBits )
262260 {
263- if ( Coefficients is null ) throw new ArgumentNullException ( nameof ( Coefficients ) ) ;
261+ ArgumentNullException . ThrowIfNull ( Coefficients ) ;
264262
265263 if ( FractionalBits is { } explicit_fractional_bits )
266264 {
@@ -399,7 +397,7 @@ private static SosSection[] BuildSos(double[] A, double[] B)
399397
400398 private static Complex [ ] GetRoots ( double [ ] Coefficients )
401399 {
402- if ( Coefficients is null ) throw new ArgumentNullException ( nameof ( Coefficients ) ) ;
400+ ArgumentNullException . ThrowIfNull ( Coefficients ) ;
403401
404402 var n = Coefficients . Length - 1 ;
405403 while ( n > 0 && Math . Abs ( Coefficients [ n ] ) < 1e-18 )
@@ -528,7 +526,7 @@ private static double[][] BuildSectionsFromRoots(Complex[] Roots)
528526
529527 private static void DistributeGain ( SosSection [ ] Sections , ref double Gain )
530528 {
531- if ( Sections is null ) throw new ArgumentNullException ( nameof ( Sections ) ) ;
529+ ArgumentNullException . ThrowIfNull ( Sections ) ;
532530 if ( Sections . Length == 0 || Gain == 0 || double . IsNaN ( Gain ) || double . IsInfinity ( Gain ) )
533531 return ;
534532
0 commit comments