//! Butterworth filters: pre-calculated Second Order Sections coefficients for order 6 lowpass filters.
//! This file is autogenerated.
use crate::sos::SisoSosFilter;
use core::ops::Neg;
use num_traits::{FromPrimitive, MulAdd, Num, ToPrimitive};
pub const NUM_SECTIONS: usize = 3;
const NUM_INTERP_POINTS: usize = 100;
pub const MIN_CUTOFF_RATIO_F32: f64 = 0.01;
pub const MAX_CUTOFF_RATIO_F32: f64 = 0.4;
pub const MIN_CUTOFF_RATIO_F64: f64 = 0.0005;
pub const MAX_CUTOFF_RATIO_F64: f64 = 0.4;
// [dimensionless] Log base-10 of cutoff ratios, to improve float precision during interpolation
#[rustfmt::skip]
static LOG10_CUTOFF_RATIOS: [f64; NUM_INTERP_POINTS] = [-4.0, -3.963615555643152, -3.9272311112863036, -3.8908466669294555, -3.8544622225726077, -3.8180777782157596, -3.7816933338589114, -3.745308889502063, -3.708924445145215, -3.672540000788367, -3.636155556431519, -3.599771112074671, -3.5633866677178228, -3.5270022233609746, -3.4906177790041264, -3.454233334647278, -3.41784889029043, -3.3814644459335823, -3.345080001576734, -3.308695557219886, -3.2723111128630378, -3.2359266685061896, -3.199542224149342, -3.1631577797924937, -3.1267733354356455, -3.0903888910787973, -3.054004446721949, -3.017620002365101, -2.981235558008253, -2.9448511136514046, -2.9084666692945564, -2.8720822249377087, -2.8356977805808605, -2.7993133362240123, -2.7629288918671646, -2.7265444475103164, -2.6901600031534683, -2.65377555879662, -2.617391114439772, -2.5810066700829237, -2.5446222257260755, -2.5082377813692274, -2.471853337012379, -2.435468892655531, -2.3990844482986833, -2.362700003941835, -2.326315559584987, -2.289931115228139, -2.253546670871291, -2.217162226514443, -2.1807777821575947, -2.1443933378007465, -2.1080088934438983, -2.07162444908705, -2.035240004730202, -1.9988555603733542, -1.962471116016506, -1.9260866716596579, -1.8897022273028097, -1.8533177829459615, -1.8169333385891133, -1.7805488942322656, -1.7441644498754174, -1.7077800055185692, -1.671395561161721, -1.6350111168048729, -1.5986266724480247, -1.5622422280911765, -1.5258577837343288, -1.4894733393774806, -1.4530888950206324, -1.4167044506637843, -1.380320006306936, -1.343935561950088, -1.3075511175932402, -1.271166673236392, -1.2347822288795438, -1.1983977845226956, -1.1620133401658475, -1.1256288958089993, -1.089244451452151, -1.0528600070953034, -1.0164755627384552, -0.980091118381607, -0.9437066740247588, -0.9073222296679107, -0.8709377853110625, -0.8345533409542147, -0.7981688965973666, -0.7617844522405184, -0.7254000078836702, -0.689015563526822, -0.6526311191699739, -0.6162466748131261, -0.5798622304562779, -0.5434777860994298, -0.5070933417425816, -0.4707088973857334, -0.4343244530288852, -0.3979400086720376];
#[rustfmt::skip]
static SOS_TABLES: [[[f64; NUM_INTERP_POINTS]; 5]; NUM_SECTIONS] = [ [
[9.602231393458894e-22, 1.587204120427584e-21, 2.623550174450936e-21, 4.33652238274884e-21, 7.167852408229099e-21, 1.184762624092359e-20, 1.9582494486260203e-20, 3.236671079839143e-20, 5.349614342871597e-20, 8.841768799610383e-20, 1.4613289107216707e-19, 2.415173053859291e-19, 3.9915285846797976e-19, 6.5965997428631e-19, 1.0901594982671887e-18, 1.8015570305286115e-18, 2.9770971570950646e-18, 4.919533148944843e-18, 8.129043264377182e-18, 1.343192637026347e-17, 2.219315473662598e-17, 3.666739629785632e-17, 6.057866249832431e-17, 1.0007739699030553e-16, 1.6532061329780255e-16, 2.7308038078259964e-16, 4.510493748035939e-16, 7.449466398758346e-16, 1.2302430441678893e-15, 2.0315067834483736e-15, 3.3543155162603773e-15, 5.5378884603810956e-15, 9.141873946906448e-15, 1.5089426010525782e-14, 2.4903021761539603e-14, 4.1093032139431154e-14, 6.779781299838612e-14, 1.1183780125780749e-13, 1.8445081256174408e-13, 3.041477282097698e-13, 5.014101009453051e-13, 8.264144218675732e-13, 1.3617272413684583e-12, 2.243159587963284e-12, 3.694006073080245e-12, 6.081225909841793e-12, 1.0007567996891025e-11, 1.646253152976841e-11, 2.7069550552343423e-11, 4.449040530191165e-11, 7.30862806365104e-11, 1.1999730589025615e-10, 1.9690365928679845e-10, 3.2289530220423273e-10, 5.291425298850043e-10, 8.664873551376395e-10, 1.4177647252032574e-09, 2.3177696681029807e-09, 3.785561156024134e-09, 6.1766309879453186e-09, 1.0066990199537658e-08, 1.6388417361075294e-08, 2.6645508605997302e-08, 4.326316255936647e-08, 7.014143843392857e-08, 1.1353907360274272e-07, 1.8347613292583205e-07, 2.9595370276995674e-07, 4.76454576652545e-07, 7.65444133662245e-07, 1.2269808836479021e-06, 1.9621394346279893e-06, 3.1298451137687054e-06, 4.97906566755744e-06, 7.898314100036777e-06, 1.2491394458753126e-05, 1.9692708653053506e-05, 3.0941863673408955e-05, 4.8446665390061406e-05, 7.557712281436776e-05, 0.00011745261896803922, 0.00018181252138628302, 0.0002803009717856802, 0.0004303549774596307, 0.0006579696339726737, 0.001001738346337977, 0.0015187499215285434, 0.0022932019559265787, 0.003449016993738565, 0.005168419891658915, 0.0077195180127353265, 0.011497716876861524, 0.017088844513822747, 0.02536716442452143, 0.037650994484230024, 0.0559563458175418, 0.08342301422835384, 0.12505561493111397, 0.18906458123358044, 0.28940691707833444],
[1.9204462786917787e-21, 3.174408240855168e-21, 5.247100348901872e-21, 8.67304476549768e-21, 1.4335704816458198e-20, 2.369525248184718e-20, 3.9164988972520407e-20, 6.473342159678286e-20, 1.0699228685743194e-19, 1.7683537599220765e-19, 2.9226578214433415e-19, 4.830346107718582e-19, 7.983057169359595e-19, 1.31931994857262e-18, 2.1803189965343775e-18, 3.603114061057223e-18, 5.954194314190129e-18, 9.839066297889686e-18, 1.6258086528754365e-17, 2.686385274052694e-17, 4.438630947325196e-17, 7.333479259571264e-17, 1.2115732499664862e-16, 2.0015479398061107e-16, 3.306412265956051e-16, 5.461607615651993e-16, 9.020987496071877e-16, 1.4898932797516692e-15, 2.4604860883357786e-15, 4.063013566896747e-15, 6.708631032520755e-15, 1.1075776920762191e-14, 1.8283747893812897e-14, 3.0178852021051563e-14, 4.9806043523079205e-14, 8.218606427886231e-14, 1.3559562599677225e-13, 2.2367560251561497e-13, 3.6890162512348816e-13, 6.082954564195396e-13, 1.0028202018906102e-12, 1.6528288437351464e-12, 2.7234544827369166e-12, 4.486319175926568e-12, 7.38801214616049e-12, 1.2162451819683587e-11, 2.001513599378205e-11, 3.292506305953682e-11, 5.4139101104686845e-11, 8.89808106038233e-11, 1.461725612730208e-10, 2.399946117805123e-10, 3.938073185735969e-10, 6.457906044084655e-10, 1.0582850597700086e-09, 1.732974710275279e-09, 2.835529450406515e-09, 4.6355393362059614e-09, 7.571122312048267e-09, 1.2353261975890637e-08, 2.0133980399075315e-08, 3.277683472215059e-08, 5.3291017211994605e-08, 8.652632511873294e-08, 1.4028287686785713e-07, 2.2707814720548545e-07, 3.669522658516641e-07, 5.919074055399135e-07, 9.5290915330509e-07, 1.53088826732449e-06, 2.4539617672958043e-06, 3.924278869255979e-06, 6.259690227537411e-06, 9.95813133511488e-06, 1.5796628200073553e-05, 2.4982788917506252e-05, 3.938541730610701e-05, 6.188372734681791e-05, 9.689333078012281e-05, 0.00015115424562873553, 0.00023490523793607843, 0.00036362504277256605, 0.0005606019435713603, 0.0008607099549192614, 0.0013159392679453475, 0.002003476692675954, 0.0030374998430570867, 0.004586403911853157, 0.00689803398747713, 0.01033683978331783, 0.015439036025470653, 0.02299543375372305, 0.034177689027645494, 0.05073432884904286, 0.07530198896846005, 0.1119126916350836, 0.16684602845670768, 0.25011122986222795, 0.3781291624671609, 0.5788138341566689],
[9.602231393458894e-22, 1.587204120427584e-21, 2.623550174450936e-21, 4.33652238274884e-21, 7.167852408229099e-21, 1.184762624092359e-20, 1.9582494486260203e-20, 3.236671079839143e-20, 5.349614342871597e-20, 8.841768799610383e-20, 1.4613289107216707e-19, 2.415173053859291e-19, 3.9915285846797976e-19, 6.5965997428631e-19, 1.0901594982671887e-18, 1.8015570305286115e-18, 2.9770971570950646e-18, 4.919533148944843e-18, 8.129043264377182e-18, 1.343192637026347e-17, 2.219315473662598e-17, 3.666739629785632e-17, 6.057866249832431e-17, 1.0007739699030553e-16, 1.6532061329780255e-16, 2.7308038078259964e-16, 4.510493748035939e-16, 7.449466398758346e-16, 1.2302430441678893e-15, 2.0315067834483736e-15, 3.3543155162603773e-15, 5.5378884603810956e-15, 9.141873946906448e-15, 1.5089426010525782e-14, 2.4903021761539603e-14, 4.1093032139431154e-14, 6.779781299838612e-14, 1.1183780125780749e-13, 1.8445081256174408e-13, 3.041477282097698e-13, 5.014101009453051e-13, 8.264144218675732e-13, 1.3617272413684583e-12, 2.243159587963284e-12, 3.694006073080245e-12, 6.081225909841793e-12, 1.0007567996891025e-11, 1.646253152976841e-11, 2.7069550552343423e-11, 4.449040530191165e-11, 7.30862806365104e-11, 1.1999730589025615e-10, 1.9690365928679845e-10, 3.2289530220423273e-10, 5.291425298850043e-10, 8.664873551376395e-10, 1.4177647252032574e-09, 2.3177696681029807e-09, 3.785561156024134e-09, 6.1766309879453186e-09, 1.0066990199537658e-08, 1.6388417361075294e-08, 2.6645508605997302e-08, 4.326316255936647e-08, 7.014143843392857e-08, 1.1353907360274272e-07, 1.8347613292583205e-07, 2.9595370276995674e-07, 4.76454576652545e-07, 7.65444133662245e-07, 1.2269808836479021e-06, 1.9621394346279893e-06, 3.1298451137687054e-06, 4.97906566755744e-06, 7.898314100036777e-06, 1.2491394458753126e-05, 1.9692708653053506e-05, 3.0941863673408955e-05, 4.8446665390061406e-05, 7.557712281436776e-05, 0.00011745261896803922, 0.00018181252138628302, 0.0002803009717856802, 0.0004303549774596307, 0.0006579696339726737, 0.001001738346337977, 0.0015187499215285434, 0.0022932019559265787, 0.003449016993738565, 0.005168419891658915, 0.0077195180127353265, 0.011497716876861524, 0.017088844513822747, 0.02536716442452143, 0.037650994484230024, 0.0559563458175418, 0.08342301422835384, 0.12505561493111397, 0.18906458123358044, 0.28940691707833444],
[-1.9987865235736224, -1.998680513036948, -1.9985652443948265, -1.9984399096810168, -1.9983036305195103, -1.9981554520073797, -1.9979943360695764, -1.997819154240718, -1.9976286798251812, -1.9974215793828314, -1.9971964034834, -1.9969515766679096, -1.9966853865505547, -1.9963959719891524, -1.9960813102465433, -1.995739203059237, -1.995367261523085, -1.9949628896988323, -1.9945232668330164, -1.9940453280818813, -1.9935257436176888, -1.99296089598812, -1.9923468555902824, -1.9916793541112836, -1.9909537557773642, -1.9901650262432529, -1.9893076989428196, -1.9883758387112633, -1.987363002478141, -1.9862621968196266, -1.9850658321476367, -1.9837656733031135, -1.9823527863109947, -1.9808174810456212, -1.9791492495477772, -1.9773366997287922, -1.9753674841935411, -1.973228223913487, -1.970904426483727, -1.9683803987052346, -1.9656391532460495, -1.9626623091541606, -1.9594299860215256, -1.9559206916344427, -1.9521112029919496, -1.9479764406327895, -1.9434893362846224, -1.9386206939386645, -1.933339044560856, -1.9276104947792143, -1.9213985700383494, -1.9146640528881638, -1.907364817276283, -1.8994556599438486, -1.8908881302824387, -1.8816103602952854, -1.8715668966163617, -1.860698536871933, -1.8489421730136284, -1.8362306445993293, -1.8224926053329316, -1.8076524064755541, -1.791630000981433, -1.7743408723556613, -1.7556959922326707, -1.73560181047694, -1.7139602811412271, -1.690668926798288, -1.6656209424893178, -1.638705338688506, -1.6098071201316826, -1.578807493941705, -1.5455840960260763, -1.5100112190215456, -1.4719600178860839, -1.4312986603246136, -1.3878923782643915, -1.3416033631767759, -1.2922904316634924, -1.2398083676891587, -1.184006823149582, -1.1247286276437154, -1.0618073191415445, -0.9950636563064458, -0.9243008052834144, -0.8492978006371509, -0.7698007490354041, -0.6855110550427537, -0.5960696687753934, -0.5010359328592012, -0.3998589546437571, -0.2918384026875278, -0.17606997022452056, -0.051368008566610654, 0.08384682936349605, 0.23171529218493664, 0.39519789253583865, 0.5784877220668747, 0.7876984991062875, 1.0320694053197093],
[0.9987869181183328, 0.9986809795266839, 0.9985657959461728, 0.9984405618011662, 0.9983044015417638, 0.9981563636059221, 0.9979954138679437, 0.9978204285309837, 0.9976301864179834, 0.9974233606120058, 0.9971985093932945, 0.9969540664165396, 0.9966883300677591, 0.9963994519359961, 0.9960854243305671, 0.9957440667700215, 0.9953730113642226, 0.9949696870061203, 0.9945313022848622, 0.9940548270269669, 0.9935369723674169, 0.9929741692478238, 0.9923625452343549, 0.9916978995440754, 0.9909756761648821, 0.9901909349514898, 0.9893383205782716, 0.9884120292293839, 0.9874057729079218, 0.9863127412492768, 0.9851255607298611, 0.9838362511715805, 0.9824361794554844, 0.980916010375811, 0.9792656545889772, 0.9774742136421847, 0.9755299221043044, 0.9734200868691406, 0.9711310237595606, 0.968647991632241, 0.9659551242689117, 0.963035360443303, 0.959870372676036, 0.9564404953351507, 0.9527246529108274, 0.9487002894922034, 0.9443433007051963, 0.9396279696361968, 0.9345269085703839, 0.9290110087181033, 0.9230494004904488, 0.9166094273173498, 0.9096566364783484, 0.9021547909363842, 0.8940659067247095, 0.8853503210300478, 0.8759667967311805, 0.865872669776855, 0.8550240464004267, 0.843376057745107, 0.8308831799801362, 0.817499628384251, 0.8031798341101669, 0.7878790123665802, 0.7715538305001881, 0.75416318386271, 0.7356690863398191, 0.7160376809380408, 0.6952403738229901, 0.6732550926525657, 0.650067666964507, 0.6256733248271394, 0.6000782960899311, 0.5733015086230276, 0.5453763602887497, 0.5163525465819973, 0.48629792264764454, 0.45530037970840687, 0.42346972108373176, 0.3909395335756922, 0.3578690681288917, 0.32444517205053386, 0.29088435731845763, 0.25743515060226674, 0.22438095777172543, 0.19204379969423133, 0.1607894539671109, 0.13103479627949632, 0.10325852088825396, 0.07801700981179611, 0.05596805018457417, 0.03790661103508396, 0.024819430348659785, 0.017969577591828476, 0.019030114954329363, 0.030300912729266702, 0.05507197940262944, 0.09825721827576965, 0.1675553764769945, 0.2757079424729437],
],
[
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0],
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[-1.9991114234707956, -1.9990337727604992, -1.9989493363310546, -1.998857521194538, -1.9987576825434046, -1.998649119222161, -1.9985310688033433, -1.9984027022332262, -1.9982631180096637, -1.9981113358511933, -1.9979462898129565, -1.9977668208011163, -1.997571668433217, -1.997359462187372, -1.9971287117781622, -1.9968777966917122, -1.996604954806533, -1.996308270020304, -1.9959856587958438, -1.9956348555319212, -1.9952533966563937, -1.9948386033302172, -1.9943875626412075, -1.993897107155912, -1.9933637926865508, -1.9927838741176171, -1.9921532791232768, -1.9914675795921941, -1.9907219605606032, -1.989911186437411, -1.9890295642866116, -1.988070903912348, -1.9870284744703925, -1.9858949573065428, -1.9846623946974187, -1.9833221341421994, -1.9818647678249774, -1.9802800668364902, -1.9785569097110403, -1.9766832047993521, -1.9746458059610283, -1.9724304210212131, -1.970021512395213, -1.967402189242425, -1.9645540904673746, -1.9614572578414695, -1.9580899984750013, -1.9544287358259667, -1.9504478483916414, -1.9461194951922782, -1.941413427125804, -1.9362967832507005, -1.9307338710444661, -1.924685929691318, -1.9181108754797074, -1.9109630284436092, -1.9031928194679588, -1.8947464772056901, -1.885565694330078, -1.8755872728807446, -1.8647427487643327, -1.852957995850883, -1.8401528105724745, -1.8262404784873936, -1.8111273249218913, -1.7947122525362074, -1.7768862694644867, -1.7575320125161402, -1.736523270743556, -1.713724515392271, -1.6889904427301525, -1.662165536326633, -1.633083654784006, -1.6015676493961735, -1.5674290133215236, -1.5304675590966745, -1.4904711140593543, -1.4472152127338067, -1.40046275056052, -1.3499635434670951, -1.2954537114447293, -1.2366547700651915, -1.1732722700070515, -1.1049937689932585, -1.0314858502483877, -0.9523898127800617, -0.8673155459121803, -0.7758329553701911, -0.6774601187218066, -0.5716470963143466, -0.45775398460197514, -0.33502133757547997, -0.2025304576704996, -0.05915023521162438, 0.0965337865296409, 0.26631341054521035, 0.4524802392815798, 0.6579785181254244, 0.8865750515828817, 1.142980502539901],
[0.9991118180796386, 0.9990342393326854, 0.9989498879884002, 0.9988581734509603, 0.9987584537408487, 0.9986500310459242, 0.9985321468912456, 0.9984039768957025, 0.9982646250809533, 0.9981131176954677, 0.997948396513556, 0.9977693115661721, 0.9975746132569798, 0.9973629438136895, 0.9971328280209648, 0.9968826631773032, 0.9966107082142017, 0.9963150719116189, 0.9959937001393131, 0.9956443620489681, 0.9952646351373148, 0.994851889095584, 0.9944032683557585, 0.9939156732392116, 0.993385739608559, 0.9928098169189893, 0.9921839445610622, 0.9915038263832295, 0.990764803279181, 0.9899618237229286, 0.9890894121334455, 0.9881416349511233, 0.9871120643106173, 0.9859937391992932, 0.9847791239980894, 0.9834600643127269, 0.9820277400186969, 0.9804726154641858, 0.9787843868021654, 0.9769519264574649, 0.9749632247782459, 0.9728053289755125, 0.9704642795210334, 0.967925044255475, 0.9651714505570975, 0.9621861160397834, 0.9589503783905279, 0.9554442251242659, 0.9516462242316596, 0.9475334569273602, 0.9430814539764486, 0.9382641373898086, 0.933053769639459, 0.9274209129569344, 0.9213344017455645, 0.9147613316644951, 0.9076670695308546, 0.9000152888374098, 0.8917680363950624, 0.8828858363782619, 0.8733278388687078, 0.8630520208455521, 0.852015448439579, 0.8401746101283707, 0.8274858313646667, 0.8139057818574212, 0.7993920873111949, 0.7839040578122602, 0.7674035451595597, 0.7498559412020915, 0.7312313285911666, 0.7115057942288784, 0.6906629140644466, 0.6686954157794791, 0.6456070234139086, 0.6214144853395186, 0.5961497845841836, 0.5698625289848636, 0.5426225189661107, 0.514522494306222, 0.48568107005016636, 0.45624588851929165, 0.42639704297020586, 0.3963508741602541, 0.3663643113108144, 0.3367400343727691, 0.30783289080728554, 0.2800582312553904, 0.25390317222035375, 0.22994231156183748, 0.20886021676071997, 0.19148425260438737, 0.1788333240101219, 0.17219144041283974, 0.1732206969665549, 0.1841382904404239, 0.2080004238790285, 0.24917025796116005, 0.31411380026799895, 0.41280159809618855],
],
[
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0],
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[-1.9996744165795892, -1.9996459320974254, -1.9996149524979923, -1.999581258658783, -1.9995446121118288, -1.9995047533172725, -1.999461399779547, -1.9994142439911995, -1.9993629511879172, -1.9993071568965752, -1.9992464642562766, -1.9991804410902123, -1.999108616703845, -1.999030478382256, -1.9989454675565543, -1.9988529756059095, -1.998752339258045, -1.9986428355468095, -1.9985236762806913, -1.9983940019707684, -1.9982528751605106, -1.9980992730929323, -1.9979320796427886, -1.9977500764325615, -1.9975519330408638, -1.9973361962002663, -1.997101277868353, -1.996845442040637, -1.9965667901566395, -1.9962632449305278, -1.9959325324148685, -1.9955721620797797, -1.9951794046595517, -1.9947512674840135, -1.9942844669717994, -1.993775397916436, -1.9932200991427824, -1.9926142150497455, -1.991952952484057, -1.9912310323076914, -1.9904426349266253, -1.989581338938989, -1.9886400519341132, -1.9876109323279114, -1.9864853009515675, -1.9852535409163723, -1.9839049840540781, -1.982427781975199, -1.9808087594927903, -1.9790332478213473, -1.9770848945742185, -1.9749454471426011, -1.9725945055386591, -1.9700092402185747, -1.967164069762288, -1.9640302925698105, -1.9605756659346625, -1.9567639249701725, -1.9525542328934768, -1.9479005531180973, -1.9427509324771173, -1.9370466837103806, -1.9307214541254458, -1.923700166120464, -1.915897814091039, -1.907218101206638, -1.8975518987351179, -1.88677551014832, -1.87474872232765, -1.861312627021448, -1.8462871975531776, -1.8294686089656265, -1.8106262946973732, -1.7894997399705324, -1.7657950218262157, -1.7391811187227548, -1.7092860293817835, -1.675692761694416, -1.6379352785133139, -1.595494518524122, -1.5477946475210551, -1.4941997387315697, -1.4340111310017016, -1.366465772039695, -1.2907359235559577, -1.20593069246096, -1.1110999701383497, -1.0052415346124746, -0.8873123427722851, -0.7562454908291008, -0.6109750885517555, -0.45047261327391064, -0.27380058809050634, -0.08019335687608353, 0.13081851040016312, 0.35921203687582703, 0.6041558696040903, 0.8634928252101928, 1.1328834042962652, 1.4043848904715814],
[0.9996748112995626, 0.9996463988124888, 0.9996155043390303, 0.9995819111513712, 0.9995453836129006, 0.9995056655313932, 0.9994624783693072, 0.9994155192988782, 0.9993644590886905, 0.9993089398072402, 0.999248572327823, 0.999182933617734, 0.9991115637933797, 0.9990339629213459, 0.9989495875438367, 0.9988578469051049, 0.998758098853607, 0.9986496453925378, 0.9985317278492191, 0.9984035216314385, 0.9982641305363193, 0.998112580574589, 0.9979478132702555, 0.9977686783926114, 0.9975739260742693, 0.9973621982654599, 0.9971320194712354, 0.9968817867143889, 0.9966097586629439, 0.9963140438569275, 0.9959925879648891, 0.9956431599962509, 0.9952633373911647, 0.9948504899051408, 0.994401762201351, 0.9939140550593651, 0.9933840051051854, 0.992807962964023, 0.9921819697344909, 0.9915017316809588, 0.9907625930401314, 0.9899595068387254, 0.9890870036219737, 0.9881391579981089, 0.987109552912651, 0.9859912415791036, 0.9847767070105932, 0.9834578191212687, 0.982025789398527, 0.9804711231891176, 0.9787835696962074, 0.9769520698533128, 0.9749647023278283, 0.97280862801582, 0.9704700335254846, 0.967934074315008, 0.965184818358363, 0.9622051914680614, 0.9589769257167791, 0.9554805127815822, 0.9516951644987873, 0.9475987834800437, 0.943167947319353, 0.9383779107374783, 0.9332026309883595, 0.927614823018577, 0.9215860522549594, 0.9150868745291064, 0.908087034564457, 0.9005557366858468, 0.892462003996979, 0.8837751452387308, 0.8744653519171043, 0.8645044520930691, 0.8538668514683635, 0.8425306970834905, 0.8304793040637494, 0.8177028914075452, 0.8042006788344609, 0.7899834032858511, 0.7750763210076385, 0.7595227696730126, 0.7433883755173845, 0.7267660043333111, 0.7097815746565745, 0.6926008800807162, 0.6754376106491038, 0.6585628283430073, 0.6423162494814305, 0.627119831615625, 0.6134943721446492, 0.6020801207161488, 0.5936628055211841, 0.5892069773146722, 0.5898991375489016, 0.5972035594488184, 0.6129335233059198, 0.6393385581773878, 0.6792010028055, 0.7359151911964714],
],
];
pub trait CutoffRatioBounds {
const MIN_CUTOFF_RATIO: f64;
const MAX_CUTOFF_RATIO: f64;
fn is_within_bounds(cutoff_ratio: f64) -> bool {
cutoff_ratio >= Self::MIN_CUTOFF_RATIO && cutoff_ratio <= Self::MAX_CUTOFF_RATIO
}
}
impl CutoffRatioBounds for f32 {
const MIN_CUTOFF_RATIO: f64 = MIN_CUTOFF_RATIO_F32;
const MAX_CUTOFF_RATIO: f64 = MAX_CUTOFF_RATIO_F32;
}
impl CutoffRatioBounds for f64 {
const MIN_CUTOFF_RATIO: f64 = MIN_CUTOFF_RATIO_F64;
const MAX_CUTOFF_RATIO: f64 = MAX_CUTOFF_RATIO_F64;
}
/// Butterworth order 6 lowpass filter, second order sections (SOS) implementation.
/// The filter is created by interpolating the SOS coefficients from stored tables.
///
/// `cutoff_ratio` (dimensionless) is the cutoff frequency divided by the sample frequency.
///
/// Region of validity for `cutoff_ratio` depends on the float type `T`:
/// * f32: 0.0100 to 0.4000
/// * f64: 0.0005 to 0.4000
pub fn butter6<T>(cutoff_ratio: f64) -> Result<SisoSosFilter<NUM_SECTIONS, T>, &'static str>
where
T: Num
+ Copy
+ MulAdd<Output = T>
+ Neg<Output = T>
+ FromPrimitive
+ ToPrimitive
+ CutoffRatioBounds,
{
if !T::is_within_bounds(cutoff_ratio) {
return Err("cutoff_ratio out of bounds for provided float type");
}
// Convert SOS tables from static arrays to slices because new_interpolated expects slices.
let sos_tables = SOS_TABLES
.each_ref()
.map(|sec| sec.each_ref().map(|coeffs| &coeffs[..]));
SisoSosFilter::new_interpolated(cutoff_ratio, &LOG10_CUTOFF_RATIOS, sos_tables)
}
#[cfg(test)]
mod tests {
use super::super::super::test_helpers::test_filter;
use super::{
MAX_CUTOFF_RATIO_F32, MAX_CUTOFF_RATIO_F64, MIN_CUTOFF_RATIO_F32, MIN_CUTOFF_RATIO_F64,
NUM_SECTIONS, butter6,
};
#[test]
fn test_butter6_f32() {
test_filter::<NUM_SECTIONS, f32>(MIN_CUTOFF_RATIO_F32, MAX_CUTOFF_RATIO_F32, butter6);
}
#[test]
fn test_butter6_f64() {
test_filter::<NUM_SECTIONS, f64>(MIN_CUTOFF_RATIO_F64, MAX_CUTOFF_RATIO_F64, butter6);
}
}