arm_math.h 246 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155
  1. /* ----------------------------------------------------------------------
  2. * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
  3. *
  4. * $Date: 20. October 2015
  5. * $Revision: V1.4.5 b
  6. *
  7. * Project: CMSIS DSP Library
  8. * Title: arm_math.h
  9. *
  10. * Description: Public header file for CMSIS DSP Library
  11. *
  12. * Target Processor: Cortex-M7/Cortex-M4/Cortex-M3/Cortex-M0
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. * - Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. * - Neither the name of ARM LIMITED nor the names of its contributors
  24. * may be used to endorse or promote products derived from this
  25. * software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  30. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  31. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  32. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  33. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  34. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  35. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. * -------------------------------------------------------------------- */
  40. /**
  41. \mainpage CMSIS DSP Software Library
  42. *
  43. * Introduction
  44. * ------------
  45. *
  46. * This user manual describes the CMSIS DSP software library,
  47. * a suite of common signal processing functions for use on Cortex-M processor based devices.
  48. *
  49. * The library is divided into a number of functions each covering a specific category:
  50. * - Basic math functions
  51. * - Fast math functions
  52. * - Complex math functions
  53. * - Filters
  54. * - Matrix functions
  55. * - Transforms
  56. * - Motor control functions
  57. * - Statistical functions
  58. * - Support functions
  59. * - Interpolation functions
  60. *
  61. * The library has separate functions for operating on 8-bit integers, 16-bit integers,
  62. * 32-bit integer and 32-bit floating-point values.
  63. *
  64. * Using the Library
  65. * ------------
  66. *
  67. * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
  68. * - arm_cortexM7lfdp_math.lib (Little endian and Double Precision Floating Point Unit on Cortex-M7)
  69. * - arm_cortexM7bfdp_math.lib (Big endian and Double Precision Floating Point Unit on Cortex-M7)
  70. * - arm_cortexM7lfsp_math.lib (Little endian and Single Precision Floating Point Unit on Cortex-M7)
  71. * - arm_cortexM7bfsp_math.lib (Big endian and Single Precision Floating Point Unit on Cortex-M7)
  72. * - arm_cortexM7l_math.lib (Little endian on Cortex-M7)
  73. * - arm_cortexM7b_math.lib (Big endian on Cortex-M7)
  74. * - arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4)
  75. * - arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4)
  76. * - arm_cortexM4l_math.lib (Little endian on Cortex-M4)
  77. * - arm_cortexM4b_math.lib (Big endian on Cortex-M4)
  78. * - arm_cortexM3l_math.lib (Little endian on Cortex-M3)
  79. * - arm_cortexM3b_math.lib (Big endian on Cortex-M3)
  80. * - arm_cortexM0l_math.lib (Little endian on Cortex-M0 / CortexM0+)
  81. * - arm_cortexM0b_math.lib (Big endian on Cortex-M0 / CortexM0+)
  82. *
  83. * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
  84. * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
  85. * public header file <code> arm_math.h</code> for Cortex-M7/M4/M3/M0/M0+ with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
  86. * Define the appropriate pre processor MACRO ARM_MATH_CM7 or ARM_MATH_CM4 or ARM_MATH_CM3 or
  87. * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
  88. *
  89. * Examples
  90. * --------
  91. *
  92. * The library ships with a number of examples which demonstrate how to use the library functions.
  93. *
  94. * Toolchain Support
  95. * ------------
  96. *
  97. * The library has been developed and tested with MDK-ARM version 5.14.0.0
  98. * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
  99. *
  100. * Building the Library
  101. * ------------
  102. *
  103. * The library installer contains a project file to re build libraries on MDK-ARM Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.
  104. * - arm_cortexM_math.uvprojx
  105. *
  106. *
  107. * The libraries can be built by opening the arm_cortexM_math.uvprojx project in MDK-ARM, selecting a specific target, and defining the optional pre processor MACROs detailed above.
  108. *
  109. * Pre-processor Macros
  110. * ------------
  111. *
  112. * Each library project have differant pre-processor macros.
  113. *
  114. * - UNALIGNED_SUPPORT_DISABLE:
  115. *
  116. * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
  117. *
  118. * - ARM_MATH_BIG_ENDIAN:
  119. *
  120. * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
  121. *
  122. * - ARM_MATH_MATRIX_CHECK:
  123. *
  124. * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
  125. *
  126. * - ARM_MATH_ROUNDING:
  127. *
  128. * Define macro ARM_MATH_ROUNDING for rounding on support functions
  129. *
  130. * - ARM_MATH_CMx:
  131. *
  132. * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
  133. * and ARM_MATH_CM0 for building library on Cortex-M0 target, ARM_MATH_CM0PLUS for building library on Cortex-M0+ target, and
  134. * ARM_MATH_CM7 for building the library on cortex-M7.
  135. *
  136. * - __FPU_PRESENT:
  137. *
  138. * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries
  139. *
  140. * <hr>
  141. * CMSIS-DSP in ARM::CMSIS Pack
  142. * -----------------------------
  143. *
  144. * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories:
  145. * |File/Folder |Content |
  146. * |------------------------------|------------------------------------------------------------------------|
  147. * |\b CMSIS\\Documentation\\DSP | This documentation |
  148. * |\b CMSIS\\DSP_Lib | Software license agreement (license.txt) |
  149. * |\b CMSIS\\DSP_Lib\\Examples | Example projects demonstrating the usage of the library functions |
  150. * |\b CMSIS\\DSP_Lib\\Source | Source files for rebuilding the library |
  151. *
  152. * <hr>
  153. * Revision History of CMSIS-DSP
  154. * ------------
  155. * Please refer to \ref ChangeLog_pg.
  156. *
  157. * Copyright Notice
  158. * ------------
  159. *
  160. * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
  161. */
  162. /**
  163. * @defgroup groupMath Basic Math Functions
  164. */
  165. /**
  166. * @defgroup groupFastMath Fast Math Functions
  167. * This set of functions provides a fast approximation to sine, cosine, and square root.
  168. * As compared to most of the other functions in the CMSIS math library, the fast math functions
  169. * operate on individual values and not arrays.
  170. * There are separate functions for Q15, Q31, and floating-point data.
  171. *
  172. */
  173. /**
  174. * @defgroup groupCmplxMath Complex Math Functions
  175. * This set of functions operates on complex data vectors.
  176. * The data in the complex arrays is stored in an interleaved fashion
  177. * (real, imag, real, imag, ...).
  178. * In the API functions, the number of samples in a complex array refers
  179. * to the number of complex values; the array contains twice this number of
  180. * real values.
  181. */
  182. /**
  183. * @defgroup groupFilters Filtering Functions
  184. */
  185. /**
  186. * @defgroup groupMatrix Matrix Functions
  187. *
  188. * This set of functions provides basic matrix math operations.
  189. * The functions operate on matrix data structures. For example,
  190. * the type
  191. * definition for the floating-point matrix structure is shown
  192. * below:
  193. * <pre>
  194. * typedef struct
  195. * {
  196. * uint16_t numRows; // number of rows of the matrix.
  197. * uint16_t numCols; // number of columns of the matrix.
  198. * float32_t *pData; // points to the data of the matrix.
  199. * } arm_matrix_instance_f32;
  200. * </pre>
  201. * There are similar definitions for Q15 and Q31 data types.
  202. *
  203. * The structure specifies the size of the matrix and then points to
  204. * an array of data. The array is of size <code>numRows X numCols</code>
  205. * and the values are arranged in row order. That is, the
  206. * matrix element (i, j) is stored at:
  207. * <pre>
  208. * pData[i*numCols + j]
  209. * </pre>
  210. *
  211. * \par Init Functions
  212. * There is an associated initialization function for each type of matrix
  213. * data structure.
  214. * The initialization function sets the values of the internal structure fields.
  215. * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>
  216. * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively.
  217. *
  218. * \par
  219. * Use of the initialization function is optional. However, if initialization function is used
  220. * then the instance structure cannot be placed into a const data section.
  221. * To place the instance structure in a const data
  222. * section, manually initialize the data structure. For example:
  223. * <pre>
  224. * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
  225. * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
  226. * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
  227. * </pre>
  228. * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
  229. * specifies the number of columns, and <code>pData</code> points to the
  230. * data array.
  231. *
  232. * \par Size Checking
  233. * By default all of the matrix functions perform size checking on the input and
  234. * output matrices. For example, the matrix addition function verifies that the
  235. * two input matrices and the output matrix all have the same number of rows and
  236. * columns. If the size check fails the functions return:
  237. * <pre>
  238. * ARM_MATH_SIZE_MISMATCH
  239. * </pre>
  240. * Otherwise the functions return
  241. * <pre>
  242. * ARM_MATH_SUCCESS
  243. * </pre>
  244. * There is some overhead associated with this matrix size checking.
  245. * The matrix size checking is enabled via the \#define
  246. * <pre>
  247. * ARM_MATH_MATRIX_CHECK
  248. * </pre>
  249. * within the library project settings. By default this macro is defined
  250. * and size checking is enabled. By changing the project settings and
  251. * undefining this macro size checking is eliminated and the functions
  252. * run a bit faster. With size checking disabled the functions always
  253. * return <code>ARM_MATH_SUCCESS</code>.
  254. */
  255. /**
  256. * @defgroup groupTransforms Transform Functions
  257. */
  258. /**
  259. * @defgroup groupController Controller Functions
  260. */
  261. /**
  262. * @defgroup groupStats Statistics Functions
  263. */
  264. /**
  265. * @defgroup groupSupport Support Functions
  266. */
  267. /**
  268. * @defgroup groupInterpolation Interpolation Functions
  269. * These functions perform 1- and 2-dimensional interpolation of data.
  270. * Linear interpolation is used for 1-dimensional data and
  271. * bilinear interpolation is used for 2-dimensional data.
  272. */
  273. /**
  274. * @defgroup groupExamples Examples
  275. */
  276. #ifndef _ARM_MATH_H
  277. #define _ARM_MATH_H
  278. /* ignore some GCC warnings */
  279. #if defined ( __GNUC__ )
  280. #pragma GCC diagnostic push
  281. #pragma GCC diagnostic ignored "-Wsign-conversion"
  282. #pragma GCC diagnostic ignored "-Wconversion"
  283. #pragma GCC diagnostic ignored "-Wunused-parameter"
  284. #endif
  285. #define __CMSIS_GENERIC /* disable NVIC and Systick functions */
  286. #if defined(ARM_MATH_CM7)
  287. #include "core_cm7.h"
  288. #elif defined (ARM_MATH_CM4)
  289. #include "core_cm4.h"
  290. #elif defined (ARM_MATH_CM3)
  291. #include "core_cm3.h"
  292. #elif defined (ARM_MATH_CM0)
  293. #include "core_cm0.h"
  294. #define ARM_MATH_CM0_FAMILY
  295. #elif defined (ARM_MATH_CM0PLUS)
  296. #include "core_cm0plus.h"
  297. #define ARM_MATH_CM0_FAMILY
  298. #else
  299. #error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"
  300. #endif
  301. #undef __CMSIS_GENERIC /* enable NVIC and Systick functions */
  302. #include "string.h"
  303. #include "math.h"
  304. #ifdef __cplusplus
  305. extern "C"
  306. {
  307. #endif
  308. /**
  309. * @brief Macros required for reciprocal calculation in Normalized LMS
  310. */
  311. #define DELTA_Q31 (0x100)
  312. #define DELTA_Q15 0x5
  313. #define INDEX_MASK 0x0000003F
  314. #ifndef PI
  315. #define PI 3.14159265358979f
  316. #endif
  317. /**
  318. * @brief Macros required for SINE and COSINE Fast math approximations
  319. */
  320. #define FAST_MATH_TABLE_SIZE 512
  321. #define FAST_MATH_Q31_SHIFT (32 - 10)
  322. #define FAST_MATH_Q15_SHIFT (16 - 10)
  323. #define CONTROLLER_Q31_SHIFT (32 - 9)
  324. #define TABLE_SIZE 256
  325. #define TABLE_SPACING_Q31 0x400000
  326. #define TABLE_SPACING_Q15 0x80
  327. /**
  328. * @brief Macros required for SINE and COSINE Controller functions
  329. */
  330. /* 1.31(q31) Fixed value of 2/360 */
  331. /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
  332. #define INPUT_SPACING 0xB60B61
  333. /**
  334. * @brief Macro for Unaligned Support
  335. */
  336. #ifndef UNALIGNED_SUPPORT_DISABLE
  337. #define ALIGN4
  338. #else
  339. #if defined (__GNUC__)
  340. #define ALIGN4 __attribute__((aligned(4)))
  341. #else
  342. #define ALIGN4 __align(4)
  343. #endif
  344. #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
  345. /**
  346. * @brief Error status returned by some functions in the library.
  347. */
  348. typedef enum
  349. {
  350. ARM_MATH_SUCCESS = 0, /**< No error */
  351. ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
  352. ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
  353. ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
  354. ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
  355. ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
  356. ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
  357. } arm_status;
  358. /**
  359. * @brief 8-bit fractional data type in 1.7 format.
  360. */
  361. typedef int8_t q7_t;
  362. /**
  363. * @brief 16-bit fractional data type in 1.15 format.
  364. */
  365. typedef int16_t q15_t;
  366. /**
  367. * @brief 32-bit fractional data type in 1.31 format.
  368. */
  369. typedef int32_t q31_t;
  370. /**
  371. * @brief 64-bit fractional data type in 1.63 format.
  372. */
  373. typedef int64_t q63_t;
  374. /**
  375. * @brief 32-bit floating-point type definition.
  376. */
  377. typedef float float32_t;
  378. /**
  379. * @brief 64-bit floating-point type definition.
  380. */
  381. typedef double float64_t;
  382. /**
  383. * @brief definition to read/write two 16 bit values.
  384. */
  385. #if defined __CC_ARM
  386. #define __SIMD32_TYPE int32_t __packed
  387. #define CMSIS_UNUSED __attribute__((unused))
  388. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  389. #define __SIMD32_TYPE int32_t
  390. #define CMSIS_UNUSED __attribute__((unused))
  391. #elif defined __GNUC__
  392. #define __SIMD32_TYPE int32_t
  393. #define CMSIS_UNUSED __attribute__((unused))
  394. #elif defined __ICCARM__
  395. #define __SIMD32_TYPE int32_t __packed
  396. #define CMSIS_UNUSED
  397. #elif defined __CSMC__
  398. #define __SIMD32_TYPE int32_t
  399. #define CMSIS_UNUSED
  400. #elif defined __TASKING__
  401. #define __SIMD32_TYPE __unaligned int32_t
  402. #define CMSIS_UNUSED
  403. #else
  404. #error Unknown compiler
  405. #endif
  406. #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
  407. #define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
  408. #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
  409. #define __SIMD64(addr) (*(int64_t **) & (addr))
  410. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  411. /**
  412. * @brief definition to pack two 16 bit values.
  413. */
  414. #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
  415. (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
  416. #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
  417. (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
  418. #endif
  419. /**
  420. * @brief definition to pack four 8 bit values.
  421. */
  422. #ifndef ARM_MATH_BIG_ENDIAN
  423. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
  424. (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
  425. (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
  426. (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
  427. #else
  428. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
  429. (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
  430. (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
  431. (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
  432. #endif
  433. /**
  434. * @brief Clips Q63 to Q31 values.
  435. */
  436. static __INLINE q31_t clip_q63_to_q31(
  437. q63_t x)
  438. {
  439. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  440. ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
  441. }
  442. /**
  443. * @brief Clips Q63 to Q15 values.
  444. */
  445. static __INLINE q15_t clip_q63_to_q15(
  446. q63_t x)
  447. {
  448. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  449. ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
  450. }
  451. /**
  452. * @brief Clips Q31 to Q7 values.
  453. */
  454. static __INLINE q7_t clip_q31_to_q7(
  455. q31_t x)
  456. {
  457. return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
  458. ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
  459. }
  460. /**
  461. * @brief Clips Q31 to Q15 values.
  462. */
  463. static __INLINE q15_t clip_q31_to_q15(
  464. q31_t x)
  465. {
  466. return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
  467. ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
  468. }
  469. /**
  470. * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
  471. */
  472. static __INLINE q63_t mult32x64(
  473. q63_t x,
  474. q31_t y)
  475. {
  476. return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
  477. (((q63_t) (x >> 32) * y)));
  478. }
  479. /*
  480. #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
  481. #define __CLZ __clz
  482. #endif
  483. */
  484. /* note: function can be removed when all toolchain support __CLZ for Cortex-M0 */
  485. #if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) )
  486. static __INLINE uint32_t __CLZ(
  487. q31_t data);
  488. static __INLINE uint32_t __CLZ(
  489. q31_t data)
  490. {
  491. uint32_t count = 0;
  492. uint32_t mask = 0x80000000;
  493. while((data & mask) == 0)
  494. {
  495. count += 1u;
  496. mask = mask >> 1u;
  497. }
  498. return (count);
  499. }
  500. #endif
  501. /**
  502. * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
  503. */
  504. static __INLINE uint32_t arm_recip_q31(
  505. q31_t in,
  506. q31_t * dst,
  507. q31_t * pRecipTable)
  508. {
  509. q31_t out;
  510. uint32_t tempVal;
  511. uint32_t index, i;
  512. uint32_t signBits;
  513. if(in > 0)
  514. {
  515. signBits = ((uint32_t) (__CLZ( in) - 1));
  516. }
  517. else
  518. {
  519. signBits = ((uint32_t) (__CLZ(-in) - 1));
  520. }
  521. /* Convert input sample to 1.31 format */
  522. in = (in << signBits);
  523. /* calculation of index for initial approximated Val */
  524. index = (uint32_t)(in >> 24);
  525. index = (index & INDEX_MASK);
  526. /* 1.31 with exp 1 */
  527. out = pRecipTable[index];
  528. /* calculation of reciprocal value */
  529. /* running approximation for two iterations */
  530. for (i = 0u; i < 2u; i++)
  531. {
  532. tempVal = (uint32_t) (((q63_t) in * out) >> 31);
  533. tempVal = 0x7FFFFFFFu - tempVal;
  534. /* 1.31 with exp 1 */
  535. /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */
  536. out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30);
  537. }
  538. /* write output */
  539. *dst = out;
  540. /* return num of signbits of out = 1/in value */
  541. return (signBits + 1u);
  542. }
  543. /**
  544. * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
  545. */
  546. static __INLINE uint32_t arm_recip_q15(
  547. q15_t in,
  548. q15_t * dst,
  549. q15_t * pRecipTable)
  550. {
  551. q15_t out = 0;
  552. uint32_t tempVal = 0;
  553. uint32_t index = 0, i = 0;
  554. uint32_t signBits = 0;
  555. if(in > 0)
  556. {
  557. signBits = ((uint32_t)(__CLZ( in) - 17));
  558. }
  559. else
  560. {
  561. signBits = ((uint32_t)(__CLZ(-in) - 17));
  562. }
  563. /* Convert input sample to 1.15 format */
  564. in = (in << signBits);
  565. /* calculation of index for initial approximated Val */
  566. index = (uint32_t)(in >> 8);
  567. index = (index & INDEX_MASK);
  568. /* 1.15 with exp 1 */
  569. out = pRecipTable[index];
  570. /* calculation of reciprocal value */
  571. /* running approximation for two iterations */
  572. for (i = 0u; i < 2u; i++)
  573. {
  574. tempVal = (uint32_t) (((q31_t) in * out) >> 15);
  575. tempVal = 0x7FFFu - tempVal;
  576. /* 1.15 with exp 1 */
  577. out = (q15_t) (((q31_t) out * tempVal) >> 14);
  578. /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */
  579. }
  580. /* write output */
  581. *dst = out;
  582. /* return num of signbits of out = 1/in value */
  583. return (signBits + 1);
  584. }
  585. /*
  586. * @brief C custom defined intrinisic function for only M0 processors
  587. */
  588. #if defined(ARM_MATH_CM0_FAMILY)
  589. static __INLINE q31_t __SSAT(
  590. q31_t x,
  591. uint32_t y)
  592. {
  593. int32_t posMax, negMin;
  594. uint32_t i;
  595. posMax = 1;
  596. for (i = 0; i < (y - 1); i++)
  597. {
  598. posMax = posMax * 2;
  599. }
  600. if(x > 0)
  601. {
  602. posMax = (posMax - 1);
  603. if(x > posMax)
  604. {
  605. x = posMax;
  606. }
  607. }
  608. else
  609. {
  610. negMin = -posMax;
  611. if(x < negMin)
  612. {
  613. x = negMin;
  614. }
  615. }
  616. return (x);
  617. }
  618. #endif /* end of ARM_MATH_CM0_FAMILY */
  619. /*
  620. * @brief C custom defined intrinsic function for M3 and M0 processors
  621. */
  622. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  623. /*
  624. * @brief C custom defined QADD8 for M3 and M0 processors
  625. */
  626. static __INLINE uint32_t __QADD8(
  627. uint32_t x,
  628. uint32_t y)
  629. {
  630. q31_t r, s, t, u;
  631. r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
  632. s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
  633. t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
  634. u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
  635. return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
  636. }
  637. /*
  638. * @brief C custom defined QSUB8 for M3 and M0 processors
  639. */
  640. static __INLINE uint32_t __QSUB8(
  641. uint32_t x,
  642. uint32_t y)
  643. {
  644. q31_t r, s, t, u;
  645. r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
  646. s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
  647. t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
  648. u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
  649. return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
  650. }
  651. /*
  652. * @brief C custom defined QADD16 for M3 and M0 processors
  653. */
  654. static __INLINE uint32_t __QADD16(
  655. uint32_t x,
  656. uint32_t y)
  657. {
  658. /* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */
  659. q31_t r = 0, s = 0;
  660. r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  661. s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  662. return ((uint32_t)((s << 16) | (r )));
  663. }
  664. /*
  665. * @brief C custom defined SHADD16 for M3 and M0 processors
  666. */
  667. static __INLINE uint32_t __SHADD16(
  668. uint32_t x,
  669. uint32_t y)
  670. {
  671. q31_t r, s;
  672. r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  673. s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  674. return ((uint32_t)((s << 16) | (r )));
  675. }
  676. /*
  677. * @brief C custom defined QSUB16 for M3 and M0 processors
  678. */
  679. static __INLINE uint32_t __QSUB16(
  680. uint32_t x,
  681. uint32_t y)
  682. {
  683. q31_t r, s;
  684. r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  685. s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  686. return ((uint32_t)((s << 16) | (r )));
  687. }
  688. /*
  689. * @brief C custom defined SHSUB16 for M3 and M0 processors
  690. */
  691. static __INLINE uint32_t __SHSUB16(
  692. uint32_t x,
  693. uint32_t y)
  694. {
  695. q31_t r, s;
  696. r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  697. s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  698. return ((uint32_t)((s << 16) | (r )));
  699. }
  700. /*
  701. * @brief C custom defined QASX for M3 and M0 processors
  702. */
  703. static __INLINE uint32_t __QASX(
  704. uint32_t x,
  705. uint32_t y)
  706. {
  707. q31_t r, s;
  708. r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  709. s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  710. return ((uint32_t)((s << 16) | (r )));
  711. }
  712. /*
  713. * @brief C custom defined SHASX for M3 and M0 processors
  714. */
  715. static __INLINE uint32_t __SHASX(
  716. uint32_t x,
  717. uint32_t y)
  718. {
  719. q31_t r, s;
  720. r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  721. s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  722. return ((uint32_t)((s << 16) | (r )));
  723. }
  724. /*
  725. * @brief C custom defined QSAX for M3 and M0 processors
  726. */
  727. static __INLINE uint32_t __QSAX(
  728. uint32_t x,
  729. uint32_t y)
  730. {
  731. q31_t r, s;
  732. r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  733. s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  734. return ((uint32_t)((s << 16) | (r )));
  735. }
  736. /*
  737. * @brief C custom defined SHSAX for M3 and M0 processors
  738. */
  739. static __INLINE uint32_t __SHSAX(
  740. uint32_t x,
  741. uint32_t y)
  742. {
  743. q31_t r, s;
  744. r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  745. s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  746. return ((uint32_t)((s << 16) | (r )));
  747. }
  748. /*
  749. * @brief C custom defined SMUSDX for M3 and M0 processors
  750. */
  751. static __INLINE uint32_t __SMUSDX(
  752. uint32_t x,
  753. uint32_t y)
  754. {
  755. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
  756. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
  757. }
  758. /*
  759. * @brief C custom defined SMUADX for M3 and M0 processors
  760. */
  761. static __INLINE uint32_t __SMUADX(
  762. uint32_t x,
  763. uint32_t y)
  764. {
  765. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  766. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
  767. }
  768. /*
  769. * @brief C custom defined QADD for M3 and M0 processors
  770. */
  771. static __INLINE int32_t __QADD(
  772. int32_t x,
  773. int32_t y)
  774. {
  775. return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y)));
  776. }
  777. /*
  778. * @brief C custom defined QSUB for M3 and M0 processors
  779. */
  780. static __INLINE int32_t __QSUB(
  781. int32_t x,
  782. int32_t y)
  783. {
  784. return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y)));
  785. }
  786. /*
  787. * @brief C custom defined SMLAD for M3 and M0 processors
  788. */
  789. static __INLINE uint32_t __SMLAD(
  790. uint32_t x,
  791. uint32_t y,
  792. uint32_t sum)
  793. {
  794. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  795. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
  796. ( ((q31_t)sum ) ) ));
  797. }
  798. /*
  799. * @brief C custom defined SMLADX for M3 and M0 processors
  800. */
  801. static __INLINE uint32_t __SMLADX(
  802. uint32_t x,
  803. uint32_t y,
  804. uint32_t sum)
  805. {
  806. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  807. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  808. ( ((q31_t)sum ) ) ));
  809. }
  810. /*
  811. * @brief C custom defined SMLSDX for M3 and M0 processors
  812. */
  813. static __INLINE uint32_t __SMLSDX(
  814. uint32_t x,
  815. uint32_t y,
  816. uint32_t sum)
  817. {
  818. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
  819. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  820. ( ((q31_t)sum ) ) ));
  821. }
  822. /*
  823. * @brief C custom defined SMLALD for M3 and M0 processors
  824. */
  825. static __INLINE uint64_t __SMLALD(
  826. uint32_t x,
  827. uint32_t y,
  828. uint64_t sum)
  829. {
  830. /* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */
  831. return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  832. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
  833. ( ((q63_t)sum ) ) ));
  834. }
  835. /*
  836. * @brief C custom defined SMLALDX for M3 and M0 processors
  837. */
  838. static __INLINE uint64_t __SMLALDX(
  839. uint32_t x,
  840. uint32_t y,
  841. uint64_t sum)
  842. {
  843. /* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */
  844. return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  845. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  846. ( ((q63_t)sum ) ) ));
  847. }
  848. /*
  849. * @brief C custom defined SMUAD for M3 and M0 processors
  850. */
  851. static __INLINE uint32_t __SMUAD(
  852. uint32_t x,
  853. uint32_t y)
  854. {
  855. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  856. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
  857. }
  858. /*
  859. * @brief C custom defined SMUSD for M3 and M0 processors
  860. */
  861. static __INLINE uint32_t __SMUSD(
  862. uint32_t x,
  863. uint32_t y)
  864. {
  865. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) -
  866. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
  867. }
  868. /*
  869. * @brief C custom defined SXTB16 for M3 and M0 processors
  870. */
  871. static __INLINE uint32_t __SXTB16(
  872. uint32_t x)
  873. {
  874. return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) |
  875. ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) ));
  876. }
  877. #endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
  878. /**
  879. * @brief Instance structure for the Q7 FIR filter.
  880. */
  881. typedef struct
  882. {
  883. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  884. q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  885. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  886. } arm_fir_instance_q7;
  887. /**
  888. * @brief Instance structure for the Q15 FIR filter.
  889. */
  890. typedef struct
  891. {
  892. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  893. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  894. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  895. } arm_fir_instance_q15;
  896. /**
  897. * @brief Instance structure for the Q31 FIR filter.
  898. */
  899. typedef struct
  900. {
  901. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  902. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  903. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  904. } arm_fir_instance_q31;
  905. /**
  906. * @brief Instance structure for the floating-point FIR filter.
  907. */
  908. typedef struct
  909. {
  910. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  911. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  912. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  913. } arm_fir_instance_f32;
  914. /**
  915. * @brief Processing function for the Q7 FIR filter.
  916. * @param[in] S points to an instance of the Q7 FIR filter structure.
  917. * @param[in] pSrc points to the block of input data.
  918. * @param[out] pDst points to the block of output data.
  919. * @param[in] blockSize number of samples to process.
  920. */
  921. void arm_fir_q7(
  922. const arm_fir_instance_q7 * S,
  923. q7_t * pSrc,
  924. q7_t * pDst,
  925. uint32_t blockSize);
  926. /**
  927. * @brief Initialization function for the Q7 FIR filter.
  928. * @param[in,out] S points to an instance of the Q7 FIR structure.
  929. * @param[in] numTaps Number of filter coefficients in the filter.
  930. * @param[in] pCoeffs points to the filter coefficients.
  931. * @param[in] pState points to the state buffer.
  932. * @param[in] blockSize number of samples that are processed.
  933. */
  934. void arm_fir_init_q7(
  935. arm_fir_instance_q7 * S,
  936. uint16_t numTaps,
  937. q7_t * pCoeffs,
  938. q7_t * pState,
  939. uint32_t blockSize);
  940. /**
  941. * @brief Processing function for the Q15 FIR filter.
  942. * @param[in] S points to an instance of the Q15 FIR structure.
  943. * @param[in] pSrc points to the block of input data.
  944. * @param[out] pDst points to the block of output data.
  945. * @param[in] blockSize number of samples to process.
  946. */
  947. void arm_fir_q15(
  948. const arm_fir_instance_q15 * S,
  949. q15_t * pSrc,
  950. q15_t * pDst,
  951. uint32_t blockSize);
  952. /**
  953. * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
  954. * @param[in] S points to an instance of the Q15 FIR filter structure.
  955. * @param[in] pSrc points to the block of input data.
  956. * @param[out] pDst points to the block of output data.
  957. * @param[in] blockSize number of samples to process.
  958. */
  959. void arm_fir_fast_q15(
  960. const arm_fir_instance_q15 * S,
  961. q15_t * pSrc,
  962. q15_t * pDst,
  963. uint32_t blockSize);
  964. /**
  965. * @brief Initialization function for the Q15 FIR filter.
  966. * @param[in,out] S points to an instance of the Q15 FIR filter structure.
  967. * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
  968. * @param[in] pCoeffs points to the filter coefficients.
  969. * @param[in] pState points to the state buffer.
  970. * @param[in] blockSize number of samples that are processed at a time.
  971. * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
  972. * <code>numTaps</code> is not a supported value.
  973. */
  974. arm_status arm_fir_init_q15(
  975. arm_fir_instance_q15 * S,
  976. uint16_t numTaps,
  977. q15_t * pCoeffs,
  978. q15_t * pState,
  979. uint32_t blockSize);
  980. /**
  981. * @brief Processing function for the Q31 FIR filter.
  982. * @param[in] S points to an instance of the Q31 FIR filter structure.
  983. * @param[in] pSrc points to the block of input data.
  984. * @param[out] pDst points to the block of output data.
  985. * @param[in] blockSize number of samples to process.
  986. */
  987. void arm_fir_q31(
  988. const arm_fir_instance_q31 * S,
  989. q31_t * pSrc,
  990. q31_t * pDst,
  991. uint32_t blockSize);
  992. /**
  993. * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
  994. * @param[in] S points to an instance of the Q31 FIR structure.
  995. * @param[in] pSrc points to the block of input data.
  996. * @param[out] pDst points to the block of output data.
  997. * @param[in] blockSize number of samples to process.
  998. */
  999. void arm_fir_fast_q31(
  1000. const arm_fir_instance_q31 * S,
  1001. q31_t * pSrc,
  1002. q31_t * pDst,
  1003. uint32_t blockSize);
  1004. /**
  1005. * @brief Initialization function for the Q31 FIR filter.
  1006. * @param[in,out] S points to an instance of the Q31 FIR structure.
  1007. * @param[in] numTaps Number of filter coefficients in the filter.
  1008. * @param[in] pCoeffs points to the filter coefficients.
  1009. * @param[in] pState points to the state buffer.
  1010. * @param[in] blockSize number of samples that are processed at a time.
  1011. */
  1012. void arm_fir_init_q31(
  1013. arm_fir_instance_q31 * S,
  1014. uint16_t numTaps,
  1015. q31_t * pCoeffs,
  1016. q31_t * pState,
  1017. uint32_t blockSize);
  1018. /**
  1019. * @brief Processing function for the floating-point FIR filter.
  1020. * @param[in] S points to an instance of the floating-point FIR structure.
  1021. * @param[in] pSrc points to the block of input data.
  1022. * @param[out] pDst points to the block of output data.
  1023. * @param[in] blockSize number of samples to process.
  1024. */
  1025. void arm_fir_f32(
  1026. const arm_fir_instance_f32 * S,
  1027. float32_t * pSrc,
  1028. float32_t * pDst,
  1029. uint32_t blockSize);
  1030. /**
  1031. * @brief Initialization function for the floating-point FIR filter.
  1032. * @param[in,out] S points to an instance of the floating-point FIR filter structure.
  1033. * @param[in] numTaps Number of filter coefficients in the filter.
  1034. * @param[in] pCoeffs points to the filter coefficients.
  1035. * @param[in] pState points to the state buffer.
  1036. * @param[in] blockSize number of samples that are processed at a time.
  1037. */
  1038. void arm_fir_init_f32(
  1039. arm_fir_instance_f32 * S,
  1040. uint16_t numTaps,
  1041. float32_t * pCoeffs,
  1042. float32_t * pState,
  1043. uint32_t blockSize);
  1044. /**
  1045. * @brief Instance structure for the Q15 Biquad cascade filter.
  1046. */
  1047. typedef struct
  1048. {
  1049. int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1050. q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1051. q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1052. int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1053. } arm_biquad_casd_df1_inst_q15;
  1054. /**
  1055. * @brief Instance structure for the Q31 Biquad cascade filter.
  1056. */
  1057. typedef struct
  1058. {
  1059. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1060. q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1061. q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1062. uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1063. } arm_biquad_casd_df1_inst_q31;
  1064. /**
  1065. * @brief Instance structure for the floating-point Biquad cascade filter.
  1066. */
  1067. typedef struct
  1068. {
  1069. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1070. float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1071. float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1072. } arm_biquad_casd_df1_inst_f32;
  1073. /**
  1074. * @brief Processing function for the Q15 Biquad cascade filter.
  1075. * @param[in] S points to an instance of the Q15 Biquad cascade structure.
  1076. * @param[in] pSrc points to the block of input data.
  1077. * @param[out] pDst points to the block of output data.
  1078. * @param[in] blockSize number of samples to process.
  1079. */
  1080. void arm_biquad_cascade_df1_q15(
  1081. const arm_biquad_casd_df1_inst_q15 * S,
  1082. q15_t * pSrc,
  1083. q15_t * pDst,
  1084. uint32_t blockSize);
  1085. /**
  1086. * @brief Initialization function for the Q15 Biquad cascade filter.
  1087. * @param[in,out] S points to an instance of the Q15 Biquad cascade structure.
  1088. * @param[in] numStages number of 2nd order stages in the filter.
  1089. * @param[in] pCoeffs points to the filter coefficients.
  1090. * @param[in] pState points to the state buffer.
  1091. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1092. */
  1093. void arm_biquad_cascade_df1_init_q15(
  1094. arm_biquad_casd_df1_inst_q15 * S,
  1095. uint8_t numStages,
  1096. q15_t * pCoeffs,
  1097. q15_t * pState,
  1098. int8_t postShift);
  1099. /**
  1100. * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1101. * @param[in] S points to an instance of the Q15 Biquad cascade structure.
  1102. * @param[in] pSrc points to the block of input data.
  1103. * @param[out] pDst points to the block of output data.
  1104. * @param[in] blockSize number of samples to process.
  1105. */
  1106. void arm_biquad_cascade_df1_fast_q15(
  1107. const arm_biquad_casd_df1_inst_q15 * S,
  1108. q15_t * pSrc,
  1109. q15_t * pDst,
  1110. uint32_t blockSize);
  1111. /**
  1112. * @brief Processing function for the Q31 Biquad cascade filter
  1113. * @param[in] S points to an instance of the Q31 Biquad cascade structure.
  1114. * @param[in] pSrc points to the block of input data.
  1115. * @param[out] pDst points to the block of output data.
  1116. * @param[in] blockSize number of samples to process.
  1117. */
  1118. void arm_biquad_cascade_df1_q31(
  1119. const arm_biquad_casd_df1_inst_q31 * S,
  1120. q31_t * pSrc,
  1121. q31_t * pDst,
  1122. uint32_t blockSize);
  1123. /**
  1124. * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1125. * @param[in] S points to an instance of the Q31 Biquad cascade structure.
  1126. * @param[in] pSrc points to the block of input data.
  1127. * @param[out] pDst points to the block of output data.
  1128. * @param[in] blockSize number of samples to process.
  1129. */
  1130. void arm_biquad_cascade_df1_fast_q31(
  1131. const arm_biquad_casd_df1_inst_q31 * S,
  1132. q31_t * pSrc,
  1133. q31_t * pDst,
  1134. uint32_t blockSize);
  1135. /**
  1136. * @brief Initialization function for the Q31 Biquad cascade filter.
  1137. * @param[in,out] S points to an instance of the Q31 Biquad cascade structure.
  1138. * @param[in] numStages number of 2nd order stages in the filter.
  1139. * @param[in] pCoeffs points to the filter coefficients.
  1140. * @param[in] pState points to the state buffer.
  1141. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1142. */
  1143. void arm_biquad_cascade_df1_init_q31(
  1144. arm_biquad_casd_df1_inst_q31 * S,
  1145. uint8_t numStages,
  1146. q31_t * pCoeffs,
  1147. q31_t * pState,
  1148. int8_t postShift);
  1149. /**
  1150. * @brief Processing function for the floating-point Biquad cascade filter.
  1151. * @param[in] S points to an instance of the floating-point Biquad cascade structure.
  1152. * @param[in] pSrc points to the block of input data.
  1153. * @param[out] pDst points to the block of output data.
  1154. * @param[in] blockSize number of samples to process.
  1155. */
  1156. void arm_biquad_cascade_df1_f32(
  1157. const arm_biquad_casd_df1_inst_f32 * S,
  1158. float32_t * pSrc,
  1159. float32_t * pDst,
  1160. uint32_t blockSize);
  1161. /**
  1162. * @brief Initialization function for the floating-point Biquad cascade filter.
  1163. * @param[in,out] S points to an instance of the floating-point Biquad cascade structure.
  1164. * @param[in] numStages number of 2nd order stages in the filter.
  1165. * @param[in] pCoeffs points to the filter coefficients.
  1166. * @param[in] pState points to the state buffer.
  1167. */
  1168. void arm_biquad_cascade_df1_init_f32(
  1169. arm_biquad_casd_df1_inst_f32 * S,
  1170. uint8_t numStages,
  1171. float32_t * pCoeffs,
  1172. float32_t * pState);
  1173. /**
  1174. * @brief Instance structure for the floating-point matrix structure.
  1175. */
  1176. typedef struct
  1177. {
  1178. uint16_t numRows; /**< number of rows of the matrix. */
  1179. uint16_t numCols; /**< number of columns of the matrix. */
  1180. float32_t *pData; /**< points to the data of the matrix. */
  1181. } arm_matrix_instance_f32;
  1182. /**
  1183. * @brief Instance structure for the floating-point matrix structure.
  1184. */
  1185. typedef struct
  1186. {
  1187. uint16_t numRows; /**< number of rows of the matrix. */
  1188. uint16_t numCols; /**< number of columns of the matrix. */
  1189. float64_t *pData; /**< points to the data of the matrix. */
  1190. } arm_matrix_instance_f64;
  1191. /**
  1192. * @brief Instance structure for the Q15 matrix structure.
  1193. */
  1194. typedef struct
  1195. {
  1196. uint16_t numRows; /**< number of rows of the matrix. */
  1197. uint16_t numCols; /**< number of columns of the matrix. */
  1198. q15_t *pData; /**< points to the data of the matrix. */
  1199. } arm_matrix_instance_q15;
  1200. /**
  1201. * @brief Instance structure for the Q31 matrix structure.
  1202. */
  1203. typedef struct
  1204. {
  1205. uint16_t numRows; /**< number of rows of the matrix. */
  1206. uint16_t numCols; /**< number of columns of the matrix. */
  1207. q31_t *pData; /**< points to the data of the matrix. */
  1208. } arm_matrix_instance_q31;
  1209. /**
  1210. * @brief Floating-point matrix addition.
  1211. * @param[in] pSrcA points to the first input matrix structure
  1212. * @param[in] pSrcB points to the second input matrix structure
  1213. * @param[out] pDst points to output matrix structure
  1214. * @return The function returns either
  1215. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1216. */
  1217. arm_status arm_mat_add_f32(
  1218. const arm_matrix_instance_f32 * pSrcA,
  1219. const arm_matrix_instance_f32 * pSrcB,
  1220. arm_matrix_instance_f32 * pDst);
  1221. /**
  1222. * @brief Q15 matrix addition.
  1223. * @param[in] pSrcA points to the first input matrix structure
  1224. * @param[in] pSrcB points to the second input matrix structure
  1225. * @param[out] pDst points to output matrix structure
  1226. * @return The function returns either
  1227. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1228. */
  1229. arm_status arm_mat_add_q15(
  1230. const arm_matrix_instance_q15 * pSrcA,
  1231. const arm_matrix_instance_q15 * pSrcB,
  1232. arm_matrix_instance_q15 * pDst);
  1233. /**
  1234. * @brief Q31 matrix addition.
  1235. * @param[in] pSrcA points to the first input matrix structure
  1236. * @param[in] pSrcB points to the second input matrix structure
  1237. * @param[out] pDst points to output matrix structure
  1238. * @return The function returns either
  1239. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1240. */
  1241. arm_status arm_mat_add_q31(
  1242. const arm_matrix_instance_q31 * pSrcA,
  1243. const arm_matrix_instance_q31 * pSrcB,
  1244. arm_matrix_instance_q31 * pDst);
  1245. /**
  1246. * @brief Floating-point, complex, matrix multiplication.
  1247. * @param[in] pSrcA points to the first input matrix structure
  1248. * @param[in] pSrcB points to the second input matrix structure
  1249. * @param[out] pDst points to output matrix structure
  1250. * @return The function returns either
  1251. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1252. */
  1253. arm_status arm_mat_cmplx_mult_f32(
  1254. const arm_matrix_instance_f32 * pSrcA,
  1255. const arm_matrix_instance_f32 * pSrcB,
  1256. arm_matrix_instance_f32 * pDst);
  1257. /**
  1258. * @brief Q15, complex, matrix multiplication.
  1259. * @param[in] pSrcA points to the first input matrix structure
  1260. * @param[in] pSrcB points to the second input matrix structure
  1261. * @param[out] pDst points to output matrix structure
  1262. * @return The function returns either
  1263. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1264. */
  1265. arm_status arm_mat_cmplx_mult_q15(
  1266. const arm_matrix_instance_q15 * pSrcA,
  1267. const arm_matrix_instance_q15 * pSrcB,
  1268. arm_matrix_instance_q15 * pDst,
  1269. q15_t * pScratch);
  1270. /**
  1271. * @brief Q31, complex, matrix multiplication.
  1272. * @param[in] pSrcA points to the first input matrix structure
  1273. * @param[in] pSrcB points to the second input matrix structure
  1274. * @param[out] pDst points to output matrix structure
  1275. * @return The function returns either
  1276. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1277. */
  1278. arm_status arm_mat_cmplx_mult_q31(
  1279. const arm_matrix_instance_q31 * pSrcA,
  1280. const arm_matrix_instance_q31 * pSrcB,
  1281. arm_matrix_instance_q31 * pDst);
  1282. /**
  1283. * @brief Floating-point matrix transpose.
  1284. * @param[in] pSrc points to the input matrix
  1285. * @param[out] pDst points to the output matrix
  1286. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1287. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1288. */
  1289. arm_status arm_mat_trans_f32(
  1290. const arm_matrix_instance_f32 * pSrc,
  1291. arm_matrix_instance_f32 * pDst);
  1292. /**
  1293. * @brief Q15 matrix transpose.
  1294. * @param[in] pSrc points to the input matrix
  1295. * @param[out] pDst points to the output matrix
  1296. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1297. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1298. */
  1299. arm_status arm_mat_trans_q15(
  1300. const arm_matrix_instance_q15 * pSrc,
  1301. arm_matrix_instance_q15 * pDst);
  1302. /**
  1303. * @brief Q31 matrix transpose.
  1304. * @param[in] pSrc points to the input matrix
  1305. * @param[out] pDst points to the output matrix
  1306. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1307. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1308. */
  1309. arm_status arm_mat_trans_q31(
  1310. const arm_matrix_instance_q31 * pSrc,
  1311. arm_matrix_instance_q31 * pDst);
  1312. /**
  1313. * @brief Floating-point matrix multiplication
  1314. * @param[in] pSrcA points to the first input matrix structure
  1315. * @param[in] pSrcB points to the second input matrix structure
  1316. * @param[out] pDst points to output matrix structure
  1317. * @return The function returns either
  1318. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1319. */
  1320. arm_status arm_mat_mult_f32(
  1321. const arm_matrix_instance_f32 * pSrcA,
  1322. const arm_matrix_instance_f32 * pSrcB,
  1323. arm_matrix_instance_f32 * pDst);
  1324. /**
  1325. * @brief Q15 matrix multiplication
  1326. * @param[in] pSrcA points to the first input matrix structure
  1327. * @param[in] pSrcB points to the second input matrix structure
  1328. * @param[out] pDst points to output matrix structure
  1329. * @param[in] pState points to the array for storing intermediate results
  1330. * @return The function returns either
  1331. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1332. */
  1333. arm_status arm_mat_mult_q15(
  1334. const arm_matrix_instance_q15 * pSrcA,
  1335. const arm_matrix_instance_q15 * pSrcB,
  1336. arm_matrix_instance_q15 * pDst,
  1337. q15_t * pState);
  1338. /**
  1339. * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1340. * @param[in] pSrcA points to the first input matrix structure
  1341. * @param[in] pSrcB points to the second input matrix structure
  1342. * @param[out] pDst points to output matrix structure
  1343. * @param[in] pState points to the array for storing intermediate results
  1344. * @return The function returns either
  1345. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1346. */
  1347. arm_status arm_mat_mult_fast_q15(
  1348. const arm_matrix_instance_q15 * pSrcA,
  1349. const arm_matrix_instance_q15 * pSrcB,
  1350. arm_matrix_instance_q15 * pDst,
  1351. q15_t * pState);
  1352. /**
  1353. * @brief Q31 matrix multiplication
  1354. * @param[in] pSrcA points to the first input matrix structure
  1355. * @param[in] pSrcB points to the second input matrix structure
  1356. * @param[out] pDst points to output matrix structure
  1357. * @return The function returns either
  1358. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1359. */
  1360. arm_status arm_mat_mult_q31(
  1361. const arm_matrix_instance_q31 * pSrcA,
  1362. const arm_matrix_instance_q31 * pSrcB,
  1363. arm_matrix_instance_q31 * pDst);
  1364. /**
  1365. * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1366. * @param[in] pSrcA points to the first input matrix structure
  1367. * @param[in] pSrcB points to the second input matrix structure
  1368. * @param[out] pDst points to output matrix structure
  1369. * @return The function returns either
  1370. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1371. */
  1372. arm_status arm_mat_mult_fast_q31(
  1373. const arm_matrix_instance_q31 * pSrcA,
  1374. const arm_matrix_instance_q31 * pSrcB,
  1375. arm_matrix_instance_q31 * pDst);
  1376. /**
  1377. * @brief Floating-point matrix subtraction
  1378. * @param[in] pSrcA points to the first input matrix structure
  1379. * @param[in] pSrcB points to the second input matrix structure
  1380. * @param[out] pDst points to output matrix structure
  1381. * @return The function returns either
  1382. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1383. */
  1384. arm_status arm_mat_sub_f32(
  1385. const arm_matrix_instance_f32 * pSrcA,
  1386. const arm_matrix_instance_f32 * pSrcB,
  1387. arm_matrix_instance_f32 * pDst);
  1388. /**
  1389. * @brief Q15 matrix subtraction
  1390. * @param[in] pSrcA points to the first input matrix structure
  1391. * @param[in] pSrcB points to the second input matrix structure
  1392. * @param[out] pDst points to output matrix structure
  1393. * @return The function returns either
  1394. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1395. */
  1396. arm_status arm_mat_sub_q15(
  1397. const arm_matrix_instance_q15 * pSrcA,
  1398. const arm_matrix_instance_q15 * pSrcB,
  1399. arm_matrix_instance_q15 * pDst);
  1400. /**
  1401. * @brief Q31 matrix subtraction
  1402. * @param[in] pSrcA points to the first input matrix structure
  1403. * @param[in] pSrcB points to the second input matrix structure
  1404. * @param[out] pDst points to output matrix structure
  1405. * @return The function returns either
  1406. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1407. */
  1408. arm_status arm_mat_sub_q31(
  1409. const arm_matrix_instance_q31 * pSrcA,
  1410. const arm_matrix_instance_q31 * pSrcB,
  1411. arm_matrix_instance_q31 * pDst);
  1412. /**
  1413. * @brief Floating-point matrix scaling.
  1414. * @param[in] pSrc points to the input matrix
  1415. * @param[in] scale scale factor
  1416. * @param[out] pDst points to the output matrix
  1417. * @return The function returns either
  1418. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1419. */
  1420. arm_status arm_mat_scale_f32(
  1421. const arm_matrix_instance_f32 * pSrc,
  1422. float32_t scale,
  1423. arm_matrix_instance_f32 * pDst);
  1424. /**
  1425. * @brief Q15 matrix scaling.
  1426. * @param[in] pSrc points to input matrix
  1427. * @param[in] scaleFract fractional portion of the scale factor
  1428. * @param[in] shift number of bits to shift the result by
  1429. * @param[out] pDst points to output matrix
  1430. * @return The function returns either
  1431. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1432. */
  1433. arm_status arm_mat_scale_q15(
  1434. const arm_matrix_instance_q15 * pSrc,
  1435. q15_t scaleFract,
  1436. int32_t shift,
  1437. arm_matrix_instance_q15 * pDst);
  1438. /**
  1439. * @brief Q31 matrix scaling.
  1440. * @param[in] pSrc points to input matrix
  1441. * @param[in] scaleFract fractional portion of the scale factor
  1442. * @param[in] shift number of bits to shift the result by
  1443. * @param[out] pDst points to output matrix structure
  1444. * @return The function returns either
  1445. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1446. */
  1447. arm_status arm_mat_scale_q31(
  1448. const arm_matrix_instance_q31 * pSrc,
  1449. q31_t scaleFract,
  1450. int32_t shift,
  1451. arm_matrix_instance_q31 * pDst);
  1452. /**
  1453. * @brief Q31 matrix initialization.
  1454. * @param[in,out] S points to an instance of the floating-point matrix structure.
  1455. * @param[in] nRows number of rows in the matrix.
  1456. * @param[in] nColumns number of columns in the matrix.
  1457. * @param[in] pData points to the matrix data array.
  1458. */
  1459. void arm_mat_init_q31(
  1460. arm_matrix_instance_q31 * S,
  1461. uint16_t nRows,
  1462. uint16_t nColumns,
  1463. q31_t * pData);
  1464. /**
  1465. * @brief Q15 matrix initialization.
  1466. * @param[in,out] S points to an instance of the floating-point matrix structure.
  1467. * @param[in] nRows number of rows in the matrix.
  1468. * @param[in] nColumns number of columns in the matrix.
  1469. * @param[in] pData points to the matrix data array.
  1470. */
  1471. void arm_mat_init_q15(
  1472. arm_matrix_instance_q15 * S,
  1473. uint16_t nRows,
  1474. uint16_t nColumns,
  1475. q15_t * pData);
  1476. /**
  1477. * @brief Floating-point matrix initialization.
  1478. * @param[in,out] S points to an instance of the floating-point matrix structure.
  1479. * @param[in] nRows number of rows in the matrix.
  1480. * @param[in] nColumns number of columns in the matrix.
  1481. * @param[in] pData points to the matrix data array.
  1482. */
  1483. void arm_mat_init_f32(
  1484. arm_matrix_instance_f32 * S,
  1485. uint16_t nRows,
  1486. uint16_t nColumns,
  1487. float32_t * pData);
  1488. /**
  1489. * @brief Instance structure for the Q15 PID Control.
  1490. */
  1491. typedef struct
  1492. {
  1493. q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1494. #ifdef ARM_MATH_CM0_FAMILY
  1495. q15_t A1;
  1496. q15_t A2;
  1497. #else
  1498. q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
  1499. #endif
  1500. q15_t state[3]; /**< The state array of length 3. */
  1501. q15_t Kp; /**< The proportional gain. */
  1502. q15_t Ki; /**< The integral gain. */
  1503. q15_t Kd; /**< The derivative gain. */
  1504. } arm_pid_instance_q15;
  1505. /**
  1506. * @brief Instance structure for the Q31 PID Control.
  1507. */
  1508. typedef struct
  1509. {
  1510. q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1511. q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1512. q31_t A2; /**< The derived gain, A2 = Kd . */
  1513. q31_t state[3]; /**< The state array of length 3. */
  1514. q31_t Kp; /**< The proportional gain. */
  1515. q31_t Ki; /**< The integral gain. */
  1516. q31_t Kd; /**< The derivative gain. */
  1517. } arm_pid_instance_q31;
  1518. /**
  1519. * @brief Instance structure for the floating-point PID Control.
  1520. */
  1521. typedef struct
  1522. {
  1523. float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1524. float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1525. float32_t A2; /**< The derived gain, A2 = Kd . */
  1526. float32_t state[3]; /**< The state array of length 3. */
  1527. float32_t Kp; /**< The proportional gain. */
  1528. float32_t Ki; /**< The integral gain. */
  1529. float32_t Kd; /**< The derivative gain. */
  1530. } arm_pid_instance_f32;
  1531. /**
  1532. * @brief Initialization function for the floating-point PID Control.
  1533. * @param[in,out] S points to an instance of the PID structure.
  1534. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1535. */
  1536. void arm_pid_init_f32(
  1537. arm_pid_instance_f32 * S,
  1538. int32_t resetStateFlag);
  1539. /**
  1540. * @brief Reset function for the floating-point PID Control.
  1541. * @param[in,out] S is an instance of the floating-point PID Control structure
  1542. */
  1543. void arm_pid_reset_f32(
  1544. arm_pid_instance_f32 * S);
  1545. /**
  1546. * @brief Initialization function for the Q31 PID Control.
  1547. * @param[in,out] S points to an instance of the Q15 PID structure.
  1548. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1549. */
  1550. void arm_pid_init_q31(
  1551. arm_pid_instance_q31 * S,
  1552. int32_t resetStateFlag);
  1553. /**
  1554. * @brief Reset function for the Q31 PID Control.
  1555. * @param[in,out] S points to an instance of the Q31 PID Control structure
  1556. */
  1557. void arm_pid_reset_q31(
  1558. arm_pid_instance_q31 * S);
  1559. /**
  1560. * @brief Initialization function for the Q15 PID Control.
  1561. * @param[in,out] S points to an instance of the Q15 PID structure.
  1562. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1563. */
  1564. void arm_pid_init_q15(
  1565. arm_pid_instance_q15 * S,
  1566. int32_t resetStateFlag);
  1567. /**
  1568. * @brief Reset function for the Q15 PID Control.
  1569. * @param[in,out] S points to an instance of the q15 PID Control structure
  1570. */
  1571. void arm_pid_reset_q15(
  1572. arm_pid_instance_q15 * S);
  1573. /**
  1574. * @brief Instance structure for the floating-point Linear Interpolate function.
  1575. */
  1576. typedef struct
  1577. {
  1578. uint32_t nValues; /**< nValues */
  1579. float32_t x1; /**< x1 */
  1580. float32_t xSpacing; /**< xSpacing */
  1581. float32_t *pYData; /**< pointer to the table of Y values */
  1582. } arm_linear_interp_instance_f32;
  1583. /**
  1584. * @brief Instance structure for the floating-point bilinear interpolation function.
  1585. */
  1586. typedef struct
  1587. {
  1588. uint16_t numRows; /**< number of rows in the data table. */
  1589. uint16_t numCols; /**< number of columns in the data table. */
  1590. float32_t *pData; /**< points to the data table. */
  1591. } arm_bilinear_interp_instance_f32;
  1592. /**
  1593. * @brief Instance structure for the Q31 bilinear interpolation function.
  1594. */
  1595. typedef struct
  1596. {
  1597. uint16_t numRows; /**< number of rows in the data table. */
  1598. uint16_t numCols; /**< number of columns in the data table. */
  1599. q31_t *pData; /**< points to the data table. */
  1600. } arm_bilinear_interp_instance_q31;
  1601. /**
  1602. * @brief Instance structure for the Q15 bilinear interpolation function.
  1603. */
  1604. typedef struct
  1605. {
  1606. uint16_t numRows; /**< number of rows in the data table. */
  1607. uint16_t numCols; /**< number of columns in the data table. */
  1608. q15_t *pData; /**< points to the data table. */
  1609. } arm_bilinear_interp_instance_q15;
  1610. /**
  1611. * @brief Instance structure for the Q15 bilinear interpolation function.
  1612. */
  1613. typedef struct
  1614. {
  1615. uint16_t numRows; /**< number of rows in the data table. */
  1616. uint16_t numCols; /**< number of columns in the data table. */
  1617. q7_t *pData; /**< points to the data table. */
  1618. } arm_bilinear_interp_instance_q7;
  1619. /**
  1620. * @brief Q7 vector multiplication.
  1621. * @param[in] pSrcA points to the first input vector
  1622. * @param[in] pSrcB points to the second input vector
  1623. * @param[out] pDst points to the output vector
  1624. * @param[in] blockSize number of samples in each vector
  1625. */
  1626. void arm_mult_q7(
  1627. q7_t * pSrcA,
  1628. q7_t * pSrcB,
  1629. q7_t * pDst,
  1630. uint32_t blockSize);
  1631. /**
  1632. * @brief Q15 vector multiplication.
  1633. * @param[in] pSrcA points to the first input vector
  1634. * @param[in] pSrcB points to the second input vector
  1635. * @param[out] pDst points to the output vector
  1636. * @param[in] blockSize number of samples in each vector
  1637. */
  1638. void arm_mult_q15(
  1639. q15_t * pSrcA,
  1640. q15_t * pSrcB,
  1641. q15_t * pDst,
  1642. uint32_t blockSize);
  1643. /**
  1644. * @brief Q31 vector multiplication.
  1645. * @param[in] pSrcA points to the first input vector
  1646. * @param[in] pSrcB points to the second input vector
  1647. * @param[out] pDst points to the output vector
  1648. * @param[in] blockSize number of samples in each vector
  1649. */
  1650. void arm_mult_q31(
  1651. q31_t * pSrcA,
  1652. q31_t * pSrcB,
  1653. q31_t * pDst,
  1654. uint32_t blockSize);
  1655. /**
  1656. * @brief Floating-point vector multiplication.
  1657. * @param[in] pSrcA points to the first input vector
  1658. * @param[in] pSrcB points to the second input vector
  1659. * @param[out] pDst points to the output vector
  1660. * @param[in] blockSize number of samples in each vector
  1661. */
  1662. void arm_mult_f32(
  1663. float32_t * pSrcA,
  1664. float32_t * pSrcB,
  1665. float32_t * pDst,
  1666. uint32_t blockSize);
  1667. /**
  1668. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1669. */
  1670. typedef struct
  1671. {
  1672. uint16_t fftLen; /**< length of the FFT. */
  1673. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1674. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1675. q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
  1676. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1677. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1678. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1679. } arm_cfft_radix2_instance_q15;
  1680. /* Deprecated */
  1681. arm_status arm_cfft_radix2_init_q15(
  1682. arm_cfft_radix2_instance_q15 * S,
  1683. uint16_t fftLen,
  1684. uint8_t ifftFlag,
  1685. uint8_t bitReverseFlag);
  1686. /* Deprecated */
  1687. void arm_cfft_radix2_q15(
  1688. const arm_cfft_radix2_instance_q15 * S,
  1689. q15_t * pSrc);
  1690. /**
  1691. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1692. */
  1693. typedef struct
  1694. {
  1695. uint16_t fftLen; /**< length of the FFT. */
  1696. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1697. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1698. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  1699. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1700. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1701. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1702. } arm_cfft_radix4_instance_q15;
  1703. /* Deprecated */
  1704. arm_status arm_cfft_radix4_init_q15(
  1705. arm_cfft_radix4_instance_q15 * S,
  1706. uint16_t fftLen,
  1707. uint8_t ifftFlag,
  1708. uint8_t bitReverseFlag);
  1709. /* Deprecated */
  1710. void arm_cfft_radix4_q15(
  1711. const arm_cfft_radix4_instance_q15 * S,
  1712. q15_t * pSrc);
  1713. /**
  1714. * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
  1715. */
  1716. typedef struct
  1717. {
  1718. uint16_t fftLen; /**< length of the FFT. */
  1719. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1720. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1721. q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  1722. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1723. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1724. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1725. } arm_cfft_radix2_instance_q31;
  1726. /* Deprecated */
  1727. arm_status arm_cfft_radix2_init_q31(
  1728. arm_cfft_radix2_instance_q31 * S,
  1729. uint16_t fftLen,
  1730. uint8_t ifftFlag,
  1731. uint8_t bitReverseFlag);
  1732. /* Deprecated */
  1733. void arm_cfft_radix2_q31(
  1734. const arm_cfft_radix2_instance_q31 * S,
  1735. q31_t * pSrc);
  1736. /**
  1737. * @brief Instance structure for the Q31 CFFT/CIFFT function.
  1738. */
  1739. typedef struct
  1740. {
  1741. uint16_t fftLen; /**< length of the FFT. */
  1742. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1743. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1744. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  1745. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1746. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1747. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1748. } arm_cfft_radix4_instance_q31;
  1749. /* Deprecated */
  1750. void arm_cfft_radix4_q31(
  1751. const arm_cfft_radix4_instance_q31 * S,
  1752. q31_t * pSrc);
  1753. /* Deprecated */
  1754. arm_status arm_cfft_radix4_init_q31(
  1755. arm_cfft_radix4_instance_q31 * S,
  1756. uint16_t fftLen,
  1757. uint8_t ifftFlag,
  1758. uint8_t bitReverseFlag);
  1759. /**
  1760. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1761. */
  1762. typedef struct
  1763. {
  1764. uint16_t fftLen; /**< length of the FFT. */
  1765. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1766. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1767. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1768. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1769. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1770. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1771. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1772. } arm_cfft_radix2_instance_f32;
  1773. /* Deprecated */
  1774. arm_status arm_cfft_radix2_init_f32(
  1775. arm_cfft_radix2_instance_f32 * S,
  1776. uint16_t fftLen,
  1777. uint8_t ifftFlag,
  1778. uint8_t bitReverseFlag);
  1779. /* Deprecated */
  1780. void arm_cfft_radix2_f32(
  1781. const arm_cfft_radix2_instance_f32 * S,
  1782. float32_t * pSrc);
  1783. /**
  1784. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1785. */
  1786. typedef struct
  1787. {
  1788. uint16_t fftLen; /**< length of the FFT. */
  1789. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1790. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1791. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1792. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1793. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1794. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1795. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1796. } arm_cfft_radix4_instance_f32;
  1797. /* Deprecated */
  1798. arm_status arm_cfft_radix4_init_f32(
  1799. arm_cfft_radix4_instance_f32 * S,
  1800. uint16_t fftLen,
  1801. uint8_t ifftFlag,
  1802. uint8_t bitReverseFlag);
  1803. /* Deprecated */
  1804. void arm_cfft_radix4_f32(
  1805. const arm_cfft_radix4_instance_f32 * S,
  1806. float32_t * pSrc);
  1807. /**
  1808. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  1809. */
  1810. typedef struct
  1811. {
  1812. uint16_t fftLen; /**< length of the FFT. */
  1813. const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
  1814. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1815. uint16_t bitRevLength; /**< bit reversal table length. */
  1816. } arm_cfft_instance_q15;
  1817. void arm_cfft_q15(
  1818. const arm_cfft_instance_q15 * S,
  1819. q15_t * p1,
  1820. uint8_t ifftFlag,
  1821. uint8_t bitReverseFlag);
  1822. /**
  1823. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  1824. */
  1825. typedef struct
  1826. {
  1827. uint16_t fftLen; /**< length of the FFT. */
  1828. const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  1829. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1830. uint16_t bitRevLength; /**< bit reversal table length. */
  1831. } arm_cfft_instance_q31;
  1832. void arm_cfft_q31(
  1833. const arm_cfft_instance_q31 * S,
  1834. q31_t * p1,
  1835. uint8_t ifftFlag,
  1836. uint8_t bitReverseFlag);
  1837. /**
  1838. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1839. */
  1840. typedef struct
  1841. {
  1842. uint16_t fftLen; /**< length of the FFT. */
  1843. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1844. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1845. uint16_t bitRevLength; /**< bit reversal table length. */
  1846. } arm_cfft_instance_f32;
  1847. void arm_cfft_f32(
  1848. const arm_cfft_instance_f32 * S,
  1849. float32_t * p1,
  1850. uint8_t ifftFlag,
  1851. uint8_t bitReverseFlag);
  1852. /**
  1853. * @brief Instance structure for the Q15 RFFT/RIFFT function.
  1854. */
  1855. typedef struct
  1856. {
  1857. uint32_t fftLenReal; /**< length of the real FFT. */
  1858. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1859. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1860. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1861. q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1862. q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1863. const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  1864. } arm_rfft_instance_q15;
  1865. arm_status arm_rfft_init_q15(
  1866. arm_rfft_instance_q15 * S,
  1867. uint32_t fftLenReal,
  1868. uint32_t ifftFlagR,
  1869. uint32_t bitReverseFlag);
  1870. void arm_rfft_q15(
  1871. const arm_rfft_instance_q15 * S,
  1872. q15_t * pSrc,
  1873. q15_t * pDst);
  1874. /**
  1875. * @brief Instance structure for the Q31 RFFT/RIFFT function.
  1876. */
  1877. typedef struct
  1878. {
  1879. uint32_t fftLenReal; /**< length of the real FFT. */
  1880. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1881. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1882. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1883. q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1884. q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1885. const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  1886. } arm_rfft_instance_q31;
  1887. arm_status arm_rfft_init_q31(
  1888. arm_rfft_instance_q31 * S,
  1889. uint32_t fftLenReal,
  1890. uint32_t ifftFlagR,
  1891. uint32_t bitReverseFlag);
  1892. void arm_rfft_q31(
  1893. const arm_rfft_instance_q31 * S,
  1894. q31_t * pSrc,
  1895. q31_t * pDst);
  1896. /**
  1897. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1898. */
  1899. typedef struct
  1900. {
  1901. uint32_t fftLenReal; /**< length of the real FFT. */
  1902. uint16_t fftLenBy2; /**< length of the complex FFT. */
  1903. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1904. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1905. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1906. float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1907. float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1908. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1909. } arm_rfft_instance_f32;
  1910. arm_status arm_rfft_init_f32(
  1911. arm_rfft_instance_f32 * S,
  1912. arm_cfft_radix4_instance_f32 * S_CFFT,
  1913. uint32_t fftLenReal,
  1914. uint32_t ifftFlagR,
  1915. uint32_t bitReverseFlag);
  1916. void arm_rfft_f32(
  1917. const arm_rfft_instance_f32 * S,
  1918. float32_t * pSrc,
  1919. float32_t * pDst);
  1920. /**
  1921. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1922. */
  1923. typedef struct
  1924. {
  1925. arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
  1926. uint16_t fftLenRFFT; /**< length of the real sequence */
  1927. float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  1928. } arm_rfft_fast_instance_f32 ;
  1929. arm_status arm_rfft_fast_init_f32 (
  1930. arm_rfft_fast_instance_f32 * S,
  1931. uint16_t fftLen);
  1932. void arm_rfft_fast_f32(
  1933. arm_rfft_fast_instance_f32 * S,
  1934. float32_t * p, float32_t * pOut,
  1935. uint8_t ifftFlag);
  1936. /**
  1937. * @brief Instance structure for the floating-point DCT4/IDCT4 function.
  1938. */
  1939. typedef struct
  1940. {
  1941. uint16_t N; /**< length of the DCT4. */
  1942. uint16_t Nby2; /**< half of the length of the DCT4. */
  1943. float32_t normalize; /**< normalizing factor. */
  1944. float32_t *pTwiddle; /**< points to the twiddle factor table. */
  1945. float32_t *pCosFactor; /**< points to the cosFactor table. */
  1946. arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
  1947. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1948. } arm_dct4_instance_f32;
  1949. /**
  1950. * @brief Initialization function for the floating-point DCT4/IDCT4.
  1951. * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure.
  1952. * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
  1953. * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
  1954. * @param[in] N length of the DCT4.
  1955. * @param[in] Nby2 half of the length of the DCT4.
  1956. * @param[in] normalize normalizing factor.
  1957. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported transform length.
  1958. */
  1959. arm_status arm_dct4_init_f32(
  1960. arm_dct4_instance_f32 * S,
  1961. arm_rfft_instance_f32 * S_RFFT,
  1962. arm_cfft_radix4_instance_f32 * S_CFFT,
  1963. uint16_t N,
  1964. uint16_t Nby2,
  1965. float32_t normalize);
  1966. /**
  1967. * @brief Processing function for the floating-point DCT4/IDCT4.
  1968. * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure.
  1969. * @param[in] pState points to state buffer.
  1970. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  1971. */
  1972. void arm_dct4_f32(
  1973. const arm_dct4_instance_f32 * S,
  1974. float32_t * pState,
  1975. float32_t * pInlineBuffer);
  1976. /**
  1977. * @brief Instance structure for the Q31 DCT4/IDCT4 function.
  1978. */
  1979. typedef struct
  1980. {
  1981. uint16_t N; /**< length of the DCT4. */
  1982. uint16_t Nby2; /**< half of the length of the DCT4. */
  1983. q31_t normalize; /**< normalizing factor. */
  1984. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  1985. q31_t *pCosFactor; /**< points to the cosFactor table. */
  1986. arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
  1987. arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  1988. } arm_dct4_instance_q31;
  1989. /**
  1990. * @brief Initialization function for the Q31 DCT4/IDCT4.
  1991. * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure.
  1992. * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure
  1993. * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure
  1994. * @param[in] N length of the DCT4.
  1995. * @param[in] Nby2 half of the length of the DCT4.
  1996. * @param[in] normalize normalizing factor.
  1997. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  1998. */
  1999. arm_status arm_dct4_init_q31(
  2000. arm_dct4_instance_q31 * S,
  2001. arm_rfft_instance_q31 * S_RFFT,
  2002. arm_cfft_radix4_instance_q31 * S_CFFT,
  2003. uint16_t N,
  2004. uint16_t Nby2,
  2005. q31_t normalize);
  2006. /**
  2007. * @brief Processing function for the Q31 DCT4/IDCT4.
  2008. * @param[in] S points to an instance of the Q31 DCT4 structure.
  2009. * @param[in] pState points to state buffer.
  2010. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  2011. */
  2012. void arm_dct4_q31(
  2013. const arm_dct4_instance_q31 * S,
  2014. q31_t * pState,
  2015. q31_t * pInlineBuffer);
  2016. /**
  2017. * @brief Instance structure for the Q15 DCT4/IDCT4 function.
  2018. */
  2019. typedef struct
  2020. {
  2021. uint16_t N; /**< length of the DCT4. */
  2022. uint16_t Nby2; /**< half of the length of the DCT4. */
  2023. q15_t normalize; /**< normalizing factor. */
  2024. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  2025. q15_t *pCosFactor; /**< points to the cosFactor table. */
  2026. arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
  2027. arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  2028. } arm_dct4_instance_q15;
  2029. /**
  2030. * @brief Initialization function for the Q15 DCT4/IDCT4.
  2031. * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure.
  2032. * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
  2033. * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
  2034. * @param[in] N length of the DCT4.
  2035. * @param[in] Nby2 half of the length of the DCT4.
  2036. * @param[in] normalize normalizing factor.
  2037. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  2038. */
  2039. arm_status arm_dct4_init_q15(
  2040. arm_dct4_instance_q15 * S,
  2041. arm_rfft_instance_q15 * S_RFFT,
  2042. arm_cfft_radix4_instance_q15 * S_CFFT,
  2043. uint16_t N,
  2044. uint16_t Nby2,
  2045. q15_t normalize);
  2046. /**
  2047. * @brief Processing function for the Q15 DCT4/IDCT4.
  2048. * @param[in] S points to an instance of the Q15 DCT4 structure.
  2049. * @param[in] pState points to state buffer.
  2050. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  2051. */
  2052. void arm_dct4_q15(
  2053. const arm_dct4_instance_q15 * S,
  2054. q15_t * pState,
  2055. q15_t * pInlineBuffer);
  2056. /**
  2057. * @brief Floating-point vector addition.
  2058. * @param[in] pSrcA points to the first input vector
  2059. * @param[in] pSrcB points to the second input vector
  2060. * @param[out] pDst points to the output vector
  2061. * @param[in] blockSize number of samples in each vector
  2062. */
  2063. void arm_add_f32(
  2064. float32_t * pSrcA,
  2065. float32_t * pSrcB,
  2066. float32_t * pDst,
  2067. uint32_t blockSize);
  2068. /**
  2069. * @brief Q7 vector addition.
  2070. * @param[in] pSrcA points to the first input vector
  2071. * @param[in] pSrcB points to the second input vector
  2072. * @param[out] pDst points to the output vector
  2073. * @param[in] blockSize number of samples in each vector
  2074. */
  2075. void arm_add_q7(
  2076. q7_t * pSrcA,
  2077. q7_t * pSrcB,
  2078. q7_t * pDst,
  2079. uint32_t blockSize);
  2080. /**
  2081. * @brief Q15 vector addition.
  2082. * @param[in] pSrcA points to the first input vector
  2083. * @param[in] pSrcB points to the second input vector
  2084. * @param[out] pDst points to the output vector
  2085. * @param[in] blockSize number of samples in each vector
  2086. */
  2087. void arm_add_q15(
  2088. q15_t * pSrcA,
  2089. q15_t * pSrcB,
  2090. q15_t * pDst,
  2091. uint32_t blockSize);
  2092. /**
  2093. * @brief Q31 vector addition.
  2094. * @param[in] pSrcA points to the first input vector
  2095. * @param[in] pSrcB points to the second input vector
  2096. * @param[out] pDst points to the output vector
  2097. * @param[in] blockSize number of samples in each vector
  2098. */
  2099. void arm_add_q31(
  2100. q31_t * pSrcA,
  2101. q31_t * pSrcB,
  2102. q31_t * pDst,
  2103. uint32_t blockSize);
  2104. /**
  2105. * @brief Floating-point vector subtraction.
  2106. * @param[in] pSrcA points to the first input vector
  2107. * @param[in] pSrcB points to the second input vector
  2108. * @param[out] pDst points to the output vector
  2109. * @param[in] blockSize number of samples in each vector
  2110. */
  2111. void arm_sub_f32(
  2112. float32_t * pSrcA,
  2113. float32_t * pSrcB,
  2114. float32_t * pDst,
  2115. uint32_t blockSize);
  2116. /**
  2117. * @brief Q7 vector subtraction.
  2118. * @param[in] pSrcA points to the first input vector
  2119. * @param[in] pSrcB points to the second input vector
  2120. * @param[out] pDst points to the output vector
  2121. * @param[in] blockSize number of samples in each vector
  2122. */
  2123. void arm_sub_q7(
  2124. q7_t * pSrcA,
  2125. q7_t * pSrcB,
  2126. q7_t * pDst,
  2127. uint32_t blockSize);
  2128. /**
  2129. * @brief Q15 vector subtraction.
  2130. * @param[in] pSrcA points to the first input vector
  2131. * @param[in] pSrcB points to the second input vector
  2132. * @param[out] pDst points to the output vector
  2133. * @param[in] blockSize number of samples in each vector
  2134. */
  2135. void arm_sub_q15(
  2136. q15_t * pSrcA,
  2137. q15_t * pSrcB,
  2138. q15_t * pDst,
  2139. uint32_t blockSize);
  2140. /**
  2141. * @brief Q31 vector subtraction.
  2142. * @param[in] pSrcA points to the first input vector
  2143. * @param[in] pSrcB points to the second input vector
  2144. * @param[out] pDst points to the output vector
  2145. * @param[in] blockSize number of samples in each vector
  2146. */
  2147. void arm_sub_q31(
  2148. q31_t * pSrcA,
  2149. q31_t * pSrcB,
  2150. q31_t * pDst,
  2151. uint32_t blockSize);
  2152. /**
  2153. * @brief Multiplies a floating-point vector by a scalar.
  2154. * @param[in] pSrc points to the input vector
  2155. * @param[in] scale scale factor to be applied
  2156. * @param[out] pDst points to the output vector
  2157. * @param[in] blockSize number of samples in the vector
  2158. */
  2159. void arm_scale_f32(
  2160. float32_t * pSrc,
  2161. float32_t scale,
  2162. float32_t * pDst,
  2163. uint32_t blockSize);
  2164. /**
  2165. * @brief Multiplies a Q7 vector by a scalar.
  2166. * @param[in] pSrc points to the input vector
  2167. * @param[in] scaleFract fractional portion of the scale value
  2168. * @param[in] shift number of bits to shift the result by
  2169. * @param[out] pDst points to the output vector
  2170. * @param[in] blockSize number of samples in the vector
  2171. */
  2172. void arm_scale_q7(
  2173. q7_t * pSrc,
  2174. q7_t scaleFract,
  2175. int8_t shift,
  2176. q7_t * pDst,
  2177. uint32_t blockSize);
  2178. /**
  2179. * @brief Multiplies a Q15 vector by a scalar.
  2180. * @param[in] pSrc points to the input vector
  2181. * @param[in] scaleFract fractional portion of the scale value
  2182. * @param[in] shift number of bits to shift the result by
  2183. * @param[out] pDst points to the output vector
  2184. * @param[in] blockSize number of samples in the vector
  2185. */
  2186. void arm_scale_q15(
  2187. q15_t * pSrc,
  2188. q15_t scaleFract,
  2189. int8_t shift,
  2190. q15_t * pDst,
  2191. uint32_t blockSize);
  2192. /**
  2193. * @brief Multiplies a Q31 vector by a scalar.
  2194. * @param[in] pSrc points to the input vector
  2195. * @param[in] scaleFract fractional portion of the scale value
  2196. * @param[in] shift number of bits to shift the result by
  2197. * @param[out] pDst points to the output vector
  2198. * @param[in] blockSize number of samples in the vector
  2199. */
  2200. void arm_scale_q31(
  2201. q31_t * pSrc,
  2202. q31_t scaleFract,
  2203. int8_t shift,
  2204. q31_t * pDst,
  2205. uint32_t blockSize);
  2206. /**
  2207. * @brief Q7 vector absolute value.
  2208. * @param[in] pSrc points to the input buffer
  2209. * @param[out] pDst points to the output buffer
  2210. * @param[in] blockSize number of samples in each vector
  2211. */
  2212. void arm_abs_q7(
  2213. q7_t * pSrc,
  2214. q7_t * pDst,
  2215. uint32_t blockSize);
  2216. /**
  2217. * @brief Floating-point vector absolute value.
  2218. * @param[in] pSrc points to the input buffer
  2219. * @param[out] pDst points to the output buffer
  2220. * @param[in] blockSize number of samples in each vector
  2221. */
  2222. void arm_abs_f32(
  2223. float32_t * pSrc,
  2224. float32_t * pDst,
  2225. uint32_t blockSize);
  2226. /**
  2227. * @brief Q15 vector absolute value.
  2228. * @param[in] pSrc points to the input buffer
  2229. * @param[out] pDst points to the output buffer
  2230. * @param[in] blockSize number of samples in each vector
  2231. */
  2232. void arm_abs_q15(
  2233. q15_t * pSrc,
  2234. q15_t * pDst,
  2235. uint32_t blockSize);
  2236. /**
  2237. * @brief Q31 vector absolute value.
  2238. * @param[in] pSrc points to the input buffer
  2239. * @param[out] pDst points to the output buffer
  2240. * @param[in] blockSize number of samples in each vector
  2241. */
  2242. void arm_abs_q31(
  2243. q31_t * pSrc,
  2244. q31_t * pDst,
  2245. uint32_t blockSize);
  2246. /**
  2247. * @brief Dot product of floating-point vectors.
  2248. * @param[in] pSrcA points to the first input vector
  2249. * @param[in] pSrcB points to the second input vector
  2250. * @param[in] blockSize number of samples in each vector
  2251. * @param[out] result output result returned here
  2252. */
  2253. void arm_dot_prod_f32(
  2254. float32_t * pSrcA,
  2255. float32_t * pSrcB,
  2256. uint32_t blockSize,
  2257. float32_t * result);
  2258. /**
  2259. * @brief Dot product of Q7 vectors.
  2260. * @param[in] pSrcA points to the first input vector
  2261. * @param[in] pSrcB points to the second input vector
  2262. * @param[in] blockSize number of samples in each vector
  2263. * @param[out] result output result returned here
  2264. */
  2265. void arm_dot_prod_q7(
  2266. q7_t * pSrcA,
  2267. q7_t * pSrcB,
  2268. uint32_t blockSize,
  2269. q31_t * result);
  2270. /**
  2271. * @brief Dot product of Q15 vectors.
  2272. * @param[in] pSrcA points to the first input vector
  2273. * @param[in] pSrcB points to the second input vector
  2274. * @param[in] blockSize number of samples in each vector
  2275. * @param[out] result output result returned here
  2276. */
  2277. void arm_dot_prod_q15(
  2278. q15_t * pSrcA,
  2279. q15_t * pSrcB,
  2280. uint32_t blockSize,
  2281. q63_t * result);
  2282. /**
  2283. * @brief Dot product of Q31 vectors.
  2284. * @param[in] pSrcA points to the first input vector
  2285. * @param[in] pSrcB points to the second input vector
  2286. * @param[in] blockSize number of samples in each vector
  2287. * @param[out] result output result returned here
  2288. */
  2289. void arm_dot_prod_q31(
  2290. q31_t * pSrcA,
  2291. q31_t * pSrcB,
  2292. uint32_t blockSize,
  2293. q63_t * result);
  2294. /**
  2295. * @brief Shifts the elements of a Q7 vector a specified number of bits.
  2296. * @param[in] pSrc points to the input vector
  2297. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2298. * @param[out] pDst points to the output vector
  2299. * @param[in] blockSize number of samples in the vector
  2300. */
  2301. void arm_shift_q7(
  2302. q7_t * pSrc,
  2303. int8_t shiftBits,
  2304. q7_t * pDst,
  2305. uint32_t blockSize);
  2306. /**
  2307. * @brief Shifts the elements of a Q15 vector a specified number of bits.
  2308. * @param[in] pSrc points to the input vector
  2309. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2310. * @param[out] pDst points to the output vector
  2311. * @param[in] blockSize number of samples in the vector
  2312. */
  2313. void arm_shift_q15(
  2314. q15_t * pSrc,
  2315. int8_t shiftBits,
  2316. q15_t * pDst,
  2317. uint32_t blockSize);
  2318. /**
  2319. * @brief Shifts the elements of a Q31 vector a specified number of bits.
  2320. * @param[in] pSrc points to the input vector
  2321. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2322. * @param[out] pDst points to the output vector
  2323. * @param[in] blockSize number of samples in the vector
  2324. */
  2325. void arm_shift_q31(
  2326. q31_t * pSrc,
  2327. int8_t shiftBits,
  2328. q31_t * pDst,
  2329. uint32_t blockSize);
  2330. /**
  2331. * @brief Adds a constant offset to a floating-point vector.
  2332. * @param[in] pSrc points to the input vector
  2333. * @param[in] offset is the offset to be added
  2334. * @param[out] pDst points to the output vector
  2335. * @param[in] blockSize number of samples in the vector
  2336. */
  2337. void arm_offset_f32(
  2338. float32_t * pSrc,
  2339. float32_t offset,
  2340. float32_t * pDst,
  2341. uint32_t blockSize);
  2342. /**
  2343. * @brief Adds a constant offset to a Q7 vector.
  2344. * @param[in] pSrc points to the input vector
  2345. * @param[in] offset is the offset to be added
  2346. * @param[out] pDst points to the output vector
  2347. * @param[in] blockSize number of samples in the vector
  2348. */
  2349. void arm_offset_q7(
  2350. q7_t * pSrc,
  2351. q7_t offset,
  2352. q7_t * pDst,
  2353. uint32_t blockSize);
  2354. /**
  2355. * @brief Adds a constant offset to a Q15 vector.
  2356. * @param[in] pSrc points to the input vector
  2357. * @param[in] offset is the offset to be added
  2358. * @param[out] pDst points to the output vector
  2359. * @param[in] blockSize number of samples in the vector
  2360. */
  2361. void arm_offset_q15(
  2362. q15_t * pSrc,
  2363. q15_t offset,
  2364. q15_t * pDst,
  2365. uint32_t blockSize);
  2366. /**
  2367. * @brief Adds a constant offset to a Q31 vector.
  2368. * @param[in] pSrc points to the input vector
  2369. * @param[in] offset is the offset to be added
  2370. * @param[out] pDst points to the output vector
  2371. * @param[in] blockSize number of samples in the vector
  2372. */
  2373. void arm_offset_q31(
  2374. q31_t * pSrc,
  2375. q31_t offset,
  2376. q31_t * pDst,
  2377. uint32_t blockSize);
  2378. /**
  2379. * @brief Negates the elements of a floating-point vector.
  2380. * @param[in] pSrc points to the input vector
  2381. * @param[out] pDst points to the output vector
  2382. * @param[in] blockSize number of samples in the vector
  2383. */
  2384. void arm_negate_f32(
  2385. float32_t * pSrc,
  2386. float32_t * pDst,
  2387. uint32_t blockSize);
  2388. /**
  2389. * @brief Negates the elements of a Q7 vector.
  2390. * @param[in] pSrc points to the input vector
  2391. * @param[out] pDst points to the output vector
  2392. * @param[in] blockSize number of samples in the vector
  2393. */
  2394. void arm_negate_q7(
  2395. q7_t * pSrc,
  2396. q7_t * pDst,
  2397. uint32_t blockSize);
  2398. /**
  2399. * @brief Negates the elements of a Q15 vector.
  2400. * @param[in] pSrc points to the input vector
  2401. * @param[out] pDst points to the output vector
  2402. * @param[in] blockSize number of samples in the vector
  2403. */
  2404. void arm_negate_q15(
  2405. q15_t * pSrc,
  2406. q15_t * pDst,
  2407. uint32_t blockSize);
  2408. /**
  2409. * @brief Negates the elements of a Q31 vector.
  2410. * @param[in] pSrc points to the input vector
  2411. * @param[out] pDst points to the output vector
  2412. * @param[in] blockSize number of samples in the vector
  2413. */
  2414. void arm_negate_q31(
  2415. q31_t * pSrc,
  2416. q31_t * pDst,
  2417. uint32_t blockSize);
  2418. /**
  2419. * @brief Copies the elements of a floating-point vector.
  2420. * @param[in] pSrc input pointer
  2421. * @param[out] pDst output pointer
  2422. * @param[in] blockSize number of samples to process
  2423. */
  2424. void arm_copy_f32(
  2425. float32_t * pSrc,
  2426. float32_t * pDst,
  2427. uint32_t blockSize);
  2428. /**
  2429. * @brief Copies the elements of a Q7 vector.
  2430. * @param[in] pSrc input pointer
  2431. * @param[out] pDst output pointer
  2432. * @param[in] blockSize number of samples to process
  2433. */
  2434. void arm_copy_q7(
  2435. q7_t * pSrc,
  2436. q7_t * pDst,
  2437. uint32_t blockSize);
  2438. /**
  2439. * @brief Copies the elements of a Q15 vector.
  2440. * @param[in] pSrc input pointer
  2441. * @param[out] pDst output pointer
  2442. * @param[in] blockSize number of samples to process
  2443. */
  2444. void arm_copy_q15(
  2445. q15_t * pSrc,
  2446. q15_t * pDst,
  2447. uint32_t blockSize);
  2448. /**
  2449. * @brief Copies the elements of a Q31 vector.
  2450. * @param[in] pSrc input pointer
  2451. * @param[out] pDst output pointer
  2452. * @param[in] blockSize number of samples to process
  2453. */
  2454. void arm_copy_q31(
  2455. q31_t * pSrc,
  2456. q31_t * pDst,
  2457. uint32_t blockSize);
  2458. /**
  2459. * @brief Fills a constant value into a floating-point vector.
  2460. * @param[in] value input value to be filled
  2461. * @param[out] pDst output pointer
  2462. * @param[in] blockSize number of samples to process
  2463. */
  2464. void arm_fill_f32(
  2465. float32_t value,
  2466. float32_t * pDst,
  2467. uint32_t blockSize);
  2468. /**
  2469. * @brief Fills a constant value into a Q7 vector.
  2470. * @param[in] value input value to be filled
  2471. * @param[out] pDst output pointer
  2472. * @param[in] blockSize number of samples to process
  2473. */
  2474. void arm_fill_q7(
  2475. q7_t value,
  2476. q7_t * pDst,
  2477. uint32_t blockSize);
  2478. /**
  2479. * @brief Fills a constant value into a Q15 vector.
  2480. * @param[in] value input value to be filled
  2481. * @param[out] pDst output pointer
  2482. * @param[in] blockSize number of samples to process
  2483. */
  2484. void arm_fill_q15(
  2485. q15_t value,
  2486. q15_t * pDst,
  2487. uint32_t blockSize);
  2488. /**
  2489. * @brief Fills a constant value into a Q31 vector.
  2490. * @param[in] value input value to be filled
  2491. * @param[out] pDst output pointer
  2492. * @param[in] blockSize number of samples to process
  2493. */
  2494. void arm_fill_q31(
  2495. q31_t value,
  2496. q31_t * pDst,
  2497. uint32_t blockSize);
  2498. /**
  2499. * @brief Convolution of floating-point sequences.
  2500. * @param[in] pSrcA points to the first input sequence.
  2501. * @param[in] srcALen length of the first input sequence.
  2502. * @param[in] pSrcB points to the second input sequence.
  2503. * @param[in] srcBLen length of the second input sequence.
  2504. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2505. */
  2506. void arm_conv_f32(
  2507. float32_t * pSrcA,
  2508. uint32_t srcALen,
  2509. float32_t * pSrcB,
  2510. uint32_t srcBLen,
  2511. float32_t * pDst);
  2512. /**
  2513. * @brief Convolution of Q15 sequences.
  2514. * @param[in] pSrcA points to the first input sequence.
  2515. * @param[in] srcALen length of the first input sequence.
  2516. * @param[in] pSrcB points to the second input sequence.
  2517. * @param[in] srcBLen length of the second input sequence.
  2518. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2519. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2520. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2521. */
  2522. void arm_conv_opt_q15(
  2523. q15_t * pSrcA,
  2524. uint32_t srcALen,
  2525. q15_t * pSrcB,
  2526. uint32_t srcBLen,
  2527. q15_t * pDst,
  2528. q15_t * pScratch1,
  2529. q15_t * pScratch2);
  2530. /**
  2531. * @brief Convolution of Q15 sequences.
  2532. * @param[in] pSrcA points to the first input sequence.
  2533. * @param[in] srcALen length of the first input sequence.
  2534. * @param[in] pSrcB points to the second input sequence.
  2535. * @param[in] srcBLen length of the second input sequence.
  2536. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2537. */
  2538. void arm_conv_q15(
  2539. q15_t * pSrcA,
  2540. uint32_t srcALen,
  2541. q15_t * pSrcB,
  2542. uint32_t srcBLen,
  2543. q15_t * pDst);
  2544. /**
  2545. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2546. * @param[in] pSrcA points to the first input sequence.
  2547. * @param[in] srcALen length of the first input sequence.
  2548. * @param[in] pSrcB points to the second input sequence.
  2549. * @param[in] srcBLen length of the second input sequence.
  2550. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2551. */
  2552. void arm_conv_fast_q15(
  2553. q15_t * pSrcA,
  2554. uint32_t srcALen,
  2555. q15_t * pSrcB,
  2556. uint32_t srcBLen,
  2557. q15_t * pDst);
  2558. /**
  2559. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2560. * @param[in] pSrcA points to the first input sequence.
  2561. * @param[in] srcALen length of the first input sequence.
  2562. * @param[in] pSrcB points to the second input sequence.
  2563. * @param[in] srcBLen length of the second input sequence.
  2564. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2565. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2566. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2567. */
  2568. void arm_conv_fast_opt_q15(
  2569. q15_t * pSrcA,
  2570. uint32_t srcALen,
  2571. q15_t * pSrcB,
  2572. uint32_t srcBLen,
  2573. q15_t * pDst,
  2574. q15_t * pScratch1,
  2575. q15_t * pScratch2);
  2576. /**
  2577. * @brief Convolution of Q31 sequences.
  2578. * @param[in] pSrcA points to the first input sequence.
  2579. * @param[in] srcALen length of the first input sequence.
  2580. * @param[in] pSrcB points to the second input sequence.
  2581. * @param[in] srcBLen length of the second input sequence.
  2582. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2583. */
  2584. void arm_conv_q31(
  2585. q31_t * pSrcA,
  2586. uint32_t srcALen,
  2587. q31_t * pSrcB,
  2588. uint32_t srcBLen,
  2589. q31_t * pDst);
  2590. /**
  2591. * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2592. * @param[in] pSrcA points to the first input sequence.
  2593. * @param[in] srcALen length of the first input sequence.
  2594. * @param[in] pSrcB points to the second input sequence.
  2595. * @param[in] srcBLen length of the second input sequence.
  2596. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2597. */
  2598. void arm_conv_fast_q31(
  2599. q31_t * pSrcA,
  2600. uint32_t srcALen,
  2601. q31_t * pSrcB,
  2602. uint32_t srcBLen,
  2603. q31_t * pDst);
  2604. /**
  2605. * @brief Convolution of Q7 sequences.
  2606. * @param[in] pSrcA points to the first input sequence.
  2607. * @param[in] srcALen length of the first input sequence.
  2608. * @param[in] pSrcB points to the second input sequence.
  2609. * @param[in] srcBLen length of the second input sequence.
  2610. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2611. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2612. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2613. */
  2614. void arm_conv_opt_q7(
  2615. q7_t * pSrcA,
  2616. uint32_t srcALen,
  2617. q7_t * pSrcB,
  2618. uint32_t srcBLen,
  2619. q7_t * pDst,
  2620. q15_t * pScratch1,
  2621. q15_t * pScratch2);
  2622. /**
  2623. * @brief Convolution of Q7 sequences.
  2624. * @param[in] pSrcA points to the first input sequence.
  2625. * @param[in] srcALen length of the first input sequence.
  2626. * @param[in] pSrcB points to the second input sequence.
  2627. * @param[in] srcBLen length of the second input sequence.
  2628. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2629. */
  2630. void arm_conv_q7(
  2631. q7_t * pSrcA,
  2632. uint32_t srcALen,
  2633. q7_t * pSrcB,
  2634. uint32_t srcBLen,
  2635. q7_t * pDst);
  2636. /**
  2637. * @brief Partial convolution of floating-point sequences.
  2638. * @param[in] pSrcA points to the first input sequence.
  2639. * @param[in] srcALen length of the first input sequence.
  2640. * @param[in] pSrcB points to the second input sequence.
  2641. * @param[in] srcBLen length of the second input sequence.
  2642. * @param[out] pDst points to the block of output data
  2643. * @param[in] firstIndex is the first output sample to start with.
  2644. * @param[in] numPoints is the number of output points to be computed.
  2645. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2646. */
  2647. arm_status arm_conv_partial_f32(
  2648. float32_t * pSrcA,
  2649. uint32_t srcALen,
  2650. float32_t * pSrcB,
  2651. uint32_t srcBLen,
  2652. float32_t * pDst,
  2653. uint32_t firstIndex,
  2654. uint32_t numPoints);
  2655. /**
  2656. * @brief Partial convolution of Q15 sequences.
  2657. * @param[in] pSrcA points to the first input sequence.
  2658. * @param[in] srcALen length of the first input sequence.
  2659. * @param[in] pSrcB points to the second input sequence.
  2660. * @param[in] srcBLen length of the second input sequence.
  2661. * @param[out] pDst points to the block of output data
  2662. * @param[in] firstIndex is the first output sample to start with.
  2663. * @param[in] numPoints is the number of output points to be computed.
  2664. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2665. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2666. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2667. */
  2668. arm_status arm_conv_partial_opt_q15(
  2669. q15_t * pSrcA,
  2670. uint32_t srcALen,
  2671. q15_t * pSrcB,
  2672. uint32_t srcBLen,
  2673. q15_t * pDst,
  2674. uint32_t firstIndex,
  2675. uint32_t numPoints,
  2676. q15_t * pScratch1,
  2677. q15_t * pScratch2);
  2678. /**
  2679. * @brief Partial convolution of Q15 sequences.
  2680. * @param[in] pSrcA points to the first input sequence.
  2681. * @param[in] srcALen length of the first input sequence.
  2682. * @param[in] pSrcB points to the second input sequence.
  2683. * @param[in] srcBLen length of the second input sequence.
  2684. * @param[out] pDst points to the block of output data
  2685. * @param[in] firstIndex is the first output sample to start with.
  2686. * @param[in] numPoints is the number of output points to be computed.
  2687. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2688. */
  2689. arm_status arm_conv_partial_q15(
  2690. q15_t * pSrcA,
  2691. uint32_t srcALen,
  2692. q15_t * pSrcB,
  2693. uint32_t srcBLen,
  2694. q15_t * pDst,
  2695. uint32_t firstIndex,
  2696. uint32_t numPoints);
  2697. /**
  2698. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2699. * @param[in] pSrcA points to the first input sequence.
  2700. * @param[in] srcALen length of the first input sequence.
  2701. * @param[in] pSrcB points to the second input sequence.
  2702. * @param[in] srcBLen length of the second input sequence.
  2703. * @param[out] pDst points to the block of output data
  2704. * @param[in] firstIndex is the first output sample to start with.
  2705. * @param[in] numPoints is the number of output points to be computed.
  2706. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2707. */
  2708. arm_status arm_conv_partial_fast_q15(
  2709. q15_t * pSrcA,
  2710. uint32_t srcALen,
  2711. q15_t * pSrcB,
  2712. uint32_t srcBLen,
  2713. q15_t * pDst,
  2714. uint32_t firstIndex,
  2715. uint32_t numPoints);
  2716. /**
  2717. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2718. * @param[in] pSrcA points to the first input sequence.
  2719. * @param[in] srcALen length of the first input sequence.
  2720. * @param[in] pSrcB points to the second input sequence.
  2721. * @param[in] srcBLen length of the second input sequence.
  2722. * @param[out] pDst points to the block of output data
  2723. * @param[in] firstIndex is the first output sample to start with.
  2724. * @param[in] numPoints is the number of output points to be computed.
  2725. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2726. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2727. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2728. */
  2729. arm_status arm_conv_partial_fast_opt_q15(
  2730. q15_t * pSrcA,
  2731. uint32_t srcALen,
  2732. q15_t * pSrcB,
  2733. uint32_t srcBLen,
  2734. q15_t * pDst,
  2735. uint32_t firstIndex,
  2736. uint32_t numPoints,
  2737. q15_t * pScratch1,
  2738. q15_t * pScratch2);
  2739. /**
  2740. * @brief Partial convolution of Q31 sequences.
  2741. * @param[in] pSrcA points to the first input sequence.
  2742. * @param[in] srcALen length of the first input sequence.
  2743. * @param[in] pSrcB points to the second input sequence.
  2744. * @param[in] srcBLen length of the second input sequence.
  2745. * @param[out] pDst points to the block of output data
  2746. * @param[in] firstIndex is the first output sample to start with.
  2747. * @param[in] numPoints is the number of output points to be computed.
  2748. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2749. */
  2750. arm_status arm_conv_partial_q31(
  2751. q31_t * pSrcA,
  2752. uint32_t srcALen,
  2753. q31_t * pSrcB,
  2754. uint32_t srcBLen,
  2755. q31_t * pDst,
  2756. uint32_t firstIndex,
  2757. uint32_t numPoints);
  2758. /**
  2759. * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2760. * @param[in] pSrcA points to the first input sequence.
  2761. * @param[in] srcALen length of the first input sequence.
  2762. * @param[in] pSrcB points to the second input sequence.
  2763. * @param[in] srcBLen length of the second input sequence.
  2764. * @param[out] pDst points to the block of output data
  2765. * @param[in] firstIndex is the first output sample to start with.
  2766. * @param[in] numPoints is the number of output points to be computed.
  2767. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2768. */
  2769. arm_status arm_conv_partial_fast_q31(
  2770. q31_t * pSrcA,
  2771. uint32_t srcALen,
  2772. q31_t * pSrcB,
  2773. uint32_t srcBLen,
  2774. q31_t * pDst,
  2775. uint32_t firstIndex,
  2776. uint32_t numPoints);
  2777. /**
  2778. * @brief Partial convolution of Q7 sequences
  2779. * @param[in] pSrcA points to the first input sequence.
  2780. * @param[in] srcALen length of the first input sequence.
  2781. * @param[in] pSrcB points to the second input sequence.
  2782. * @param[in] srcBLen length of the second input sequence.
  2783. * @param[out] pDst points to the block of output data
  2784. * @param[in] firstIndex is the first output sample to start with.
  2785. * @param[in] numPoints is the number of output points to be computed.
  2786. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2787. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2788. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2789. */
  2790. arm_status arm_conv_partial_opt_q7(
  2791. q7_t * pSrcA,
  2792. uint32_t srcALen,
  2793. q7_t * pSrcB,
  2794. uint32_t srcBLen,
  2795. q7_t * pDst,
  2796. uint32_t firstIndex,
  2797. uint32_t numPoints,
  2798. q15_t * pScratch1,
  2799. q15_t * pScratch2);
  2800. /**
  2801. * @brief Partial convolution of Q7 sequences.
  2802. * @param[in] pSrcA points to the first input sequence.
  2803. * @param[in] srcALen length of the first input sequence.
  2804. * @param[in] pSrcB points to the second input sequence.
  2805. * @param[in] srcBLen length of the second input sequence.
  2806. * @param[out] pDst points to the block of output data
  2807. * @param[in] firstIndex is the first output sample to start with.
  2808. * @param[in] numPoints is the number of output points to be computed.
  2809. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2810. */
  2811. arm_status arm_conv_partial_q7(
  2812. q7_t * pSrcA,
  2813. uint32_t srcALen,
  2814. q7_t * pSrcB,
  2815. uint32_t srcBLen,
  2816. q7_t * pDst,
  2817. uint32_t firstIndex,
  2818. uint32_t numPoints);
  2819. /**
  2820. * @brief Instance structure for the Q15 FIR decimator.
  2821. */
  2822. typedef struct
  2823. {
  2824. uint8_t M; /**< decimation factor. */
  2825. uint16_t numTaps; /**< number of coefficients in the filter. */
  2826. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2827. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2828. } arm_fir_decimate_instance_q15;
  2829. /**
  2830. * @brief Instance structure for the Q31 FIR decimator.
  2831. */
  2832. typedef struct
  2833. {
  2834. uint8_t M; /**< decimation factor. */
  2835. uint16_t numTaps; /**< number of coefficients in the filter. */
  2836. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2837. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2838. } arm_fir_decimate_instance_q31;
  2839. /**
  2840. * @brief Instance structure for the floating-point FIR decimator.
  2841. */
  2842. typedef struct
  2843. {
  2844. uint8_t M; /**< decimation factor. */
  2845. uint16_t numTaps; /**< number of coefficients in the filter. */
  2846. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2847. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2848. } arm_fir_decimate_instance_f32;
  2849. /**
  2850. * @brief Processing function for the floating-point FIR decimator.
  2851. * @param[in] S points to an instance of the floating-point FIR decimator structure.
  2852. * @param[in] pSrc points to the block of input data.
  2853. * @param[out] pDst points to the block of output data
  2854. * @param[in] blockSize number of input samples to process per call.
  2855. */
  2856. void arm_fir_decimate_f32(
  2857. const arm_fir_decimate_instance_f32 * S,
  2858. float32_t * pSrc,
  2859. float32_t * pDst,
  2860. uint32_t blockSize);
  2861. /**
  2862. * @brief Initialization function for the floating-point FIR decimator.
  2863. * @param[in,out] S points to an instance of the floating-point FIR decimator structure.
  2864. * @param[in] numTaps number of coefficients in the filter.
  2865. * @param[in] M decimation factor.
  2866. * @param[in] pCoeffs points to the filter coefficients.
  2867. * @param[in] pState points to the state buffer.
  2868. * @param[in] blockSize number of input samples to process per call.
  2869. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2870. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2871. */
  2872. arm_status arm_fir_decimate_init_f32(
  2873. arm_fir_decimate_instance_f32 * S,
  2874. uint16_t numTaps,
  2875. uint8_t M,
  2876. float32_t * pCoeffs,
  2877. float32_t * pState,
  2878. uint32_t blockSize);
  2879. /**
  2880. * @brief Processing function for the Q15 FIR decimator.
  2881. * @param[in] S points to an instance of the Q15 FIR decimator structure.
  2882. * @param[in] pSrc points to the block of input data.
  2883. * @param[out] pDst points to the block of output data
  2884. * @param[in] blockSize number of input samples to process per call.
  2885. */
  2886. void arm_fir_decimate_q15(
  2887. const arm_fir_decimate_instance_q15 * S,
  2888. q15_t * pSrc,
  2889. q15_t * pDst,
  2890. uint32_t blockSize);
  2891. /**
  2892. * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  2893. * @param[in] S points to an instance of the Q15 FIR decimator structure.
  2894. * @param[in] pSrc points to the block of input data.
  2895. * @param[out] pDst points to the block of output data
  2896. * @param[in] blockSize number of input samples to process per call.
  2897. */
  2898. void arm_fir_decimate_fast_q15(
  2899. const arm_fir_decimate_instance_q15 * S,
  2900. q15_t * pSrc,
  2901. q15_t * pDst,
  2902. uint32_t blockSize);
  2903. /**
  2904. * @brief Initialization function for the Q15 FIR decimator.
  2905. * @param[in,out] S points to an instance of the Q15 FIR decimator structure.
  2906. * @param[in] numTaps number of coefficients in the filter.
  2907. * @param[in] M decimation factor.
  2908. * @param[in] pCoeffs points to the filter coefficients.
  2909. * @param[in] pState points to the state buffer.
  2910. * @param[in] blockSize number of input samples to process per call.
  2911. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2912. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2913. */
  2914. arm_status arm_fir_decimate_init_q15(
  2915. arm_fir_decimate_instance_q15 * S,
  2916. uint16_t numTaps,
  2917. uint8_t M,
  2918. q15_t * pCoeffs,
  2919. q15_t * pState,
  2920. uint32_t blockSize);
  2921. /**
  2922. * @brief Processing function for the Q31 FIR decimator.
  2923. * @param[in] S points to an instance of the Q31 FIR decimator structure.
  2924. * @param[in] pSrc points to the block of input data.
  2925. * @param[out] pDst points to the block of output data
  2926. * @param[in] blockSize number of input samples to process per call.
  2927. */
  2928. void arm_fir_decimate_q31(
  2929. const arm_fir_decimate_instance_q31 * S,
  2930. q31_t * pSrc,
  2931. q31_t * pDst,
  2932. uint32_t blockSize);
  2933. /**
  2934. * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  2935. * @param[in] S points to an instance of the Q31 FIR decimator structure.
  2936. * @param[in] pSrc points to the block of input data.
  2937. * @param[out] pDst points to the block of output data
  2938. * @param[in] blockSize number of input samples to process per call.
  2939. */
  2940. void arm_fir_decimate_fast_q31(
  2941. arm_fir_decimate_instance_q31 * S,
  2942. q31_t * pSrc,
  2943. q31_t * pDst,
  2944. uint32_t blockSize);
  2945. /**
  2946. * @brief Initialization function for the Q31 FIR decimator.
  2947. * @param[in,out] S points to an instance of the Q31 FIR decimator structure.
  2948. * @param[in] numTaps number of coefficients in the filter.
  2949. * @param[in] M decimation factor.
  2950. * @param[in] pCoeffs points to the filter coefficients.
  2951. * @param[in] pState points to the state buffer.
  2952. * @param[in] blockSize number of input samples to process per call.
  2953. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2954. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2955. */
  2956. arm_status arm_fir_decimate_init_q31(
  2957. arm_fir_decimate_instance_q31 * S,
  2958. uint16_t numTaps,
  2959. uint8_t M,
  2960. q31_t * pCoeffs,
  2961. q31_t * pState,
  2962. uint32_t blockSize);
  2963. /**
  2964. * @brief Instance structure for the Q15 FIR interpolator.
  2965. */
  2966. typedef struct
  2967. {
  2968. uint8_t L; /**< upsample factor. */
  2969. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2970. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2971. q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  2972. } arm_fir_interpolate_instance_q15;
  2973. /**
  2974. * @brief Instance structure for the Q31 FIR interpolator.
  2975. */
  2976. typedef struct
  2977. {
  2978. uint8_t L; /**< upsample factor. */
  2979. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2980. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2981. q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  2982. } arm_fir_interpolate_instance_q31;
  2983. /**
  2984. * @brief Instance structure for the floating-point FIR interpolator.
  2985. */
  2986. typedef struct
  2987. {
  2988. uint8_t L; /**< upsample factor. */
  2989. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2990. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2991. float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
  2992. } arm_fir_interpolate_instance_f32;
  2993. /**
  2994. * @brief Processing function for the Q15 FIR interpolator.
  2995. * @param[in] S points to an instance of the Q15 FIR interpolator structure.
  2996. * @param[in] pSrc points to the block of input data.
  2997. * @param[out] pDst points to the block of output data.
  2998. * @param[in] blockSize number of input samples to process per call.
  2999. */
  3000. void arm_fir_interpolate_q15(
  3001. const arm_fir_interpolate_instance_q15 * S,
  3002. q15_t * pSrc,
  3003. q15_t * pDst,
  3004. uint32_t blockSize);
  3005. /**
  3006. * @brief Initialization function for the Q15 FIR interpolator.
  3007. * @param[in,out] S points to an instance of the Q15 FIR interpolator structure.
  3008. * @param[in] L upsample factor.
  3009. * @param[in] numTaps number of filter coefficients in the filter.
  3010. * @param[in] pCoeffs points to the filter coefficient buffer.
  3011. * @param[in] pState points to the state buffer.
  3012. * @param[in] blockSize number of input samples to process per call.
  3013. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3014. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3015. */
  3016. arm_status arm_fir_interpolate_init_q15(
  3017. arm_fir_interpolate_instance_q15 * S,
  3018. uint8_t L,
  3019. uint16_t numTaps,
  3020. q15_t * pCoeffs,
  3021. q15_t * pState,
  3022. uint32_t blockSize);
  3023. /**
  3024. * @brief Processing function for the Q31 FIR interpolator.
  3025. * @param[in] S points to an instance of the Q15 FIR interpolator structure.
  3026. * @param[in] pSrc points to the block of input data.
  3027. * @param[out] pDst points to the block of output data.
  3028. * @param[in] blockSize number of input samples to process per call.
  3029. */
  3030. void arm_fir_interpolate_q31(
  3031. const arm_fir_interpolate_instance_q31 * S,
  3032. q31_t * pSrc,
  3033. q31_t * pDst,
  3034. uint32_t blockSize);
  3035. /**
  3036. * @brief Initialization function for the Q31 FIR interpolator.
  3037. * @param[in,out] S points to an instance of the Q31 FIR interpolator structure.
  3038. * @param[in] L upsample factor.
  3039. * @param[in] numTaps number of filter coefficients in the filter.
  3040. * @param[in] pCoeffs points to the filter coefficient buffer.
  3041. * @param[in] pState points to the state buffer.
  3042. * @param[in] blockSize number of input samples to process per call.
  3043. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3044. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3045. */
  3046. arm_status arm_fir_interpolate_init_q31(
  3047. arm_fir_interpolate_instance_q31 * S,
  3048. uint8_t L,
  3049. uint16_t numTaps,
  3050. q31_t * pCoeffs,
  3051. q31_t * pState,
  3052. uint32_t blockSize);
  3053. /**
  3054. * @brief Processing function for the floating-point FIR interpolator.
  3055. * @param[in] S points to an instance of the floating-point FIR interpolator structure.
  3056. * @param[in] pSrc points to the block of input data.
  3057. * @param[out] pDst points to the block of output data.
  3058. * @param[in] blockSize number of input samples to process per call.
  3059. */
  3060. void arm_fir_interpolate_f32(
  3061. const arm_fir_interpolate_instance_f32 * S,
  3062. float32_t * pSrc,
  3063. float32_t * pDst,
  3064. uint32_t blockSize);
  3065. /**
  3066. * @brief Initialization function for the floating-point FIR interpolator.
  3067. * @param[in,out] S points to an instance of the floating-point FIR interpolator structure.
  3068. * @param[in] L upsample factor.
  3069. * @param[in] numTaps number of filter coefficients in the filter.
  3070. * @param[in] pCoeffs points to the filter coefficient buffer.
  3071. * @param[in] pState points to the state buffer.
  3072. * @param[in] blockSize number of input samples to process per call.
  3073. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3074. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3075. */
  3076. arm_status arm_fir_interpolate_init_f32(
  3077. arm_fir_interpolate_instance_f32 * S,
  3078. uint8_t L,
  3079. uint16_t numTaps,
  3080. float32_t * pCoeffs,
  3081. float32_t * pState,
  3082. uint32_t blockSize);
  3083. /**
  3084. * @brief Instance structure for the high precision Q31 Biquad cascade filter.
  3085. */
  3086. typedef struct
  3087. {
  3088. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3089. q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  3090. q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3091. uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
  3092. } arm_biquad_cas_df1_32x64_ins_q31;
  3093. /**
  3094. * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure.
  3095. * @param[in] pSrc points to the block of input data.
  3096. * @param[out] pDst points to the block of output data
  3097. * @param[in] blockSize number of samples to process.
  3098. */
  3099. void arm_biquad_cas_df1_32x64_q31(
  3100. const arm_biquad_cas_df1_32x64_ins_q31 * S,
  3101. q31_t * pSrc,
  3102. q31_t * pDst,
  3103. uint32_t blockSize);
  3104. /**
  3105. * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure.
  3106. * @param[in] numStages number of 2nd order stages in the filter.
  3107. * @param[in] pCoeffs points to the filter coefficients.
  3108. * @param[in] pState points to the state buffer.
  3109. * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
  3110. */
  3111. void arm_biquad_cas_df1_32x64_init_q31(
  3112. arm_biquad_cas_df1_32x64_ins_q31 * S,
  3113. uint8_t numStages,
  3114. q31_t * pCoeffs,
  3115. q63_t * pState,
  3116. uint8_t postShift);
  3117. /**
  3118. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  3119. */
  3120. typedef struct
  3121. {
  3122. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3123. float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  3124. float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3125. } arm_biquad_cascade_df2T_instance_f32;
  3126. /**
  3127. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  3128. */
  3129. typedef struct
  3130. {
  3131. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3132. float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  3133. float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3134. } arm_biquad_cascade_stereo_df2T_instance_f32;
  3135. /**
  3136. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  3137. */
  3138. typedef struct
  3139. {
  3140. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3141. float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  3142. float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3143. } arm_biquad_cascade_df2T_instance_f64;
  3144. /**
  3145. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  3146. * @param[in] S points to an instance of the filter data structure.
  3147. * @param[in] pSrc points to the block of input data.
  3148. * @param[out] pDst points to the block of output data
  3149. * @param[in] blockSize number of samples to process.
  3150. */
  3151. void arm_biquad_cascade_df2T_f32(
  3152. const arm_biquad_cascade_df2T_instance_f32 * S,
  3153. float32_t * pSrc,
  3154. float32_t * pDst,
  3155. uint32_t blockSize);
  3156. /**
  3157. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
  3158. * @param[in] S points to an instance of the filter data structure.
  3159. * @param[in] pSrc points to the block of input data.
  3160. * @param[out] pDst points to the block of output data
  3161. * @param[in] blockSize number of samples to process.
  3162. */
  3163. void arm_biquad_cascade_stereo_df2T_f32(
  3164. const arm_biquad_cascade_stereo_df2T_instance_f32 * S,
  3165. float32_t * pSrc,
  3166. float32_t * pDst,
  3167. uint32_t blockSize);
  3168. /**
  3169. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  3170. * @param[in] S points to an instance of the filter data structure.
  3171. * @param[in] pSrc points to the block of input data.
  3172. * @param[out] pDst points to the block of output data
  3173. * @param[in] blockSize number of samples to process.
  3174. */
  3175. void arm_biquad_cascade_df2T_f64(
  3176. const arm_biquad_cascade_df2T_instance_f64 * S,
  3177. float64_t * pSrc,
  3178. float64_t * pDst,
  3179. uint32_t blockSize);
  3180. /**
  3181. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  3182. * @param[in,out] S points to an instance of the filter data structure.
  3183. * @param[in] numStages number of 2nd order stages in the filter.
  3184. * @param[in] pCoeffs points to the filter coefficients.
  3185. * @param[in] pState points to the state buffer.
  3186. */
  3187. void arm_biquad_cascade_df2T_init_f32(
  3188. arm_biquad_cascade_df2T_instance_f32 * S,
  3189. uint8_t numStages,
  3190. float32_t * pCoeffs,
  3191. float32_t * pState);
  3192. /**
  3193. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  3194. * @param[in,out] S points to an instance of the filter data structure.
  3195. * @param[in] numStages number of 2nd order stages in the filter.
  3196. * @param[in] pCoeffs points to the filter coefficients.
  3197. * @param[in] pState points to the state buffer.
  3198. */
  3199. void arm_biquad_cascade_stereo_df2T_init_f32(
  3200. arm_biquad_cascade_stereo_df2T_instance_f32 * S,
  3201. uint8_t numStages,
  3202. float32_t * pCoeffs,
  3203. float32_t * pState);
  3204. /**
  3205. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  3206. * @param[in,out] S points to an instance of the filter data structure.
  3207. * @param[in] numStages number of 2nd order stages in the filter.
  3208. * @param[in] pCoeffs points to the filter coefficients.
  3209. * @param[in] pState points to the state buffer.
  3210. */
  3211. void arm_biquad_cascade_df2T_init_f64(
  3212. arm_biquad_cascade_df2T_instance_f64 * S,
  3213. uint8_t numStages,
  3214. float64_t * pCoeffs,
  3215. float64_t * pState);
  3216. /**
  3217. * @brief Instance structure for the Q15 FIR lattice filter.
  3218. */
  3219. typedef struct
  3220. {
  3221. uint16_t numStages; /**< number of filter stages. */
  3222. q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3223. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3224. } arm_fir_lattice_instance_q15;
  3225. /**
  3226. * @brief Instance structure for the Q31 FIR lattice filter.
  3227. */
  3228. typedef struct
  3229. {
  3230. uint16_t numStages; /**< number of filter stages. */
  3231. q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3232. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3233. } arm_fir_lattice_instance_q31;
  3234. /**
  3235. * @brief Instance structure for the floating-point FIR lattice filter.
  3236. */
  3237. typedef struct
  3238. {
  3239. uint16_t numStages; /**< number of filter stages. */
  3240. float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3241. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3242. } arm_fir_lattice_instance_f32;
  3243. /**
  3244. * @brief Initialization function for the Q15 FIR lattice filter.
  3245. * @param[in] S points to an instance of the Q15 FIR lattice structure.
  3246. * @param[in] numStages number of filter stages.
  3247. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  3248. * @param[in] pState points to the state buffer. The array is of length numStages.
  3249. */
  3250. void arm_fir_lattice_init_q15(
  3251. arm_fir_lattice_instance_q15 * S,
  3252. uint16_t numStages,
  3253. q15_t * pCoeffs,
  3254. q15_t * pState);
  3255. /**
  3256. * @brief Processing function for the Q15 FIR lattice filter.
  3257. * @param[in] S points to an instance of the Q15 FIR lattice structure.
  3258. * @param[in] pSrc points to the block of input data.
  3259. * @param[out] pDst points to the block of output data.
  3260. * @param[in] blockSize number of samples to process.
  3261. */
  3262. void arm_fir_lattice_q15(
  3263. const arm_fir_lattice_instance_q15 * S,
  3264. q15_t * pSrc,
  3265. q15_t * pDst,
  3266. uint32_t blockSize);
  3267. /**
  3268. * @brief Initialization function for the Q31 FIR lattice filter.
  3269. * @param[in] S points to an instance of the Q31 FIR lattice structure.
  3270. * @param[in] numStages number of filter stages.
  3271. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  3272. * @param[in] pState points to the state buffer. The array is of length numStages.
  3273. */
  3274. void arm_fir_lattice_init_q31(
  3275. arm_fir_lattice_instance_q31 * S,
  3276. uint16_t numStages,
  3277. q31_t * pCoeffs,
  3278. q31_t * pState);
  3279. /**
  3280. * @brief Processing function for the Q31 FIR lattice filter.
  3281. * @param[in] S points to an instance of the Q31 FIR lattice structure.
  3282. * @param[in] pSrc points to the block of input data.
  3283. * @param[out] pDst points to the block of output data
  3284. * @param[in] blockSize number of samples to process.
  3285. */
  3286. void arm_fir_lattice_q31(
  3287. const arm_fir_lattice_instance_q31 * S,
  3288. q31_t * pSrc,
  3289. q31_t * pDst,
  3290. uint32_t blockSize);
  3291. /**
  3292. * @brief Initialization function for the floating-point FIR lattice filter.
  3293. * @param[in] S points to an instance of the floating-point FIR lattice structure.
  3294. * @param[in] numStages number of filter stages.
  3295. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  3296. * @param[in] pState points to the state buffer. The array is of length numStages.
  3297. */
  3298. void arm_fir_lattice_init_f32(
  3299. arm_fir_lattice_instance_f32 * S,
  3300. uint16_t numStages,
  3301. float32_t * pCoeffs,
  3302. float32_t * pState);
  3303. /**
  3304. * @brief Processing function for the floating-point FIR lattice filter.
  3305. * @param[in] S points to an instance of the floating-point FIR lattice structure.
  3306. * @param[in] pSrc points to the block of input data.
  3307. * @param[out] pDst points to the block of output data
  3308. * @param[in] blockSize number of samples to process.
  3309. */
  3310. void arm_fir_lattice_f32(
  3311. const arm_fir_lattice_instance_f32 * S,
  3312. float32_t * pSrc,
  3313. float32_t * pDst,
  3314. uint32_t blockSize);
  3315. /**
  3316. * @brief Instance structure for the Q15 IIR lattice filter.
  3317. */
  3318. typedef struct
  3319. {
  3320. uint16_t numStages; /**< number of stages in the filter. */
  3321. q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3322. q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3323. q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3324. } arm_iir_lattice_instance_q15;
  3325. /**
  3326. * @brief Instance structure for the Q31 IIR lattice filter.
  3327. */
  3328. typedef struct
  3329. {
  3330. uint16_t numStages; /**< number of stages in the filter. */
  3331. q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3332. q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3333. q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3334. } arm_iir_lattice_instance_q31;
  3335. /**
  3336. * @brief Instance structure for the floating-point IIR lattice filter.
  3337. */
  3338. typedef struct
  3339. {
  3340. uint16_t numStages; /**< number of stages in the filter. */
  3341. float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3342. float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3343. float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3344. } arm_iir_lattice_instance_f32;
  3345. /**
  3346. * @brief Processing function for the floating-point IIR lattice filter.
  3347. * @param[in] S points to an instance of the floating-point IIR lattice structure.
  3348. * @param[in] pSrc points to the block of input data.
  3349. * @param[out] pDst points to the block of output data.
  3350. * @param[in] blockSize number of samples to process.
  3351. */
  3352. void arm_iir_lattice_f32(
  3353. const arm_iir_lattice_instance_f32 * S,
  3354. float32_t * pSrc,
  3355. float32_t * pDst,
  3356. uint32_t blockSize);
  3357. /**
  3358. * @brief Initialization function for the floating-point IIR lattice filter.
  3359. * @param[in] S points to an instance of the floating-point IIR lattice structure.
  3360. * @param[in] numStages number of stages in the filter.
  3361. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  3362. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  3363. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1.
  3364. * @param[in] blockSize number of samples to process.
  3365. */
  3366. void arm_iir_lattice_init_f32(
  3367. arm_iir_lattice_instance_f32 * S,
  3368. uint16_t numStages,
  3369. float32_t * pkCoeffs,
  3370. float32_t * pvCoeffs,
  3371. float32_t * pState,
  3372. uint32_t blockSize);
  3373. /**
  3374. * @brief Processing function for the Q31 IIR lattice filter.
  3375. * @param[in] S points to an instance of the Q31 IIR lattice structure.
  3376. * @param[in] pSrc points to the block of input data.
  3377. * @param[out] pDst points to the block of output data.
  3378. * @param[in] blockSize number of samples to process.
  3379. */
  3380. void arm_iir_lattice_q31(
  3381. const arm_iir_lattice_instance_q31 * S,
  3382. q31_t * pSrc,
  3383. q31_t * pDst,
  3384. uint32_t blockSize);
  3385. /**
  3386. * @brief Initialization function for the Q31 IIR lattice filter.
  3387. * @param[in] S points to an instance of the Q31 IIR lattice structure.
  3388. * @param[in] numStages number of stages in the filter.
  3389. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  3390. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  3391. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize.
  3392. * @param[in] blockSize number of samples to process.
  3393. */
  3394. void arm_iir_lattice_init_q31(
  3395. arm_iir_lattice_instance_q31 * S,
  3396. uint16_t numStages,
  3397. q31_t * pkCoeffs,
  3398. q31_t * pvCoeffs,
  3399. q31_t * pState,
  3400. uint32_t blockSize);
  3401. /**
  3402. * @brief Processing function for the Q15 IIR lattice filter.
  3403. * @param[in] S points to an instance of the Q15 IIR lattice structure.
  3404. * @param[in] pSrc points to the block of input data.
  3405. * @param[out] pDst points to the block of output data.
  3406. * @param[in] blockSize number of samples to process.
  3407. */
  3408. void arm_iir_lattice_q15(
  3409. const arm_iir_lattice_instance_q15 * S,
  3410. q15_t * pSrc,
  3411. q15_t * pDst,
  3412. uint32_t blockSize);
  3413. /**
  3414. * @brief Initialization function for the Q15 IIR lattice filter.
  3415. * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure.
  3416. * @param[in] numStages number of stages in the filter.
  3417. * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
  3418. * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
  3419. * @param[in] pState points to state buffer. The array is of length numStages+blockSize.
  3420. * @param[in] blockSize number of samples to process per call.
  3421. */
  3422. void arm_iir_lattice_init_q15(
  3423. arm_iir_lattice_instance_q15 * S,
  3424. uint16_t numStages,
  3425. q15_t * pkCoeffs,
  3426. q15_t * pvCoeffs,
  3427. q15_t * pState,
  3428. uint32_t blockSize);
  3429. /**
  3430. * @brief Instance structure for the floating-point LMS filter.
  3431. */
  3432. typedef struct
  3433. {
  3434. uint16_t numTaps; /**< number of coefficients in the filter. */
  3435. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3436. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3437. float32_t mu; /**< step size that controls filter coefficient updates. */
  3438. } arm_lms_instance_f32;
  3439. /**
  3440. * @brief Processing function for floating-point LMS filter.
  3441. * @param[in] S points to an instance of the floating-point LMS filter structure.
  3442. * @param[in] pSrc points to the block of input data.
  3443. * @param[in] pRef points to the block of reference data.
  3444. * @param[out] pOut points to the block of output data.
  3445. * @param[out] pErr points to the block of error data.
  3446. * @param[in] blockSize number of samples to process.
  3447. */
  3448. void arm_lms_f32(
  3449. const arm_lms_instance_f32 * S,
  3450. float32_t * pSrc,
  3451. float32_t * pRef,
  3452. float32_t * pOut,
  3453. float32_t * pErr,
  3454. uint32_t blockSize);
  3455. /**
  3456. * @brief Initialization function for floating-point LMS filter.
  3457. * @param[in] S points to an instance of the floating-point LMS filter structure.
  3458. * @param[in] numTaps number of filter coefficients.
  3459. * @param[in] pCoeffs points to the coefficient buffer.
  3460. * @param[in] pState points to state buffer.
  3461. * @param[in] mu step size that controls filter coefficient updates.
  3462. * @param[in] blockSize number of samples to process.
  3463. */
  3464. void arm_lms_init_f32(
  3465. arm_lms_instance_f32 * S,
  3466. uint16_t numTaps,
  3467. float32_t * pCoeffs,
  3468. float32_t * pState,
  3469. float32_t mu,
  3470. uint32_t blockSize);
  3471. /**
  3472. * @brief Instance structure for the Q15 LMS filter.
  3473. */
  3474. typedef struct
  3475. {
  3476. uint16_t numTaps; /**< number of coefficients in the filter. */
  3477. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3478. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3479. q15_t mu; /**< step size that controls filter coefficient updates. */
  3480. uint32_t postShift; /**< bit shift applied to coefficients. */
  3481. } arm_lms_instance_q15;
  3482. /**
  3483. * @brief Initialization function for the Q15 LMS filter.
  3484. * @param[in] S points to an instance of the Q15 LMS filter structure.
  3485. * @param[in] numTaps number of filter coefficients.
  3486. * @param[in] pCoeffs points to the coefficient buffer.
  3487. * @param[in] pState points to the state buffer.
  3488. * @param[in] mu step size that controls filter coefficient updates.
  3489. * @param[in] blockSize number of samples to process.
  3490. * @param[in] postShift bit shift applied to coefficients.
  3491. */
  3492. void arm_lms_init_q15(
  3493. arm_lms_instance_q15 * S,
  3494. uint16_t numTaps,
  3495. q15_t * pCoeffs,
  3496. q15_t * pState,
  3497. q15_t mu,
  3498. uint32_t blockSize,
  3499. uint32_t postShift);
  3500. /**
  3501. * @brief Processing function for Q15 LMS filter.
  3502. * @param[in] S points to an instance of the Q15 LMS filter structure.
  3503. * @param[in] pSrc points to the block of input data.
  3504. * @param[in] pRef points to the block of reference data.
  3505. * @param[out] pOut points to the block of output data.
  3506. * @param[out] pErr points to the block of error data.
  3507. * @param[in] blockSize number of samples to process.
  3508. */
  3509. void arm_lms_q15(
  3510. const arm_lms_instance_q15 * S,
  3511. q15_t * pSrc,
  3512. q15_t * pRef,
  3513. q15_t * pOut,
  3514. q15_t * pErr,
  3515. uint32_t blockSize);
  3516. /**
  3517. * @brief Instance structure for the Q31 LMS filter.
  3518. */
  3519. typedef struct
  3520. {
  3521. uint16_t numTaps; /**< number of coefficients in the filter. */
  3522. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3523. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3524. q31_t mu; /**< step size that controls filter coefficient updates. */
  3525. uint32_t postShift; /**< bit shift applied to coefficients. */
  3526. } arm_lms_instance_q31;
  3527. /**
  3528. * @brief Processing function for Q31 LMS filter.
  3529. * @param[in] S points to an instance of the Q15 LMS filter structure.
  3530. * @param[in] pSrc points to the block of input data.
  3531. * @param[in] pRef points to the block of reference data.
  3532. * @param[out] pOut points to the block of output data.
  3533. * @param[out] pErr points to the block of error data.
  3534. * @param[in] blockSize number of samples to process.
  3535. */
  3536. void arm_lms_q31(
  3537. const arm_lms_instance_q31 * S,
  3538. q31_t * pSrc,
  3539. q31_t * pRef,
  3540. q31_t * pOut,
  3541. q31_t * pErr,
  3542. uint32_t blockSize);
  3543. /**
  3544. * @brief Initialization function for Q31 LMS filter.
  3545. * @param[in] S points to an instance of the Q31 LMS filter structure.
  3546. * @param[in] numTaps number of filter coefficients.
  3547. * @param[in] pCoeffs points to coefficient buffer.
  3548. * @param[in] pState points to state buffer.
  3549. * @param[in] mu step size that controls filter coefficient updates.
  3550. * @param[in] blockSize number of samples to process.
  3551. * @param[in] postShift bit shift applied to coefficients.
  3552. */
  3553. void arm_lms_init_q31(
  3554. arm_lms_instance_q31 * S,
  3555. uint16_t numTaps,
  3556. q31_t * pCoeffs,
  3557. q31_t * pState,
  3558. q31_t mu,
  3559. uint32_t blockSize,
  3560. uint32_t postShift);
  3561. /**
  3562. * @brief Instance structure for the floating-point normalized LMS filter.
  3563. */
  3564. typedef struct
  3565. {
  3566. uint16_t numTaps; /**< number of coefficients in the filter. */
  3567. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3568. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3569. float32_t mu; /**< step size that control filter coefficient updates. */
  3570. float32_t energy; /**< saves previous frame energy. */
  3571. float32_t x0; /**< saves previous input sample. */
  3572. } arm_lms_norm_instance_f32;
  3573. /**
  3574. * @brief Processing function for floating-point normalized LMS filter.
  3575. * @param[in] S points to an instance of the floating-point normalized LMS filter structure.
  3576. * @param[in] pSrc points to the block of input data.
  3577. * @param[in] pRef points to the block of reference data.
  3578. * @param[out] pOut points to the block of output data.
  3579. * @param[out] pErr points to the block of error data.
  3580. * @param[in] blockSize number of samples to process.
  3581. */
  3582. void arm_lms_norm_f32(
  3583. arm_lms_norm_instance_f32 * S,
  3584. float32_t * pSrc,
  3585. float32_t * pRef,
  3586. float32_t * pOut,
  3587. float32_t * pErr,
  3588. uint32_t blockSize);
  3589. /**
  3590. * @brief Initialization function for floating-point normalized LMS filter.
  3591. * @param[in] S points to an instance of the floating-point LMS filter structure.
  3592. * @param[in] numTaps number of filter coefficients.
  3593. * @param[in] pCoeffs points to coefficient buffer.
  3594. * @param[in] pState points to state buffer.
  3595. * @param[in] mu step size that controls filter coefficient updates.
  3596. * @param[in] blockSize number of samples to process.
  3597. */
  3598. void arm_lms_norm_init_f32(
  3599. arm_lms_norm_instance_f32 * S,
  3600. uint16_t numTaps,
  3601. float32_t * pCoeffs,
  3602. float32_t * pState,
  3603. float32_t mu,
  3604. uint32_t blockSize);
  3605. /**
  3606. * @brief Instance structure for the Q31 normalized LMS filter.
  3607. */
  3608. typedef struct
  3609. {
  3610. uint16_t numTaps; /**< number of coefficients in the filter. */
  3611. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3612. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3613. q31_t mu; /**< step size that controls filter coefficient updates. */
  3614. uint8_t postShift; /**< bit shift applied to coefficients. */
  3615. q31_t *recipTable; /**< points to the reciprocal initial value table. */
  3616. q31_t energy; /**< saves previous frame energy. */
  3617. q31_t x0; /**< saves previous input sample. */
  3618. } arm_lms_norm_instance_q31;
  3619. /**
  3620. * @brief Processing function for Q31 normalized LMS filter.
  3621. * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
  3622. * @param[in] pSrc points to the block of input data.
  3623. * @param[in] pRef points to the block of reference data.
  3624. * @param[out] pOut points to the block of output data.
  3625. * @param[out] pErr points to the block of error data.
  3626. * @param[in] blockSize number of samples to process.
  3627. */
  3628. void arm_lms_norm_q31(
  3629. arm_lms_norm_instance_q31 * S,
  3630. q31_t * pSrc,
  3631. q31_t * pRef,
  3632. q31_t * pOut,
  3633. q31_t * pErr,
  3634. uint32_t blockSize);
  3635. /**
  3636. * @brief Initialization function for Q31 normalized LMS filter.
  3637. * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
  3638. * @param[in] numTaps number of filter coefficients.
  3639. * @param[in] pCoeffs points to coefficient buffer.
  3640. * @param[in] pState points to state buffer.
  3641. * @param[in] mu step size that controls filter coefficient updates.
  3642. * @param[in] blockSize number of samples to process.
  3643. * @param[in] postShift bit shift applied to coefficients.
  3644. */
  3645. void arm_lms_norm_init_q31(
  3646. arm_lms_norm_instance_q31 * S,
  3647. uint16_t numTaps,
  3648. q31_t * pCoeffs,
  3649. q31_t * pState,
  3650. q31_t mu,
  3651. uint32_t blockSize,
  3652. uint8_t postShift);
  3653. /**
  3654. * @brief Instance structure for the Q15 normalized LMS filter.
  3655. */
  3656. typedef struct
  3657. {
  3658. uint16_t numTaps; /**< Number of coefficients in the filter. */
  3659. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3660. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3661. q15_t mu; /**< step size that controls filter coefficient updates. */
  3662. uint8_t postShift; /**< bit shift applied to coefficients. */
  3663. q15_t *recipTable; /**< Points to the reciprocal initial value table. */
  3664. q15_t energy; /**< saves previous frame energy. */
  3665. q15_t x0; /**< saves previous input sample. */
  3666. } arm_lms_norm_instance_q15;
  3667. /**
  3668. * @brief Processing function for Q15 normalized LMS filter.
  3669. * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
  3670. * @param[in] pSrc points to the block of input data.
  3671. * @param[in] pRef points to the block of reference data.
  3672. * @param[out] pOut points to the block of output data.
  3673. * @param[out] pErr points to the block of error data.
  3674. * @param[in] blockSize number of samples to process.
  3675. */
  3676. void arm_lms_norm_q15(
  3677. arm_lms_norm_instance_q15 * S,
  3678. q15_t * pSrc,
  3679. q15_t * pRef,
  3680. q15_t * pOut,
  3681. q15_t * pErr,
  3682. uint32_t blockSize);
  3683. /**
  3684. * @brief Initialization function for Q15 normalized LMS filter.
  3685. * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
  3686. * @param[in] numTaps number of filter coefficients.
  3687. * @param[in] pCoeffs points to coefficient buffer.
  3688. * @param[in] pState points to state buffer.
  3689. * @param[in] mu step size that controls filter coefficient updates.
  3690. * @param[in] blockSize number of samples to process.
  3691. * @param[in] postShift bit shift applied to coefficients.
  3692. */
  3693. void arm_lms_norm_init_q15(
  3694. arm_lms_norm_instance_q15 * S,
  3695. uint16_t numTaps,
  3696. q15_t * pCoeffs,
  3697. q15_t * pState,
  3698. q15_t mu,
  3699. uint32_t blockSize,
  3700. uint8_t postShift);
  3701. /**
  3702. * @brief Correlation of floating-point sequences.
  3703. * @param[in] pSrcA points to the first input sequence.
  3704. * @param[in] srcALen length of the first input sequence.
  3705. * @param[in] pSrcB points to the second input sequence.
  3706. * @param[in] srcBLen length of the second input sequence.
  3707. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3708. */
  3709. void arm_correlate_f32(
  3710. float32_t * pSrcA,
  3711. uint32_t srcALen,
  3712. float32_t * pSrcB,
  3713. uint32_t srcBLen,
  3714. float32_t * pDst);
  3715. /**
  3716. * @brief Correlation of Q15 sequences
  3717. * @param[in] pSrcA points to the first input sequence.
  3718. * @param[in] srcALen length of the first input sequence.
  3719. * @param[in] pSrcB points to the second input sequence.
  3720. * @param[in] srcBLen length of the second input sequence.
  3721. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3722. * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3723. */
  3724. void arm_correlate_opt_q15(
  3725. q15_t * pSrcA,
  3726. uint32_t srcALen,
  3727. q15_t * pSrcB,
  3728. uint32_t srcBLen,
  3729. q15_t * pDst,
  3730. q15_t * pScratch);
  3731. /**
  3732. * @brief Correlation of Q15 sequences.
  3733. * @param[in] pSrcA points to the first input sequence.
  3734. * @param[in] srcALen length of the first input sequence.
  3735. * @param[in] pSrcB points to the second input sequence.
  3736. * @param[in] srcBLen length of the second input sequence.
  3737. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3738. */
  3739. void arm_correlate_q15(
  3740. q15_t * pSrcA,
  3741. uint32_t srcALen,
  3742. q15_t * pSrcB,
  3743. uint32_t srcBLen,
  3744. q15_t * pDst);
  3745. /**
  3746. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3747. * @param[in] pSrcA points to the first input sequence.
  3748. * @param[in] srcALen length of the first input sequence.
  3749. * @param[in] pSrcB points to the second input sequence.
  3750. * @param[in] srcBLen length of the second input sequence.
  3751. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3752. */
  3753. void arm_correlate_fast_q15(
  3754. q15_t * pSrcA,
  3755. uint32_t srcALen,
  3756. q15_t * pSrcB,
  3757. uint32_t srcBLen,
  3758. q15_t * pDst);
  3759. /**
  3760. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3761. * @param[in] pSrcA points to the first input sequence.
  3762. * @param[in] srcALen length of the first input sequence.
  3763. * @param[in] pSrcB points to the second input sequence.
  3764. * @param[in] srcBLen length of the second input sequence.
  3765. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3766. * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3767. */
  3768. void arm_correlate_fast_opt_q15(
  3769. q15_t * pSrcA,
  3770. uint32_t srcALen,
  3771. q15_t * pSrcB,
  3772. uint32_t srcBLen,
  3773. q15_t * pDst,
  3774. q15_t * pScratch);
  3775. /**
  3776. * @brief Correlation of Q31 sequences.
  3777. * @param[in] pSrcA points to the first input sequence.
  3778. * @param[in] srcALen length of the first input sequence.
  3779. * @param[in] pSrcB points to the second input sequence.
  3780. * @param[in] srcBLen length of the second input sequence.
  3781. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3782. */
  3783. void arm_correlate_q31(
  3784. q31_t * pSrcA,
  3785. uint32_t srcALen,
  3786. q31_t * pSrcB,
  3787. uint32_t srcBLen,
  3788. q31_t * pDst);
  3789. /**
  3790. * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  3791. * @param[in] pSrcA points to the first input sequence.
  3792. * @param[in] srcALen length of the first input sequence.
  3793. * @param[in] pSrcB points to the second input sequence.
  3794. * @param[in] srcBLen length of the second input sequence.
  3795. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3796. */
  3797. void arm_correlate_fast_q31(
  3798. q31_t * pSrcA,
  3799. uint32_t srcALen,
  3800. q31_t * pSrcB,
  3801. uint32_t srcBLen,
  3802. q31_t * pDst);
  3803. /**
  3804. * @brief Correlation of Q7 sequences.
  3805. * @param[in] pSrcA points to the first input sequence.
  3806. * @param[in] srcALen length of the first input sequence.
  3807. * @param[in] pSrcB points to the second input sequence.
  3808. * @param[in] srcBLen length of the second input sequence.
  3809. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3810. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3811. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  3812. */
  3813. void arm_correlate_opt_q7(
  3814. q7_t * pSrcA,
  3815. uint32_t srcALen,
  3816. q7_t * pSrcB,
  3817. uint32_t srcBLen,
  3818. q7_t * pDst,
  3819. q15_t * pScratch1,
  3820. q15_t * pScratch2);
  3821. /**
  3822. * @brief Correlation of Q7 sequences.
  3823. * @param[in] pSrcA points to the first input sequence.
  3824. * @param[in] srcALen length of the first input sequence.
  3825. * @param[in] pSrcB points to the second input sequence.
  3826. * @param[in] srcBLen length of the second input sequence.
  3827. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3828. */
  3829. void arm_correlate_q7(
  3830. q7_t * pSrcA,
  3831. uint32_t srcALen,
  3832. q7_t * pSrcB,
  3833. uint32_t srcBLen,
  3834. q7_t * pDst);
  3835. /**
  3836. * @brief Instance structure for the floating-point sparse FIR filter.
  3837. */
  3838. typedef struct
  3839. {
  3840. uint16_t numTaps; /**< number of coefficients in the filter. */
  3841. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3842. float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3843. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3844. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3845. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3846. } arm_fir_sparse_instance_f32;
  3847. /**
  3848. * @brief Instance structure for the Q31 sparse FIR filter.
  3849. */
  3850. typedef struct
  3851. {
  3852. uint16_t numTaps; /**< number of coefficients in the filter. */
  3853. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3854. q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3855. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3856. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3857. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3858. } arm_fir_sparse_instance_q31;
  3859. /**
  3860. * @brief Instance structure for the Q15 sparse FIR filter.
  3861. */
  3862. typedef struct
  3863. {
  3864. uint16_t numTaps; /**< number of coefficients in the filter. */
  3865. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3866. q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3867. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3868. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3869. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3870. } arm_fir_sparse_instance_q15;
  3871. /**
  3872. * @brief Instance structure for the Q7 sparse FIR filter.
  3873. */
  3874. typedef struct
  3875. {
  3876. uint16_t numTaps; /**< number of coefficients in the filter. */
  3877. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3878. q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3879. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3880. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3881. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3882. } arm_fir_sparse_instance_q7;
  3883. /**
  3884. * @brief Processing function for the floating-point sparse FIR filter.
  3885. * @param[in] S points to an instance of the floating-point sparse FIR structure.
  3886. * @param[in] pSrc points to the block of input data.
  3887. * @param[out] pDst points to the block of output data
  3888. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3889. * @param[in] blockSize number of input samples to process per call.
  3890. */
  3891. void arm_fir_sparse_f32(
  3892. arm_fir_sparse_instance_f32 * S,
  3893. float32_t * pSrc,
  3894. float32_t * pDst,
  3895. float32_t * pScratchIn,
  3896. uint32_t blockSize);
  3897. /**
  3898. * @brief Initialization function for the floating-point sparse FIR filter.
  3899. * @param[in,out] S points to an instance of the floating-point sparse FIR structure.
  3900. * @param[in] numTaps number of nonzero coefficients in the filter.
  3901. * @param[in] pCoeffs points to the array of filter coefficients.
  3902. * @param[in] pState points to the state buffer.
  3903. * @param[in] pTapDelay points to the array of offset times.
  3904. * @param[in] maxDelay maximum offset time supported.
  3905. * @param[in] blockSize number of samples that will be processed per block.
  3906. */
  3907. void arm_fir_sparse_init_f32(
  3908. arm_fir_sparse_instance_f32 * S,
  3909. uint16_t numTaps,
  3910. float32_t * pCoeffs,
  3911. float32_t * pState,
  3912. int32_t * pTapDelay,
  3913. uint16_t maxDelay,
  3914. uint32_t blockSize);
  3915. /**
  3916. * @brief Processing function for the Q31 sparse FIR filter.
  3917. * @param[in] S points to an instance of the Q31 sparse FIR structure.
  3918. * @param[in] pSrc points to the block of input data.
  3919. * @param[out] pDst points to the block of output data
  3920. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3921. * @param[in] blockSize number of input samples to process per call.
  3922. */
  3923. void arm_fir_sparse_q31(
  3924. arm_fir_sparse_instance_q31 * S,
  3925. q31_t * pSrc,
  3926. q31_t * pDst,
  3927. q31_t * pScratchIn,
  3928. uint32_t blockSize);
  3929. /**
  3930. * @brief Initialization function for the Q31 sparse FIR filter.
  3931. * @param[in,out] S points to an instance of the Q31 sparse FIR structure.
  3932. * @param[in] numTaps number of nonzero coefficients in the filter.
  3933. * @param[in] pCoeffs points to the array of filter coefficients.
  3934. * @param[in] pState points to the state buffer.
  3935. * @param[in] pTapDelay points to the array of offset times.
  3936. * @param[in] maxDelay maximum offset time supported.
  3937. * @param[in] blockSize number of samples that will be processed per block.
  3938. */
  3939. void arm_fir_sparse_init_q31(
  3940. arm_fir_sparse_instance_q31 * S,
  3941. uint16_t numTaps,
  3942. q31_t * pCoeffs,
  3943. q31_t * pState,
  3944. int32_t * pTapDelay,
  3945. uint16_t maxDelay,
  3946. uint32_t blockSize);
  3947. /**
  3948. * @brief Processing function for the Q15 sparse FIR filter.
  3949. * @param[in] S points to an instance of the Q15 sparse FIR structure.
  3950. * @param[in] pSrc points to the block of input data.
  3951. * @param[out] pDst points to the block of output data
  3952. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3953. * @param[in] pScratchOut points to a temporary buffer of size blockSize.
  3954. * @param[in] blockSize number of input samples to process per call.
  3955. */
  3956. void arm_fir_sparse_q15(
  3957. arm_fir_sparse_instance_q15 * S,
  3958. q15_t * pSrc,
  3959. q15_t * pDst,
  3960. q15_t * pScratchIn,
  3961. q31_t * pScratchOut,
  3962. uint32_t blockSize);
  3963. /**
  3964. * @brief Initialization function for the Q15 sparse FIR filter.
  3965. * @param[in,out] S points to an instance of the Q15 sparse FIR structure.
  3966. * @param[in] numTaps number of nonzero coefficients in the filter.
  3967. * @param[in] pCoeffs points to the array of filter coefficients.
  3968. * @param[in] pState points to the state buffer.
  3969. * @param[in] pTapDelay points to the array of offset times.
  3970. * @param[in] maxDelay maximum offset time supported.
  3971. * @param[in] blockSize number of samples that will be processed per block.
  3972. */
  3973. void arm_fir_sparse_init_q15(
  3974. arm_fir_sparse_instance_q15 * S,
  3975. uint16_t numTaps,
  3976. q15_t * pCoeffs,
  3977. q15_t * pState,
  3978. int32_t * pTapDelay,
  3979. uint16_t maxDelay,
  3980. uint32_t blockSize);
  3981. /**
  3982. * @brief Processing function for the Q7 sparse FIR filter.
  3983. * @param[in] S points to an instance of the Q7 sparse FIR structure.
  3984. * @param[in] pSrc points to the block of input data.
  3985. * @param[out] pDst points to the block of output data
  3986. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3987. * @param[in] pScratchOut points to a temporary buffer of size blockSize.
  3988. * @param[in] blockSize number of input samples to process per call.
  3989. */
  3990. void arm_fir_sparse_q7(
  3991. arm_fir_sparse_instance_q7 * S,
  3992. q7_t * pSrc,
  3993. q7_t * pDst,
  3994. q7_t * pScratchIn,
  3995. q31_t * pScratchOut,
  3996. uint32_t blockSize);
  3997. /**
  3998. * @brief Initialization function for the Q7 sparse FIR filter.
  3999. * @param[in,out] S points to an instance of the Q7 sparse FIR structure.
  4000. * @param[in] numTaps number of nonzero coefficients in the filter.
  4001. * @param[in] pCoeffs points to the array of filter coefficients.
  4002. * @param[in] pState points to the state buffer.
  4003. * @param[in] pTapDelay points to the array of offset times.
  4004. * @param[in] maxDelay maximum offset time supported.
  4005. * @param[in] blockSize number of samples that will be processed per block.
  4006. */
  4007. void arm_fir_sparse_init_q7(
  4008. arm_fir_sparse_instance_q7 * S,
  4009. uint16_t numTaps,
  4010. q7_t * pCoeffs,
  4011. q7_t * pState,
  4012. int32_t * pTapDelay,
  4013. uint16_t maxDelay,
  4014. uint32_t blockSize);
  4015. /**
  4016. * @brief Floating-point sin_cos function.
  4017. * @param[in] theta input value in degrees
  4018. * @param[out] pSinVal points to the processed sine output.
  4019. * @param[out] pCosVal points to the processed cos output.
  4020. */
  4021. void arm_sin_cos_f32(
  4022. float32_t theta,
  4023. float32_t * pSinVal,
  4024. float32_t * pCosVal);
  4025. /**
  4026. * @brief Q31 sin_cos function.
  4027. * @param[in] theta scaled input value in degrees
  4028. * @param[out] pSinVal points to the processed sine output.
  4029. * @param[out] pCosVal points to the processed cosine output.
  4030. */
  4031. void arm_sin_cos_q31(
  4032. q31_t theta,
  4033. q31_t * pSinVal,
  4034. q31_t * pCosVal);
  4035. /**
  4036. * @brief Floating-point complex conjugate.
  4037. * @param[in] pSrc points to the input vector
  4038. * @param[out] pDst points to the output vector
  4039. * @param[in] numSamples number of complex samples in each vector
  4040. */
  4041. void arm_cmplx_conj_f32(
  4042. float32_t * pSrc,
  4043. float32_t * pDst,
  4044. uint32_t numSamples);
  4045. /**
  4046. * @brief Q31 complex conjugate.
  4047. * @param[in] pSrc points to the input vector
  4048. * @param[out] pDst points to the output vector
  4049. * @param[in] numSamples number of complex samples in each vector
  4050. */
  4051. void arm_cmplx_conj_q31(
  4052. q31_t * pSrc,
  4053. q31_t * pDst,
  4054. uint32_t numSamples);
  4055. /**
  4056. * @brief Q15 complex conjugate.
  4057. * @param[in] pSrc points to the input vector
  4058. * @param[out] pDst points to the output vector
  4059. * @param[in] numSamples number of complex samples in each vector
  4060. */
  4061. void arm_cmplx_conj_q15(
  4062. q15_t * pSrc,
  4063. q15_t * pDst,
  4064. uint32_t numSamples);
  4065. /**
  4066. * @brief Floating-point complex magnitude squared
  4067. * @param[in] pSrc points to the complex input vector
  4068. * @param[out] pDst points to the real output vector
  4069. * @param[in] numSamples number of complex samples in the input vector
  4070. */
  4071. void arm_cmplx_mag_squared_f32(
  4072. float32_t * pSrc,
  4073. float32_t * pDst,
  4074. uint32_t numSamples);
  4075. /**
  4076. * @brief Q31 complex magnitude squared
  4077. * @param[in] pSrc points to the complex input vector
  4078. * @param[out] pDst points to the real output vector
  4079. * @param[in] numSamples number of complex samples in the input vector
  4080. */
  4081. void arm_cmplx_mag_squared_q31(
  4082. q31_t * pSrc,
  4083. q31_t * pDst,
  4084. uint32_t numSamples);
  4085. /**
  4086. * @brief Q15 complex magnitude squared
  4087. * @param[in] pSrc points to the complex input vector
  4088. * @param[out] pDst points to the real output vector
  4089. * @param[in] numSamples number of complex samples in the input vector
  4090. */
  4091. void arm_cmplx_mag_squared_q15(
  4092. q15_t * pSrc,
  4093. q15_t * pDst,
  4094. uint32_t numSamples);
  4095. /**
  4096. * @ingroup groupController
  4097. */
  4098. /**
  4099. * @defgroup PID PID Motor Control
  4100. *
  4101. * A Proportional Integral Derivative (PID) controller is a generic feedback control
  4102. * loop mechanism widely used in industrial control systems.
  4103. * A PID controller is the most commonly used type of feedback controller.
  4104. *
  4105. * This set of functions implements (PID) controllers
  4106. * for Q15, Q31, and floating-point data types. The functions operate on a single sample
  4107. * of data and each call to the function returns a single processed value.
  4108. * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
  4109. * is the input sample value. The functions return the output value.
  4110. *
  4111. * \par Algorithm:
  4112. * <pre>
  4113. * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
  4114. * A0 = Kp + Ki + Kd
  4115. * A1 = (-Kp ) - (2 * Kd )
  4116. * A2 = Kd </pre>
  4117. *
  4118. * \par
  4119. * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
  4120. *
  4121. * \par
  4122. * \image html PID.gif "Proportional Integral Derivative Controller"
  4123. *
  4124. * \par
  4125. * The PID controller calculates an "error" value as the difference between
  4126. * the measured output and the reference input.
  4127. * The controller attempts to minimize the error by adjusting the process control inputs.
  4128. * The proportional value determines the reaction to the current error,
  4129. * the integral value determines the reaction based on the sum of recent errors,
  4130. * and the derivative value determines the reaction based on the rate at which the error has been changing.
  4131. *
  4132. * \par Instance Structure
  4133. * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
  4134. * A separate instance structure must be defined for each PID Controller.
  4135. * There are separate instance structure declarations for each of the 3 supported data types.
  4136. *
  4137. * \par Reset Functions
  4138. * There is also an associated reset function for each data type which clears the state array.
  4139. *
  4140. * \par Initialization Functions
  4141. * There is also an associated initialization function for each data type.
  4142. * The initialization function performs the following operations:
  4143. * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
  4144. * - Zeros out the values in the state buffer.
  4145. *
  4146. * \par
  4147. * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
  4148. *
  4149. * \par Fixed-Point Behavior
  4150. * Care must be taken when using the fixed-point versions of the PID Controller functions.
  4151. * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
  4152. * Refer to the function specific documentation below for usage guidelines.
  4153. */
  4154. /**
  4155. * @addtogroup PID
  4156. * @{
  4157. */
  4158. /**
  4159. * @brief Process function for the floating-point PID Control.
  4160. * @param[in,out] S is an instance of the floating-point PID Control structure
  4161. * @param[in] in input sample to process
  4162. * @return out processed output sample.
  4163. */
  4164. static __INLINE float32_t arm_pid_f32(
  4165. arm_pid_instance_f32 * S,
  4166. float32_t in)
  4167. {
  4168. float32_t out;
  4169. /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
  4170. out = (S->A0 * in) +
  4171. (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
  4172. /* Update state */
  4173. S->state[1] = S->state[0];
  4174. S->state[0] = in;
  4175. S->state[2] = out;
  4176. /* return to application */
  4177. return (out);
  4178. }
  4179. /**
  4180. * @brief Process function for the Q31 PID Control.
  4181. * @param[in,out] S points to an instance of the Q31 PID Control structure
  4182. * @param[in] in input sample to process
  4183. * @return out processed output sample.
  4184. *
  4185. * <b>Scaling and Overflow Behavior:</b>
  4186. * \par
  4187. * The function is implemented using an internal 64-bit accumulator.
  4188. * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
  4189. * Thus, if the accumulator result overflows it wraps around rather than clip.
  4190. * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
  4191. * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
  4192. */
  4193. static __INLINE q31_t arm_pid_q31(
  4194. arm_pid_instance_q31 * S,
  4195. q31_t in)
  4196. {
  4197. q63_t acc;
  4198. q31_t out;
  4199. /* acc = A0 * x[n] */
  4200. acc = (q63_t) S->A0 * in;
  4201. /* acc += A1 * x[n-1] */
  4202. acc += (q63_t) S->A1 * S->state[0];
  4203. /* acc += A2 * x[n-2] */
  4204. acc += (q63_t) S->A2 * S->state[1];
  4205. /* convert output to 1.31 format to add y[n-1] */
  4206. out = (q31_t) (acc >> 31u);
  4207. /* out += y[n-1] */
  4208. out += S->state[2];
  4209. /* Update state */
  4210. S->state[1] = S->state[0];
  4211. S->state[0] = in;
  4212. S->state[2] = out;
  4213. /* return to application */
  4214. return (out);
  4215. }
  4216. /**
  4217. * @brief Process function for the Q15 PID Control.
  4218. * @param[in,out] S points to an instance of the Q15 PID Control structure
  4219. * @param[in] in input sample to process
  4220. * @return out processed output sample.
  4221. *
  4222. * <b>Scaling and Overflow Behavior:</b>
  4223. * \par
  4224. * The function is implemented using a 64-bit internal accumulator.
  4225. * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
  4226. * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
  4227. * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
  4228. * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
  4229. * Lastly, the accumulator is saturated to yield a result in 1.15 format.
  4230. */
  4231. static __INLINE q15_t arm_pid_q15(
  4232. arm_pid_instance_q15 * S,
  4233. q15_t in)
  4234. {
  4235. q63_t acc;
  4236. q15_t out;
  4237. #ifndef ARM_MATH_CM0_FAMILY
  4238. __SIMD32_TYPE *vstate;
  4239. /* Implementation of PID controller */
  4240. /* acc = A0 * x[n] */
  4241. acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in);
  4242. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  4243. vstate = __SIMD32_CONST(S->state);
  4244. acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)*vstate, (uint64_t)acc);
  4245. #else
  4246. /* acc = A0 * x[n] */
  4247. acc = ((q31_t) S->A0) * in;
  4248. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  4249. acc += (q31_t) S->A1 * S->state[0];
  4250. acc += (q31_t) S->A2 * S->state[1];
  4251. #endif
  4252. /* acc += y[n-1] */
  4253. acc += (q31_t) S->state[2] << 15;
  4254. /* saturate the output */
  4255. out = (q15_t) (__SSAT((acc >> 15), 16));
  4256. /* Update state */
  4257. S->state[1] = S->state[0];
  4258. S->state[0] = in;
  4259. S->state[2] = out;
  4260. /* return to application */
  4261. return (out);
  4262. }
  4263. /**
  4264. * @} end of PID group
  4265. */
  4266. /**
  4267. * @brief Floating-point matrix inverse.
  4268. * @param[in] src points to the instance of the input floating-point matrix structure.
  4269. * @param[out] dst points to the instance of the output floating-point matrix structure.
  4270. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  4271. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  4272. */
  4273. arm_status arm_mat_inverse_f32(
  4274. const arm_matrix_instance_f32 * src,
  4275. arm_matrix_instance_f32 * dst);
  4276. /**
  4277. * @brief Floating-point matrix inverse.
  4278. * @param[in] src points to the instance of the input floating-point matrix structure.
  4279. * @param[out] dst points to the instance of the output floating-point matrix structure.
  4280. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  4281. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  4282. */
  4283. arm_status arm_mat_inverse_f64(
  4284. const arm_matrix_instance_f64 * src,
  4285. arm_matrix_instance_f64 * dst);
  4286. /**
  4287. * @ingroup groupController
  4288. */
  4289. /**
  4290. * @defgroup clarke Vector Clarke Transform
  4291. * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
  4292. * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
  4293. * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
  4294. * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
  4295. * \image html clarke.gif Stator current space vector and its components in (a,b).
  4296. * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
  4297. * can be calculated using only <code>Ia</code> and <code>Ib</code>.
  4298. *
  4299. * The function operates on a single sample of data and each call to the function returns the processed output.
  4300. * The library provides separate functions for Q31 and floating-point data types.
  4301. * \par Algorithm
  4302. * \image html clarkeFormula.gif
  4303. * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
  4304. * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
  4305. * \par Fixed-Point Behavior
  4306. * Care must be taken when using the Q31 version of the Clarke transform.
  4307. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4308. * Refer to the function specific documentation below for usage guidelines.
  4309. */
  4310. /**
  4311. * @addtogroup clarke
  4312. * @{
  4313. */
  4314. /**
  4315. *
  4316. * @brief Floating-point Clarke transform
  4317. * @param[in] Ia input three-phase coordinate <code>a</code>
  4318. * @param[in] Ib input three-phase coordinate <code>b</code>
  4319. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  4320. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  4321. */
  4322. static __INLINE void arm_clarke_f32(
  4323. float32_t Ia,
  4324. float32_t Ib,
  4325. float32_t * pIalpha,
  4326. float32_t * pIbeta)
  4327. {
  4328. /* Calculate pIalpha using the equation, pIalpha = Ia */
  4329. *pIalpha = Ia;
  4330. /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
  4331. *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
  4332. }
  4333. /**
  4334. * @brief Clarke transform for Q31 version
  4335. * @param[in] Ia input three-phase coordinate <code>a</code>
  4336. * @param[in] Ib input three-phase coordinate <code>b</code>
  4337. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  4338. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  4339. *
  4340. * <b>Scaling and Overflow Behavior:</b>
  4341. * \par
  4342. * The function is implemented using an internal 32-bit accumulator.
  4343. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4344. * There is saturation on the addition, hence there is no risk of overflow.
  4345. */
  4346. static __INLINE void arm_clarke_q31(
  4347. q31_t Ia,
  4348. q31_t Ib,
  4349. q31_t * pIalpha,
  4350. q31_t * pIbeta)
  4351. {
  4352. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4353. /* Calculating pIalpha from Ia by equation pIalpha = Ia */
  4354. *pIalpha = Ia;
  4355. /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
  4356. product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
  4357. /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
  4358. product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
  4359. /* pIbeta is calculated by adding the intermediate products */
  4360. *pIbeta = __QADD(product1, product2);
  4361. }
  4362. /**
  4363. * @} end of clarke group
  4364. */
  4365. /**
  4366. * @brief Converts the elements of the Q7 vector to Q31 vector.
  4367. * @param[in] pSrc input pointer
  4368. * @param[out] pDst output pointer
  4369. * @param[in] blockSize number of samples to process
  4370. */
  4371. void arm_q7_to_q31(
  4372. q7_t * pSrc,
  4373. q31_t * pDst,
  4374. uint32_t blockSize);
  4375. /**
  4376. * @ingroup groupController
  4377. */
  4378. /**
  4379. * @defgroup inv_clarke Vector Inverse Clarke Transform
  4380. * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
  4381. *
  4382. * The function operates on a single sample of data and each call to the function returns the processed output.
  4383. * The library provides separate functions for Q31 and floating-point data types.
  4384. * \par Algorithm
  4385. * \image html clarkeInvFormula.gif
  4386. * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
  4387. * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
  4388. * \par Fixed-Point Behavior
  4389. * Care must be taken when using the Q31 version of the Clarke transform.
  4390. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4391. * Refer to the function specific documentation below for usage guidelines.
  4392. */
  4393. /**
  4394. * @addtogroup inv_clarke
  4395. * @{
  4396. */
  4397. /**
  4398. * @brief Floating-point Inverse Clarke transform
  4399. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  4400. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  4401. * @param[out] pIa points to output three-phase coordinate <code>a</code>
  4402. * @param[out] pIb points to output three-phase coordinate <code>b</code>
  4403. */
  4404. static __INLINE void arm_inv_clarke_f32(
  4405. float32_t Ialpha,
  4406. float32_t Ibeta,
  4407. float32_t * pIa,
  4408. float32_t * pIb)
  4409. {
  4410. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  4411. *pIa = Ialpha;
  4412. /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
  4413. *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta;
  4414. }
  4415. /**
  4416. * @brief Inverse Clarke transform for Q31 version
  4417. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  4418. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  4419. * @param[out] pIa points to output three-phase coordinate <code>a</code>
  4420. * @param[out] pIb points to output three-phase coordinate <code>b</code>
  4421. *
  4422. * <b>Scaling and Overflow Behavior:</b>
  4423. * \par
  4424. * The function is implemented using an internal 32-bit accumulator.
  4425. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4426. * There is saturation on the subtraction, hence there is no risk of overflow.
  4427. */
  4428. static __INLINE void arm_inv_clarke_q31(
  4429. q31_t Ialpha,
  4430. q31_t Ibeta,
  4431. q31_t * pIa,
  4432. q31_t * pIb)
  4433. {
  4434. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4435. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  4436. *pIa = Ialpha;
  4437. /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
  4438. product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
  4439. /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
  4440. product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
  4441. /* pIb is calculated by subtracting the products */
  4442. *pIb = __QSUB(product2, product1);
  4443. }
  4444. /**
  4445. * @} end of inv_clarke group
  4446. */
  4447. /**
  4448. * @brief Converts the elements of the Q7 vector to Q15 vector.
  4449. * @param[in] pSrc input pointer
  4450. * @param[out] pDst output pointer
  4451. * @param[in] blockSize number of samples to process
  4452. */
  4453. void arm_q7_to_q15(
  4454. q7_t * pSrc,
  4455. q15_t * pDst,
  4456. uint32_t blockSize);
  4457. /**
  4458. * @ingroup groupController
  4459. */
  4460. /**
  4461. * @defgroup park Vector Park Transform
  4462. *
  4463. * Forward Park transform converts the input two-coordinate vector to flux and torque components.
  4464. * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
  4465. * from the stationary to the moving reference frame and control the spatial relationship between
  4466. * the stator vector current and rotor flux vector.
  4467. * If we consider the d axis aligned with the rotor flux, the diagram below shows the
  4468. * current vector and the relationship from the two reference frames:
  4469. * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
  4470. *
  4471. * The function operates on a single sample of data and each call to the function returns the processed output.
  4472. * The library provides separate functions for Q31 and floating-point data types.
  4473. * \par Algorithm
  4474. * \image html parkFormula.gif
  4475. * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
  4476. * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  4477. * cosine and sine values of theta (rotor flux position).
  4478. * \par Fixed-Point Behavior
  4479. * Care must be taken when using the Q31 version of the Park transform.
  4480. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4481. * Refer to the function specific documentation below for usage guidelines.
  4482. */
  4483. /**
  4484. * @addtogroup park
  4485. * @{
  4486. */
  4487. /**
  4488. * @brief Floating-point Park transform
  4489. * @param[in] Ialpha input two-phase vector coordinate alpha
  4490. * @param[in] Ibeta input two-phase vector coordinate beta
  4491. * @param[out] pId points to output rotor reference frame d
  4492. * @param[out] pIq points to output rotor reference frame q
  4493. * @param[in] sinVal sine value of rotation angle theta
  4494. * @param[in] cosVal cosine value of rotation angle theta
  4495. *
  4496. * The function implements the forward Park transform.
  4497. *
  4498. */
  4499. static __INLINE void arm_park_f32(
  4500. float32_t Ialpha,
  4501. float32_t Ibeta,
  4502. float32_t * pId,
  4503. float32_t * pIq,
  4504. float32_t sinVal,
  4505. float32_t cosVal)
  4506. {
  4507. /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
  4508. *pId = Ialpha * cosVal + Ibeta * sinVal;
  4509. /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
  4510. *pIq = -Ialpha * sinVal + Ibeta * cosVal;
  4511. }
  4512. /**
  4513. * @brief Park transform for Q31 version
  4514. * @param[in] Ialpha input two-phase vector coordinate alpha
  4515. * @param[in] Ibeta input two-phase vector coordinate beta
  4516. * @param[out] pId points to output rotor reference frame d
  4517. * @param[out] pIq points to output rotor reference frame q
  4518. * @param[in] sinVal sine value of rotation angle theta
  4519. * @param[in] cosVal cosine value of rotation angle theta
  4520. *
  4521. * <b>Scaling and Overflow Behavior:</b>
  4522. * \par
  4523. * The function is implemented using an internal 32-bit accumulator.
  4524. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4525. * There is saturation on the addition and subtraction, hence there is no risk of overflow.
  4526. */
  4527. static __INLINE void arm_park_q31(
  4528. q31_t Ialpha,
  4529. q31_t Ibeta,
  4530. q31_t * pId,
  4531. q31_t * pIq,
  4532. q31_t sinVal,
  4533. q31_t cosVal)
  4534. {
  4535. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4536. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  4537. /* Intermediate product is calculated by (Ialpha * cosVal) */
  4538. product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
  4539. /* Intermediate product is calculated by (Ibeta * sinVal) */
  4540. product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
  4541. /* Intermediate product is calculated by (Ialpha * sinVal) */
  4542. product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
  4543. /* Intermediate product is calculated by (Ibeta * cosVal) */
  4544. product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
  4545. /* Calculate pId by adding the two intermediate products 1 and 2 */
  4546. *pId = __QADD(product1, product2);
  4547. /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
  4548. *pIq = __QSUB(product4, product3);
  4549. }
  4550. /**
  4551. * @} end of park group
  4552. */
  4553. /**
  4554. * @brief Converts the elements of the Q7 vector to floating-point vector.
  4555. * @param[in] pSrc is input pointer
  4556. * @param[out] pDst is output pointer
  4557. * @param[in] blockSize is the number of samples to process
  4558. */
  4559. void arm_q7_to_float(
  4560. q7_t * pSrc,
  4561. float32_t * pDst,
  4562. uint32_t blockSize);
  4563. /**
  4564. * @ingroup groupController
  4565. */
  4566. /**
  4567. * @defgroup inv_park Vector Inverse Park transform
  4568. * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
  4569. *
  4570. * The function operates on a single sample of data and each call to the function returns the processed output.
  4571. * The library provides separate functions for Q31 and floating-point data types.
  4572. * \par Algorithm
  4573. * \image html parkInvFormula.gif
  4574. * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
  4575. * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  4576. * cosine and sine values of theta (rotor flux position).
  4577. * \par Fixed-Point Behavior
  4578. * Care must be taken when using the Q31 version of the Park transform.
  4579. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4580. * Refer to the function specific documentation below for usage guidelines.
  4581. */
  4582. /**
  4583. * @addtogroup inv_park
  4584. * @{
  4585. */
  4586. /**
  4587. * @brief Floating-point Inverse Park transform
  4588. * @param[in] Id input coordinate of rotor reference frame d
  4589. * @param[in] Iq input coordinate of rotor reference frame q
  4590. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  4591. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  4592. * @param[in] sinVal sine value of rotation angle theta
  4593. * @param[in] cosVal cosine value of rotation angle theta
  4594. */
  4595. static __INLINE void arm_inv_park_f32(
  4596. float32_t Id,
  4597. float32_t Iq,
  4598. float32_t * pIalpha,
  4599. float32_t * pIbeta,
  4600. float32_t sinVal,
  4601. float32_t cosVal)
  4602. {
  4603. /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
  4604. *pIalpha = Id * cosVal - Iq * sinVal;
  4605. /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
  4606. *pIbeta = Id * sinVal + Iq * cosVal;
  4607. }
  4608. /**
  4609. * @brief Inverse Park transform for Q31 version
  4610. * @param[in] Id input coordinate of rotor reference frame d
  4611. * @param[in] Iq input coordinate of rotor reference frame q
  4612. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  4613. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  4614. * @param[in] sinVal sine value of rotation angle theta
  4615. * @param[in] cosVal cosine value of rotation angle theta
  4616. *
  4617. * <b>Scaling and Overflow Behavior:</b>
  4618. * \par
  4619. * The function is implemented using an internal 32-bit accumulator.
  4620. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4621. * There is saturation on the addition, hence there is no risk of overflow.
  4622. */
  4623. static __INLINE void arm_inv_park_q31(
  4624. q31_t Id,
  4625. q31_t Iq,
  4626. q31_t * pIalpha,
  4627. q31_t * pIbeta,
  4628. q31_t sinVal,
  4629. q31_t cosVal)
  4630. {
  4631. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4632. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  4633. /* Intermediate product is calculated by (Id * cosVal) */
  4634. product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
  4635. /* Intermediate product is calculated by (Iq * sinVal) */
  4636. product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
  4637. /* Intermediate product is calculated by (Id * sinVal) */
  4638. product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
  4639. /* Intermediate product is calculated by (Iq * cosVal) */
  4640. product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
  4641. /* Calculate pIalpha by using the two intermediate products 1 and 2 */
  4642. *pIalpha = __QSUB(product1, product2);
  4643. /* Calculate pIbeta by using the two intermediate products 3 and 4 */
  4644. *pIbeta = __QADD(product4, product3);
  4645. }
  4646. /**
  4647. * @} end of Inverse park group
  4648. */
  4649. /**
  4650. * @brief Converts the elements of the Q31 vector to floating-point vector.
  4651. * @param[in] pSrc is input pointer
  4652. * @param[out] pDst is output pointer
  4653. * @param[in] blockSize is the number of samples to process
  4654. */
  4655. void arm_q31_to_float(
  4656. q31_t * pSrc,
  4657. float32_t * pDst,
  4658. uint32_t blockSize);
  4659. /**
  4660. * @ingroup groupInterpolation
  4661. */
  4662. /**
  4663. * @defgroup LinearInterpolate Linear Interpolation
  4664. *
  4665. * Linear interpolation is a method of curve fitting using linear polynomials.
  4666. * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
  4667. *
  4668. * \par
  4669. * \image html LinearInterp.gif "Linear interpolation"
  4670. *
  4671. * \par
  4672. * A Linear Interpolate function calculates an output value(y), for the input(x)
  4673. * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
  4674. *
  4675. * \par Algorithm:
  4676. * <pre>
  4677. * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
  4678. * where x0, x1 are nearest values of input x
  4679. * y0, y1 are nearest values to output y
  4680. * </pre>
  4681. *
  4682. * \par
  4683. * This set of functions implements Linear interpolation process
  4684. * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
  4685. * sample of data and each call to the function returns a single processed value.
  4686. * <code>S</code> points to an instance of the Linear Interpolate function data structure.
  4687. * <code>x</code> is the input sample value. The functions returns the output value.
  4688. *
  4689. * \par
  4690. * if x is outside of the table boundary, Linear interpolation returns first value of the table
  4691. * if x is below input range and returns last value of table if x is above range.
  4692. */
  4693. /**
  4694. * @addtogroup LinearInterpolate
  4695. * @{
  4696. */
  4697. /**
  4698. * @brief Process function for the floating-point Linear Interpolation Function.
  4699. * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
  4700. * @param[in] x input sample to process
  4701. * @return y processed output sample.
  4702. *
  4703. */
  4704. static __INLINE float32_t arm_linear_interp_f32(
  4705. arm_linear_interp_instance_f32 * S,
  4706. float32_t x)
  4707. {
  4708. float32_t y;
  4709. float32_t x0, x1; /* Nearest input values */
  4710. float32_t y0, y1; /* Nearest output values */
  4711. float32_t xSpacing = S->xSpacing; /* spacing between input values */
  4712. int32_t i; /* Index variable */
  4713. float32_t *pYData = S->pYData; /* pointer to output table */
  4714. /* Calculation of index */
  4715. i = (int32_t) ((x - S->x1) / xSpacing);
  4716. if(i < 0)
  4717. {
  4718. /* Iniatilize output for below specified range as least output value of table */
  4719. y = pYData[0];
  4720. }
  4721. else if((uint32_t)i >= S->nValues)
  4722. {
  4723. /* Iniatilize output for above specified range as last output value of table */
  4724. y = pYData[S->nValues - 1];
  4725. }
  4726. else
  4727. {
  4728. /* Calculation of nearest input values */
  4729. x0 = S->x1 + i * xSpacing;
  4730. x1 = S->x1 + (i + 1) * xSpacing;
  4731. /* Read of nearest output values */
  4732. y0 = pYData[i];
  4733. y1 = pYData[i + 1];
  4734. /* Calculation of output */
  4735. y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
  4736. }
  4737. /* returns output value */
  4738. return (y);
  4739. }
  4740. /**
  4741. *
  4742. * @brief Process function for the Q31 Linear Interpolation Function.
  4743. * @param[in] pYData pointer to Q31 Linear Interpolation table
  4744. * @param[in] x input sample to process
  4745. * @param[in] nValues number of table values
  4746. * @return y processed output sample.
  4747. *
  4748. * \par
  4749. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4750. * This function can support maximum of table size 2^12.
  4751. *
  4752. */
  4753. static __INLINE q31_t arm_linear_interp_q31(
  4754. q31_t * pYData,
  4755. q31_t x,
  4756. uint32_t nValues)
  4757. {
  4758. q31_t y; /* output */
  4759. q31_t y0, y1; /* Nearest output values */
  4760. q31_t fract; /* fractional part */
  4761. int32_t index; /* Index to read nearest output values */
  4762. /* Input is in 12.20 format */
  4763. /* 12 bits for the table index */
  4764. /* Index value calculation */
  4765. index = ((x & (q31_t)0xFFF00000) >> 20);
  4766. if(index >= (int32_t)(nValues - 1))
  4767. {
  4768. return (pYData[nValues - 1]);
  4769. }
  4770. else if(index < 0)
  4771. {
  4772. return (pYData[0]);
  4773. }
  4774. else
  4775. {
  4776. /* 20 bits for the fractional part */
  4777. /* shift left by 11 to keep fract in 1.31 format */
  4778. fract = (x & 0x000FFFFF) << 11;
  4779. /* Read two nearest output values from the index in 1.31(q31) format */
  4780. y0 = pYData[index];
  4781. y1 = pYData[index + 1];
  4782. /* Calculation of y0 * (1-fract) and y is in 2.30 format */
  4783. y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
  4784. /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
  4785. y += ((q31_t) (((q63_t) y1 * fract) >> 32));
  4786. /* Convert y to 1.31 format */
  4787. return (y << 1u);
  4788. }
  4789. }
  4790. /**
  4791. *
  4792. * @brief Process function for the Q15 Linear Interpolation Function.
  4793. * @param[in] pYData pointer to Q15 Linear Interpolation table
  4794. * @param[in] x input sample to process
  4795. * @param[in] nValues number of table values
  4796. * @return y processed output sample.
  4797. *
  4798. * \par
  4799. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4800. * This function can support maximum of table size 2^12.
  4801. *
  4802. */
  4803. static __INLINE q15_t arm_linear_interp_q15(
  4804. q15_t * pYData,
  4805. q31_t x,
  4806. uint32_t nValues)
  4807. {
  4808. q63_t y; /* output */
  4809. q15_t y0, y1; /* Nearest output values */
  4810. q31_t fract; /* fractional part */
  4811. int32_t index; /* Index to read nearest output values */
  4812. /* Input is in 12.20 format */
  4813. /* 12 bits for the table index */
  4814. /* Index value calculation */
  4815. index = ((x & (int32_t)0xFFF00000) >> 20);
  4816. if(index >= (int32_t)(nValues - 1))
  4817. {
  4818. return (pYData[nValues - 1]);
  4819. }
  4820. else if(index < 0)
  4821. {
  4822. return (pYData[0]);
  4823. }
  4824. else
  4825. {
  4826. /* 20 bits for the fractional part */
  4827. /* fract is in 12.20 format */
  4828. fract = (x & 0x000FFFFF);
  4829. /* Read two nearest output values from the index */
  4830. y0 = pYData[index];
  4831. y1 = pYData[index + 1];
  4832. /* Calculation of y0 * (1-fract) and y is in 13.35 format */
  4833. y = ((q63_t) y0 * (0xFFFFF - fract));
  4834. /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
  4835. y += ((q63_t) y1 * (fract));
  4836. /* convert y to 1.15 format */
  4837. return (q15_t) (y >> 20);
  4838. }
  4839. }
  4840. /**
  4841. *
  4842. * @brief Process function for the Q7 Linear Interpolation Function.
  4843. * @param[in] pYData pointer to Q7 Linear Interpolation table
  4844. * @param[in] x input sample to process
  4845. * @param[in] nValues number of table values
  4846. * @return y processed output sample.
  4847. *
  4848. * \par
  4849. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4850. * This function can support maximum of table size 2^12.
  4851. */
  4852. static __INLINE q7_t arm_linear_interp_q7(
  4853. q7_t * pYData,
  4854. q31_t x,
  4855. uint32_t nValues)
  4856. {
  4857. q31_t y; /* output */
  4858. q7_t y0, y1; /* Nearest output values */
  4859. q31_t fract; /* fractional part */
  4860. uint32_t index; /* Index to read nearest output values */
  4861. /* Input is in 12.20 format */
  4862. /* 12 bits for the table index */
  4863. /* Index value calculation */
  4864. if (x < 0)
  4865. {
  4866. return (pYData[0]);
  4867. }
  4868. index = (x >> 20) & 0xfff;
  4869. if(index >= (nValues - 1))
  4870. {
  4871. return (pYData[nValues - 1]);
  4872. }
  4873. else
  4874. {
  4875. /* 20 bits for the fractional part */
  4876. /* fract is in 12.20 format */
  4877. fract = (x & 0x000FFFFF);
  4878. /* Read two nearest output values from the index and are in 1.7(q7) format */
  4879. y0 = pYData[index];
  4880. y1 = pYData[index + 1];
  4881. /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
  4882. y = ((y0 * (0xFFFFF - fract)));
  4883. /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
  4884. y += (y1 * fract);
  4885. /* convert y to 1.7(q7) format */
  4886. return (q7_t) (y >> 20);
  4887. }
  4888. }
  4889. /**
  4890. * @} end of LinearInterpolate group
  4891. */
  4892. /**
  4893. * @brief Fast approximation to the trigonometric sine function for floating-point data.
  4894. * @param[in] x input value in radians.
  4895. * @return sin(x).
  4896. */
  4897. float32_t arm_sin_f32(
  4898. float32_t x);
  4899. /**
  4900. * @brief Fast approximation to the trigonometric sine function for Q31 data.
  4901. * @param[in] x Scaled input value in radians.
  4902. * @return sin(x).
  4903. */
  4904. q31_t arm_sin_q31(
  4905. q31_t x);
  4906. /**
  4907. * @brief Fast approximation to the trigonometric sine function for Q15 data.
  4908. * @param[in] x Scaled input value in radians.
  4909. * @return sin(x).
  4910. */
  4911. q15_t arm_sin_q15(
  4912. q15_t x);
  4913. /**
  4914. * @brief Fast approximation to the trigonometric cosine function for floating-point data.
  4915. * @param[in] x input value in radians.
  4916. * @return cos(x).
  4917. */
  4918. float32_t arm_cos_f32(
  4919. float32_t x);
  4920. /**
  4921. * @brief Fast approximation to the trigonometric cosine function for Q31 data.
  4922. * @param[in] x Scaled input value in radians.
  4923. * @return cos(x).
  4924. */
  4925. q31_t arm_cos_q31(
  4926. q31_t x);
  4927. /**
  4928. * @brief Fast approximation to the trigonometric cosine function for Q15 data.
  4929. * @param[in] x Scaled input value in radians.
  4930. * @return cos(x).
  4931. */
  4932. q15_t arm_cos_q15(
  4933. q15_t x);
  4934. /**
  4935. * @ingroup groupFastMath
  4936. */
  4937. /**
  4938. * @defgroup SQRT Square Root
  4939. *
  4940. * Computes the square root of a number.
  4941. * There are separate functions for Q15, Q31, and floating-point data types.
  4942. * The square root function is computed using the Newton-Raphson algorithm.
  4943. * This is an iterative algorithm of the form:
  4944. * <pre>
  4945. * x1 = x0 - f(x0)/f'(x0)
  4946. * </pre>
  4947. * where <code>x1</code> is the current estimate,
  4948. * <code>x0</code> is the previous estimate, and
  4949. * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
  4950. * For the square root function, the algorithm reduces to:
  4951. * <pre>
  4952. * x0 = in/2 [initial guess]
  4953. * x1 = 1/2 * ( x0 + in / x0) [each iteration]
  4954. * </pre>
  4955. */
  4956. /**
  4957. * @addtogroup SQRT
  4958. * @{
  4959. */
  4960. /**
  4961. * @brief Floating-point square root function.
  4962. * @param[in] in input value.
  4963. * @param[out] pOut square root of input value.
  4964. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4965. * <code>in</code> is negative value and returns zero output for negative values.
  4966. */
  4967. static __INLINE arm_status arm_sqrt_f32(
  4968. float32_t in,
  4969. float32_t * pOut)
  4970. {
  4971. if(in >= 0.0f)
  4972. {
  4973. #if (__FPU_USED == 1) && defined ( __CC_ARM )
  4974. *pOut = __sqrtf(in);
  4975. #elif (__FPU_USED == 1) && (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
  4976. *pOut = __builtin_sqrtf(in);
  4977. #elif (__FPU_USED == 1) && defined(__GNUC__)
  4978. *pOut = __builtin_sqrtf(in);
  4979. #elif (__FPU_USED == 1) && defined ( __ICCARM__ ) && (__VER__ >= 6040000)
  4980. __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in));
  4981. #else
  4982. *pOut = sqrtf(in);
  4983. #endif
  4984. return (ARM_MATH_SUCCESS);
  4985. }
  4986. else
  4987. {
  4988. *pOut = 0.0f;
  4989. return (ARM_MATH_ARGUMENT_ERROR);
  4990. }
  4991. }
  4992. /**
  4993. * @brief Q31 square root function.
  4994. * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
  4995. * @param[out] pOut square root of input value.
  4996. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4997. * <code>in</code> is negative value and returns zero output for negative values.
  4998. */
  4999. arm_status arm_sqrt_q31(
  5000. q31_t in,
  5001. q31_t * pOut);
  5002. /**
  5003. * @brief Q15 square root function.
  5004. * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
  5005. * @param[out] pOut square root of input value.
  5006. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  5007. * <code>in</code> is negative value and returns zero output for negative values.
  5008. */
  5009. arm_status arm_sqrt_q15(
  5010. q15_t in,
  5011. q15_t * pOut);
  5012. /**
  5013. * @} end of SQRT group
  5014. */
  5015. /**
  5016. * @brief floating-point Circular write function.
  5017. */
  5018. static __INLINE void arm_circularWrite_f32(
  5019. int32_t * circBuffer,
  5020. int32_t L,
  5021. uint16_t * writeOffset,
  5022. int32_t bufferInc,
  5023. const int32_t * src,
  5024. int32_t srcInc,
  5025. uint32_t blockSize)
  5026. {
  5027. uint32_t i = 0u;
  5028. int32_t wOffset;
  5029. /* Copy the value of Index pointer that points
  5030. * to the current location where the input samples to be copied */
  5031. wOffset = *writeOffset;
  5032. /* Loop over the blockSize */
  5033. i = blockSize;
  5034. while(i > 0u)
  5035. {
  5036. /* copy the input sample to the circular buffer */
  5037. circBuffer[wOffset] = *src;
  5038. /* Update the input pointer */
  5039. src += srcInc;
  5040. /* Circularly update wOffset. Watch out for positive and negative value */
  5041. wOffset += bufferInc;
  5042. if(wOffset >= L)
  5043. wOffset -= L;
  5044. /* Decrement the loop counter */
  5045. i--;
  5046. }
  5047. /* Update the index pointer */
  5048. *writeOffset = (uint16_t)wOffset;
  5049. }
  5050. /**
  5051. * @brief floating-point Circular Read function.
  5052. */
  5053. static __INLINE void arm_circularRead_f32(
  5054. int32_t * circBuffer,
  5055. int32_t L,
  5056. int32_t * readOffset,
  5057. int32_t bufferInc,
  5058. int32_t * dst,
  5059. int32_t * dst_base,
  5060. int32_t dst_length,
  5061. int32_t dstInc,
  5062. uint32_t blockSize)
  5063. {
  5064. uint32_t i = 0u;
  5065. int32_t rOffset, dst_end;
  5066. /* Copy the value of Index pointer that points
  5067. * to the current location from where the input samples to be read */
  5068. rOffset = *readOffset;
  5069. dst_end = (int32_t) (dst_base + dst_length);
  5070. /* Loop over the blockSize */
  5071. i = blockSize;
  5072. while(i > 0u)
  5073. {
  5074. /* copy the sample from the circular buffer to the destination buffer */
  5075. *dst = circBuffer[rOffset];
  5076. /* Update the input pointer */
  5077. dst += dstInc;
  5078. if(dst == (int32_t *) dst_end)
  5079. {
  5080. dst = dst_base;
  5081. }
  5082. /* Circularly update rOffset. Watch out for positive and negative value */
  5083. rOffset += bufferInc;
  5084. if(rOffset >= L)
  5085. {
  5086. rOffset -= L;
  5087. }
  5088. /* Decrement the loop counter */
  5089. i--;
  5090. }
  5091. /* Update the index pointer */
  5092. *readOffset = rOffset;
  5093. }
  5094. /**
  5095. * @brief Q15 Circular write function.
  5096. */
  5097. static __INLINE void arm_circularWrite_q15(
  5098. q15_t * circBuffer,
  5099. int32_t L,
  5100. uint16_t * writeOffset,
  5101. int32_t bufferInc,
  5102. const q15_t * src,
  5103. int32_t srcInc,
  5104. uint32_t blockSize)
  5105. {
  5106. uint32_t i = 0u;
  5107. int32_t wOffset;
  5108. /* Copy the value of Index pointer that points
  5109. * to the current location where the input samples to be copied */
  5110. wOffset = *writeOffset;
  5111. /* Loop over the blockSize */
  5112. i = blockSize;
  5113. while(i > 0u)
  5114. {
  5115. /* copy the input sample to the circular buffer */
  5116. circBuffer[wOffset] = *src;
  5117. /* Update the input pointer */
  5118. src += srcInc;
  5119. /* Circularly update wOffset. Watch out for positive and negative value */
  5120. wOffset += bufferInc;
  5121. if(wOffset >= L)
  5122. wOffset -= L;
  5123. /* Decrement the loop counter */
  5124. i--;
  5125. }
  5126. /* Update the index pointer */
  5127. *writeOffset = (uint16_t)wOffset;
  5128. }
  5129. /**
  5130. * @brief Q15 Circular Read function.
  5131. */
  5132. static __INLINE void arm_circularRead_q15(
  5133. q15_t * circBuffer,
  5134. int32_t L,
  5135. int32_t * readOffset,
  5136. int32_t bufferInc,
  5137. q15_t * dst,
  5138. q15_t * dst_base,
  5139. int32_t dst_length,
  5140. int32_t dstInc,
  5141. uint32_t blockSize)
  5142. {
  5143. uint32_t i = 0;
  5144. int32_t rOffset, dst_end;
  5145. /* Copy the value of Index pointer that points
  5146. * to the current location from where the input samples to be read */
  5147. rOffset = *readOffset;
  5148. dst_end = (int32_t) (dst_base + dst_length);
  5149. /* Loop over the blockSize */
  5150. i = blockSize;
  5151. while(i > 0u)
  5152. {
  5153. /* copy the sample from the circular buffer to the destination buffer */
  5154. *dst = circBuffer[rOffset];
  5155. /* Update the input pointer */
  5156. dst += dstInc;
  5157. if(dst == (q15_t *) dst_end)
  5158. {
  5159. dst = dst_base;
  5160. }
  5161. /* Circularly update wOffset. Watch out for positive and negative value */
  5162. rOffset += bufferInc;
  5163. if(rOffset >= L)
  5164. {
  5165. rOffset -= L;
  5166. }
  5167. /* Decrement the loop counter */
  5168. i--;
  5169. }
  5170. /* Update the index pointer */
  5171. *readOffset = rOffset;
  5172. }
  5173. /**
  5174. * @brief Q7 Circular write function.
  5175. */
  5176. static __INLINE void arm_circularWrite_q7(
  5177. q7_t * circBuffer,
  5178. int32_t L,
  5179. uint16_t * writeOffset,
  5180. int32_t bufferInc,
  5181. const q7_t * src,
  5182. int32_t srcInc,
  5183. uint32_t blockSize)
  5184. {
  5185. uint32_t i = 0u;
  5186. int32_t wOffset;
  5187. /* Copy the value of Index pointer that points
  5188. * to the current location where the input samples to be copied */
  5189. wOffset = *writeOffset;
  5190. /* Loop over the blockSize */
  5191. i = blockSize;
  5192. while(i > 0u)
  5193. {
  5194. /* copy the input sample to the circular buffer */
  5195. circBuffer[wOffset] = *src;
  5196. /* Update the input pointer */
  5197. src += srcInc;
  5198. /* Circularly update wOffset. Watch out for positive and negative value */
  5199. wOffset += bufferInc;
  5200. if(wOffset >= L)
  5201. wOffset -= L;
  5202. /* Decrement the loop counter */
  5203. i--;
  5204. }
  5205. /* Update the index pointer */
  5206. *writeOffset = (uint16_t)wOffset;
  5207. }
  5208. /**
  5209. * @brief Q7 Circular Read function.
  5210. */
  5211. static __INLINE void arm_circularRead_q7(
  5212. q7_t * circBuffer,
  5213. int32_t L,
  5214. int32_t * readOffset,
  5215. int32_t bufferInc,
  5216. q7_t * dst,
  5217. q7_t * dst_base,
  5218. int32_t dst_length,
  5219. int32_t dstInc,
  5220. uint32_t blockSize)
  5221. {
  5222. uint32_t i = 0;
  5223. int32_t rOffset, dst_end;
  5224. /* Copy the value of Index pointer that points
  5225. * to the current location from where the input samples to be read */
  5226. rOffset = *readOffset;
  5227. dst_end = (int32_t) (dst_base + dst_length);
  5228. /* Loop over the blockSize */
  5229. i = blockSize;
  5230. while(i > 0u)
  5231. {
  5232. /* copy the sample from the circular buffer to the destination buffer */
  5233. *dst = circBuffer[rOffset];
  5234. /* Update the input pointer */
  5235. dst += dstInc;
  5236. if(dst == (q7_t *) dst_end)
  5237. {
  5238. dst = dst_base;
  5239. }
  5240. /* Circularly update rOffset. Watch out for positive and negative value */
  5241. rOffset += bufferInc;
  5242. if(rOffset >= L)
  5243. {
  5244. rOffset -= L;
  5245. }
  5246. /* Decrement the loop counter */
  5247. i--;
  5248. }
  5249. /* Update the index pointer */
  5250. *readOffset = rOffset;
  5251. }
  5252. /**
  5253. * @brief Sum of the squares of the elements of a Q31 vector.
  5254. * @param[in] pSrc is input pointer
  5255. * @param[in] blockSize is the number of samples to process
  5256. * @param[out] pResult is output value.
  5257. */
  5258. void arm_power_q31(
  5259. q31_t * pSrc,
  5260. uint32_t blockSize,
  5261. q63_t * pResult);
  5262. /**
  5263. * @brief Sum of the squares of the elements of a floating-point vector.
  5264. * @param[in] pSrc is input pointer
  5265. * @param[in] blockSize is the number of samples to process
  5266. * @param[out] pResult is output value.
  5267. */
  5268. void arm_power_f32(
  5269. float32_t * pSrc,
  5270. uint32_t blockSize,
  5271. float32_t * pResult);
  5272. /**
  5273. * @brief Sum of the squares of the elements of a Q15 vector.
  5274. * @param[in] pSrc is input pointer
  5275. * @param[in] blockSize is the number of samples to process
  5276. * @param[out] pResult is output value.
  5277. */
  5278. void arm_power_q15(
  5279. q15_t * pSrc,
  5280. uint32_t blockSize,
  5281. q63_t * pResult);
  5282. /**
  5283. * @brief Sum of the squares of the elements of a Q7 vector.
  5284. * @param[in] pSrc is input pointer
  5285. * @param[in] blockSize is the number of samples to process
  5286. * @param[out] pResult is output value.
  5287. */
  5288. void arm_power_q7(
  5289. q7_t * pSrc,
  5290. uint32_t blockSize,
  5291. q31_t * pResult);
  5292. /**
  5293. * @brief Mean value of a Q7 vector.
  5294. * @param[in] pSrc is input pointer
  5295. * @param[in] blockSize is the number of samples to process
  5296. * @param[out] pResult is output value.
  5297. */
  5298. void arm_mean_q7(
  5299. q7_t * pSrc,
  5300. uint32_t blockSize,
  5301. q7_t * pResult);
  5302. /**
  5303. * @brief Mean value of a Q15 vector.
  5304. * @param[in] pSrc is input pointer
  5305. * @param[in] blockSize is the number of samples to process
  5306. * @param[out] pResult is output value.
  5307. */
  5308. void arm_mean_q15(
  5309. q15_t * pSrc,
  5310. uint32_t blockSize,
  5311. q15_t * pResult);
  5312. /**
  5313. * @brief Mean value of a Q31 vector.
  5314. * @param[in] pSrc is input pointer
  5315. * @param[in] blockSize is the number of samples to process
  5316. * @param[out] pResult is output value.
  5317. */
  5318. void arm_mean_q31(
  5319. q31_t * pSrc,
  5320. uint32_t blockSize,
  5321. q31_t * pResult);
  5322. /**
  5323. * @brief Mean value of a floating-point vector.
  5324. * @param[in] pSrc is input pointer
  5325. * @param[in] blockSize is the number of samples to process
  5326. * @param[out] pResult is output value.
  5327. */
  5328. void arm_mean_f32(
  5329. float32_t * pSrc,
  5330. uint32_t blockSize,
  5331. float32_t * pResult);
  5332. /**
  5333. * @brief Variance of the elements of a floating-point vector.
  5334. * @param[in] pSrc is input pointer
  5335. * @param[in] blockSize is the number of samples to process
  5336. * @param[out] pResult is output value.
  5337. */
  5338. void arm_var_f32(
  5339. float32_t * pSrc,
  5340. uint32_t blockSize,
  5341. float32_t * pResult);
  5342. /**
  5343. * @brief Variance of the elements of a Q31 vector.
  5344. * @param[in] pSrc is input pointer
  5345. * @param[in] blockSize is the number of samples to process
  5346. * @param[out] pResult is output value.
  5347. */
  5348. void arm_var_q31(
  5349. q31_t * pSrc,
  5350. uint32_t blockSize,
  5351. q31_t * pResult);
  5352. /**
  5353. * @brief Variance of the elements of a Q15 vector.
  5354. * @param[in] pSrc is input pointer
  5355. * @param[in] blockSize is the number of samples to process
  5356. * @param[out] pResult is output value.
  5357. */
  5358. void arm_var_q15(
  5359. q15_t * pSrc,
  5360. uint32_t blockSize,
  5361. q15_t * pResult);
  5362. /**
  5363. * @brief Root Mean Square of the elements of a floating-point vector.
  5364. * @param[in] pSrc is input pointer
  5365. * @param[in] blockSize is the number of samples to process
  5366. * @param[out] pResult is output value.
  5367. */
  5368. void arm_rms_f32(
  5369. float32_t * pSrc,
  5370. uint32_t blockSize,
  5371. float32_t * pResult);
  5372. /**
  5373. * @brief Root Mean Square of the elements of a Q31 vector.
  5374. * @param[in] pSrc is input pointer
  5375. * @param[in] blockSize is the number of samples to process
  5376. * @param[out] pResult is output value.
  5377. */
  5378. void arm_rms_q31(
  5379. q31_t * pSrc,
  5380. uint32_t blockSize,
  5381. q31_t * pResult);
  5382. /**
  5383. * @brief Root Mean Square of the elements of a Q15 vector.
  5384. * @param[in] pSrc is input pointer
  5385. * @param[in] blockSize is the number of samples to process
  5386. * @param[out] pResult is output value.
  5387. */
  5388. void arm_rms_q15(
  5389. q15_t * pSrc,
  5390. uint32_t blockSize,
  5391. q15_t * pResult);
  5392. /**
  5393. * @brief Standard deviation of the elements of a floating-point vector.
  5394. * @param[in] pSrc is input pointer
  5395. * @param[in] blockSize is the number of samples to process
  5396. * @param[out] pResult is output value.
  5397. */
  5398. void arm_std_f32(
  5399. float32_t * pSrc,
  5400. uint32_t blockSize,
  5401. float32_t * pResult);
  5402. /**
  5403. * @brief Standard deviation of the elements of a Q31 vector.
  5404. * @param[in] pSrc is input pointer
  5405. * @param[in] blockSize is the number of samples to process
  5406. * @param[out] pResult is output value.
  5407. */
  5408. void arm_std_q31(
  5409. q31_t * pSrc,
  5410. uint32_t blockSize,
  5411. q31_t * pResult);
  5412. /**
  5413. * @brief Standard deviation of the elements of a Q15 vector.
  5414. * @param[in] pSrc is input pointer
  5415. * @param[in] blockSize is the number of samples to process
  5416. * @param[out] pResult is output value.
  5417. */
  5418. void arm_std_q15(
  5419. q15_t * pSrc,
  5420. uint32_t blockSize,
  5421. q15_t * pResult);
  5422. /**
  5423. * @brief Floating-point complex magnitude
  5424. * @param[in] pSrc points to the complex input vector
  5425. * @param[out] pDst points to the real output vector
  5426. * @param[in] numSamples number of complex samples in the input vector
  5427. */
  5428. void arm_cmplx_mag_f32(
  5429. float32_t * pSrc,
  5430. float32_t * pDst,
  5431. uint32_t numSamples);
  5432. /**
  5433. * @brief Q31 complex magnitude
  5434. * @param[in] pSrc points to the complex input vector
  5435. * @param[out] pDst points to the real output vector
  5436. * @param[in] numSamples number of complex samples in the input vector
  5437. */
  5438. void arm_cmplx_mag_q31(
  5439. q31_t * pSrc,
  5440. q31_t * pDst,
  5441. uint32_t numSamples);
  5442. /**
  5443. * @brief Q15 complex magnitude
  5444. * @param[in] pSrc points to the complex input vector
  5445. * @param[out] pDst points to the real output vector
  5446. * @param[in] numSamples number of complex samples in the input vector
  5447. */
  5448. void arm_cmplx_mag_q15(
  5449. q15_t * pSrc,
  5450. q15_t * pDst,
  5451. uint32_t numSamples);
  5452. /**
  5453. * @brief Q15 complex dot product
  5454. * @param[in] pSrcA points to the first input vector
  5455. * @param[in] pSrcB points to the second input vector
  5456. * @param[in] numSamples number of complex samples in each vector
  5457. * @param[out] realResult real part of the result returned here
  5458. * @param[out] imagResult imaginary part of the result returned here
  5459. */
  5460. void arm_cmplx_dot_prod_q15(
  5461. q15_t * pSrcA,
  5462. q15_t * pSrcB,
  5463. uint32_t numSamples,
  5464. q31_t * realResult,
  5465. q31_t * imagResult);
  5466. /**
  5467. * @brief Q31 complex dot product
  5468. * @param[in] pSrcA points to the first input vector
  5469. * @param[in] pSrcB points to the second input vector
  5470. * @param[in] numSamples number of complex samples in each vector
  5471. * @param[out] realResult real part of the result returned here
  5472. * @param[out] imagResult imaginary part of the result returned here
  5473. */
  5474. void arm_cmplx_dot_prod_q31(
  5475. q31_t * pSrcA,
  5476. q31_t * pSrcB,
  5477. uint32_t numSamples,
  5478. q63_t * realResult,
  5479. q63_t * imagResult);
  5480. /**
  5481. * @brief Floating-point complex dot product
  5482. * @param[in] pSrcA points to the first input vector
  5483. * @param[in] pSrcB points to the second input vector
  5484. * @param[in] numSamples number of complex samples in each vector
  5485. * @param[out] realResult real part of the result returned here
  5486. * @param[out] imagResult imaginary part of the result returned here
  5487. */
  5488. void arm_cmplx_dot_prod_f32(
  5489. float32_t * pSrcA,
  5490. float32_t * pSrcB,
  5491. uint32_t numSamples,
  5492. float32_t * realResult,
  5493. float32_t * imagResult);
  5494. /**
  5495. * @brief Q15 complex-by-real multiplication
  5496. * @param[in] pSrcCmplx points to the complex input vector
  5497. * @param[in] pSrcReal points to the real input vector
  5498. * @param[out] pCmplxDst points to the complex output vector
  5499. * @param[in] numSamples number of samples in each vector
  5500. */
  5501. void arm_cmplx_mult_real_q15(
  5502. q15_t * pSrcCmplx,
  5503. q15_t * pSrcReal,
  5504. q15_t * pCmplxDst,
  5505. uint32_t numSamples);
  5506. /**
  5507. * @brief Q31 complex-by-real multiplication
  5508. * @param[in] pSrcCmplx points to the complex input vector
  5509. * @param[in] pSrcReal points to the real input vector
  5510. * @param[out] pCmplxDst points to the complex output vector
  5511. * @param[in] numSamples number of samples in each vector
  5512. */
  5513. void arm_cmplx_mult_real_q31(
  5514. q31_t * pSrcCmplx,
  5515. q31_t * pSrcReal,
  5516. q31_t * pCmplxDst,
  5517. uint32_t numSamples);
  5518. /**
  5519. * @brief Floating-point complex-by-real multiplication
  5520. * @param[in] pSrcCmplx points to the complex input vector
  5521. * @param[in] pSrcReal points to the real input vector
  5522. * @param[out] pCmplxDst points to the complex output vector
  5523. * @param[in] numSamples number of samples in each vector
  5524. */
  5525. void arm_cmplx_mult_real_f32(
  5526. float32_t * pSrcCmplx,
  5527. float32_t * pSrcReal,
  5528. float32_t * pCmplxDst,
  5529. uint32_t numSamples);
  5530. /**
  5531. * @brief Minimum value of a Q7 vector.
  5532. * @param[in] pSrc is input pointer
  5533. * @param[in] blockSize is the number of samples to process
  5534. * @param[out] result is output pointer
  5535. * @param[in] index is the array index of the minimum value in the input buffer.
  5536. */
  5537. void arm_min_q7(
  5538. q7_t * pSrc,
  5539. uint32_t blockSize,
  5540. q7_t * result,
  5541. uint32_t * index);
  5542. /**
  5543. * @brief Minimum value of a Q15 vector.
  5544. * @param[in] pSrc is input pointer
  5545. * @param[in] blockSize is the number of samples to process
  5546. * @param[out] pResult is output pointer
  5547. * @param[in] pIndex is the array index of the minimum value in the input buffer.
  5548. */
  5549. void arm_min_q15(
  5550. q15_t * pSrc,
  5551. uint32_t blockSize,
  5552. q15_t * pResult,
  5553. uint32_t * pIndex);
  5554. /**
  5555. * @brief Minimum value of a Q31 vector.
  5556. * @param[in] pSrc is input pointer
  5557. * @param[in] blockSize is the number of samples to process
  5558. * @param[out] pResult is output pointer
  5559. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  5560. */
  5561. void arm_min_q31(
  5562. q31_t * pSrc,
  5563. uint32_t blockSize,
  5564. q31_t * pResult,
  5565. uint32_t * pIndex);
  5566. /**
  5567. * @brief Minimum value of a floating-point vector.
  5568. * @param[in] pSrc is input pointer
  5569. * @param[in] blockSize is the number of samples to process
  5570. * @param[out] pResult is output pointer
  5571. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  5572. */
  5573. void arm_min_f32(
  5574. float32_t * pSrc,
  5575. uint32_t blockSize,
  5576. float32_t * pResult,
  5577. uint32_t * pIndex);
  5578. /**
  5579. * @brief Maximum value of a Q7 vector.
  5580. * @param[in] pSrc points to the input buffer
  5581. * @param[in] blockSize length of the input vector
  5582. * @param[out] pResult maximum value returned here
  5583. * @param[out] pIndex index of maximum value returned here
  5584. */
  5585. void arm_max_q7(
  5586. q7_t * pSrc,
  5587. uint32_t blockSize,
  5588. q7_t * pResult,
  5589. uint32_t * pIndex);
  5590. /**
  5591. * @brief Maximum value of a Q15 vector.
  5592. * @param[in] pSrc points to the input buffer
  5593. * @param[in] blockSize length of the input vector
  5594. * @param[out] pResult maximum value returned here
  5595. * @param[out] pIndex index of maximum value returned here
  5596. */
  5597. void arm_max_q15(
  5598. q15_t * pSrc,
  5599. uint32_t blockSize,
  5600. q15_t * pResult,
  5601. uint32_t * pIndex);
  5602. /**
  5603. * @brief Maximum value of a Q31 vector.
  5604. * @param[in] pSrc points to the input buffer
  5605. * @param[in] blockSize length of the input vector
  5606. * @param[out] pResult maximum value returned here
  5607. * @param[out] pIndex index of maximum value returned here
  5608. */
  5609. void arm_max_q31(
  5610. q31_t * pSrc,
  5611. uint32_t blockSize,
  5612. q31_t * pResult,
  5613. uint32_t * pIndex);
  5614. /**
  5615. * @brief Maximum value of a floating-point vector.
  5616. * @param[in] pSrc points to the input buffer
  5617. * @param[in] blockSize length of the input vector
  5618. * @param[out] pResult maximum value returned here
  5619. * @param[out] pIndex index of maximum value returned here
  5620. */
  5621. void arm_max_f32(
  5622. float32_t * pSrc,
  5623. uint32_t blockSize,
  5624. float32_t * pResult,
  5625. uint32_t * pIndex);
  5626. /**
  5627. * @brief Q15 complex-by-complex multiplication
  5628. * @param[in] pSrcA points to the first input vector
  5629. * @param[in] pSrcB points to the second input vector
  5630. * @param[out] pDst points to the output vector
  5631. * @param[in] numSamples number of complex samples in each vector
  5632. */
  5633. void arm_cmplx_mult_cmplx_q15(
  5634. q15_t * pSrcA,
  5635. q15_t * pSrcB,
  5636. q15_t * pDst,
  5637. uint32_t numSamples);
  5638. /**
  5639. * @brief Q31 complex-by-complex multiplication
  5640. * @param[in] pSrcA points to the first input vector
  5641. * @param[in] pSrcB points to the second input vector
  5642. * @param[out] pDst points to the output vector
  5643. * @param[in] numSamples number of complex samples in each vector
  5644. */
  5645. void arm_cmplx_mult_cmplx_q31(
  5646. q31_t * pSrcA,
  5647. q31_t * pSrcB,
  5648. q31_t * pDst,
  5649. uint32_t numSamples);
  5650. /**
  5651. * @brief Floating-point complex-by-complex multiplication
  5652. * @param[in] pSrcA points to the first input vector
  5653. * @param[in] pSrcB points to the second input vector
  5654. * @param[out] pDst points to the output vector
  5655. * @param[in] numSamples number of complex samples in each vector
  5656. */
  5657. void arm_cmplx_mult_cmplx_f32(
  5658. float32_t * pSrcA,
  5659. float32_t * pSrcB,
  5660. float32_t * pDst,
  5661. uint32_t numSamples);
  5662. /**
  5663. * @brief Converts the elements of the floating-point vector to Q31 vector.
  5664. * @param[in] pSrc points to the floating-point input vector
  5665. * @param[out] pDst points to the Q31 output vector
  5666. * @param[in] blockSize length of the input vector
  5667. */
  5668. void arm_float_to_q31(
  5669. float32_t * pSrc,
  5670. q31_t * pDst,
  5671. uint32_t blockSize);
  5672. /**
  5673. * @brief Converts the elements of the floating-point vector to Q15 vector.
  5674. * @param[in] pSrc points to the floating-point input vector
  5675. * @param[out] pDst points to the Q15 output vector
  5676. * @param[in] blockSize length of the input vector
  5677. */
  5678. void arm_float_to_q15(
  5679. float32_t * pSrc,
  5680. q15_t * pDst,
  5681. uint32_t blockSize);
  5682. /**
  5683. * @brief Converts the elements of the floating-point vector to Q7 vector.
  5684. * @param[in] pSrc points to the floating-point input vector
  5685. * @param[out] pDst points to the Q7 output vector
  5686. * @param[in] blockSize length of the input vector
  5687. */
  5688. void arm_float_to_q7(
  5689. float32_t * pSrc,
  5690. q7_t * pDst,
  5691. uint32_t blockSize);
  5692. /**
  5693. * @brief Converts the elements of the Q31 vector to Q15 vector.
  5694. * @param[in] pSrc is input pointer
  5695. * @param[out] pDst is output pointer
  5696. * @param[in] blockSize is the number of samples to process
  5697. */
  5698. void arm_q31_to_q15(
  5699. q31_t * pSrc,
  5700. q15_t * pDst,
  5701. uint32_t blockSize);
  5702. /**
  5703. * @brief Converts the elements of the Q31 vector to Q7 vector.
  5704. * @param[in] pSrc is input pointer
  5705. * @param[out] pDst is output pointer
  5706. * @param[in] blockSize is the number of samples to process
  5707. */
  5708. void arm_q31_to_q7(
  5709. q31_t * pSrc,
  5710. q7_t * pDst,
  5711. uint32_t blockSize);
  5712. /**
  5713. * @brief Converts the elements of the Q15 vector to floating-point vector.
  5714. * @param[in] pSrc is input pointer
  5715. * @param[out] pDst is output pointer
  5716. * @param[in] blockSize is the number of samples to process
  5717. */
  5718. void arm_q15_to_float(
  5719. q15_t * pSrc,
  5720. float32_t * pDst,
  5721. uint32_t blockSize);
  5722. /**
  5723. * @brief Converts the elements of the Q15 vector to Q31 vector.
  5724. * @param[in] pSrc is input pointer
  5725. * @param[out] pDst is output pointer
  5726. * @param[in] blockSize is the number of samples to process
  5727. */
  5728. void arm_q15_to_q31(
  5729. q15_t * pSrc,
  5730. q31_t * pDst,
  5731. uint32_t blockSize);
  5732. /**
  5733. * @brief Converts the elements of the Q15 vector to Q7 vector.
  5734. * @param[in] pSrc is input pointer
  5735. * @param[out] pDst is output pointer
  5736. * @param[in] blockSize is the number of samples to process
  5737. */
  5738. void arm_q15_to_q7(
  5739. q15_t * pSrc,
  5740. q7_t * pDst,
  5741. uint32_t blockSize);
  5742. /**
  5743. * @ingroup groupInterpolation
  5744. */
  5745. /**
  5746. * @defgroup BilinearInterpolate Bilinear Interpolation
  5747. *
  5748. * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
  5749. * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
  5750. * determines values between the grid points.
  5751. * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
  5752. * Bilinear interpolation is often used in image processing to rescale images.
  5753. * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
  5754. *
  5755. * <b>Algorithm</b>
  5756. * \par
  5757. * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
  5758. * For floating-point, the instance structure is defined as:
  5759. * <pre>
  5760. * typedef struct
  5761. * {
  5762. * uint16_t numRows;
  5763. * uint16_t numCols;
  5764. * float32_t *pData;
  5765. * } arm_bilinear_interp_instance_f32;
  5766. * </pre>
  5767. *
  5768. * \par
  5769. * where <code>numRows</code> specifies the number of rows in the table;
  5770. * <code>numCols</code> specifies the number of columns in the table;
  5771. * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
  5772. * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
  5773. * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
  5774. *
  5775. * \par
  5776. * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
  5777. * <pre>
  5778. * XF = floor(x)
  5779. * YF = floor(y)
  5780. * </pre>
  5781. * \par
  5782. * The interpolated output point is computed as:
  5783. * <pre>
  5784. * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
  5785. * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
  5786. * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
  5787. * + f(XF+1, YF+1) * (x-XF)*(y-YF)
  5788. * </pre>
  5789. * Note that the coordinates (x, y) contain integer and fractional components.
  5790. * The integer components specify which portion of the table to use while the
  5791. * fractional components control the interpolation processor.
  5792. *
  5793. * \par
  5794. * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
  5795. */
  5796. /**
  5797. * @addtogroup BilinearInterpolate
  5798. * @{
  5799. */
  5800. /**
  5801. *
  5802. * @brief Floating-point bilinear interpolation.
  5803. * @param[in,out] S points to an instance of the interpolation structure.
  5804. * @param[in] X interpolation coordinate.
  5805. * @param[in] Y interpolation coordinate.
  5806. * @return out interpolated value.
  5807. */
  5808. static __INLINE float32_t arm_bilinear_interp_f32(
  5809. const arm_bilinear_interp_instance_f32 * S,
  5810. float32_t X,
  5811. float32_t Y)
  5812. {
  5813. float32_t out;
  5814. float32_t f00, f01, f10, f11;
  5815. float32_t *pData = S->pData;
  5816. int32_t xIndex, yIndex, index;
  5817. float32_t xdiff, ydiff;
  5818. float32_t b1, b2, b3, b4;
  5819. xIndex = (int32_t) X;
  5820. yIndex = (int32_t) Y;
  5821. /* Care taken for table outside boundary */
  5822. /* Returns zero output when values are outside table boundary */
  5823. if(xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1))
  5824. {
  5825. return (0);
  5826. }
  5827. /* Calculation of index for two nearest points in X-direction */
  5828. index = (xIndex - 1) + (yIndex - 1) * S->numCols;
  5829. /* Read two nearest points in X-direction */
  5830. f00 = pData[index];
  5831. f01 = pData[index + 1];
  5832. /* Calculation of index for two nearest points in Y-direction */
  5833. index = (xIndex - 1) + (yIndex) * S->numCols;
  5834. /* Read two nearest points in Y-direction */
  5835. f10 = pData[index];
  5836. f11 = pData[index + 1];
  5837. /* Calculation of intermediate values */
  5838. b1 = f00;
  5839. b2 = f01 - f00;
  5840. b3 = f10 - f00;
  5841. b4 = f00 - f01 - f10 + f11;
  5842. /* Calculation of fractional part in X */
  5843. xdiff = X - xIndex;
  5844. /* Calculation of fractional part in Y */
  5845. ydiff = Y - yIndex;
  5846. /* Calculation of bi-linear interpolated output */
  5847. out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
  5848. /* return to application */
  5849. return (out);
  5850. }
  5851. /**
  5852. *
  5853. * @brief Q31 bilinear interpolation.
  5854. * @param[in,out] S points to an instance of the interpolation structure.
  5855. * @param[in] X interpolation coordinate in 12.20 format.
  5856. * @param[in] Y interpolation coordinate in 12.20 format.
  5857. * @return out interpolated value.
  5858. */
  5859. static __INLINE q31_t arm_bilinear_interp_q31(
  5860. arm_bilinear_interp_instance_q31 * S,
  5861. q31_t X,
  5862. q31_t Y)
  5863. {
  5864. q31_t out; /* Temporary output */
  5865. q31_t acc = 0; /* output */
  5866. q31_t xfract, yfract; /* X, Y fractional parts */
  5867. q31_t x1, x2, y1, y2; /* Nearest output values */
  5868. int32_t rI, cI; /* Row and column indices */
  5869. q31_t *pYData = S->pData; /* pointer to output table values */
  5870. uint32_t nCols = S->numCols; /* num of rows */
  5871. /* Input is in 12.20 format */
  5872. /* 12 bits for the table index */
  5873. /* Index value calculation */
  5874. rI = ((X & (q31_t)0xFFF00000) >> 20);
  5875. /* Input is in 12.20 format */
  5876. /* 12 bits for the table index */
  5877. /* Index value calculation */
  5878. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  5879. /* Care taken for table outside boundary */
  5880. /* Returns zero output when values are outside table boundary */
  5881. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  5882. {
  5883. return (0);
  5884. }
  5885. /* 20 bits for the fractional part */
  5886. /* shift left xfract by 11 to keep 1.31 format */
  5887. xfract = (X & 0x000FFFFF) << 11u;
  5888. /* Read two nearest output values from the index */
  5889. x1 = pYData[(rI) + (int32_t)nCols * (cI) ];
  5890. x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1];
  5891. /* 20 bits for the fractional part */
  5892. /* shift left yfract by 11 to keep 1.31 format */
  5893. yfract = (Y & 0x000FFFFF) << 11u;
  5894. /* Read two nearest output values from the index */
  5895. y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ];
  5896. y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1];
  5897. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
  5898. out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
  5899. acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
  5900. /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
  5901. out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
  5902. acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
  5903. /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
  5904. out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
  5905. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  5906. /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
  5907. out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
  5908. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  5909. /* Convert acc to 1.31(q31) format */
  5910. return ((q31_t)(acc << 2));
  5911. }
  5912. /**
  5913. * @brief Q15 bilinear interpolation.
  5914. * @param[in,out] S points to an instance of the interpolation structure.
  5915. * @param[in] X interpolation coordinate in 12.20 format.
  5916. * @param[in] Y interpolation coordinate in 12.20 format.
  5917. * @return out interpolated value.
  5918. */
  5919. static __INLINE q15_t arm_bilinear_interp_q15(
  5920. arm_bilinear_interp_instance_q15 * S,
  5921. q31_t X,
  5922. q31_t Y)
  5923. {
  5924. q63_t acc = 0; /* output */
  5925. q31_t out; /* Temporary output */
  5926. q15_t x1, x2, y1, y2; /* Nearest output values */
  5927. q31_t xfract, yfract; /* X, Y fractional parts */
  5928. int32_t rI, cI; /* Row and column indices */
  5929. q15_t *pYData = S->pData; /* pointer to output table values */
  5930. uint32_t nCols = S->numCols; /* num of rows */
  5931. /* Input is in 12.20 format */
  5932. /* 12 bits for the table index */
  5933. /* Index value calculation */
  5934. rI = ((X & (q31_t)0xFFF00000) >> 20);
  5935. /* Input is in 12.20 format */
  5936. /* 12 bits for the table index */
  5937. /* Index value calculation */
  5938. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  5939. /* Care taken for table outside boundary */
  5940. /* Returns zero output when values are outside table boundary */
  5941. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  5942. {
  5943. return (0);
  5944. }
  5945. /* 20 bits for the fractional part */
  5946. /* xfract should be in 12.20 format */
  5947. xfract = (X & 0x000FFFFF);
  5948. /* Read two nearest output values from the index */
  5949. x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
  5950. x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
  5951. /* 20 bits for the fractional part */
  5952. /* yfract should be in 12.20 format */
  5953. yfract = (Y & 0x000FFFFF);
  5954. /* Read two nearest output values from the index */
  5955. y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
  5956. y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
  5957. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
  5958. /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
  5959. /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
  5960. out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);
  5961. acc = ((q63_t) out * (0xFFFFF - yfract));
  5962. /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
  5963. out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);
  5964. acc += ((q63_t) out * (xfract));
  5965. /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
  5966. out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);
  5967. acc += ((q63_t) out * (yfract));
  5968. /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
  5969. out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u);
  5970. acc += ((q63_t) out * (yfract));
  5971. /* acc is in 13.51 format and down shift acc by 36 times */
  5972. /* Convert out to 1.15 format */
  5973. return ((q15_t)(acc >> 36));
  5974. }
  5975. /**
  5976. * @brief Q7 bilinear interpolation.
  5977. * @param[in,out] S points to an instance of the interpolation structure.
  5978. * @param[in] X interpolation coordinate in 12.20 format.
  5979. * @param[in] Y interpolation coordinate in 12.20 format.
  5980. * @return out interpolated value.
  5981. */
  5982. static __INLINE q7_t arm_bilinear_interp_q7(
  5983. arm_bilinear_interp_instance_q7 * S,
  5984. q31_t X,
  5985. q31_t Y)
  5986. {
  5987. q63_t acc = 0; /* output */
  5988. q31_t out; /* Temporary output */
  5989. q31_t xfract, yfract; /* X, Y fractional parts */
  5990. q7_t x1, x2, y1, y2; /* Nearest output values */
  5991. int32_t rI, cI; /* Row and column indices */
  5992. q7_t *pYData = S->pData; /* pointer to output table values */
  5993. uint32_t nCols = S->numCols; /* num of rows */
  5994. /* Input is in 12.20 format */
  5995. /* 12 bits for the table index */
  5996. /* Index value calculation */
  5997. rI = ((X & (q31_t)0xFFF00000) >> 20);
  5998. /* Input is in 12.20 format */
  5999. /* 12 bits for the table index */
  6000. /* Index value calculation */
  6001. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  6002. /* Care taken for table outside boundary */
  6003. /* Returns zero output when values are outside table boundary */
  6004. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  6005. {
  6006. return (0);
  6007. }
  6008. /* 20 bits for the fractional part */
  6009. /* xfract should be in 12.20 format */
  6010. xfract = (X & (q31_t)0x000FFFFF);
  6011. /* Read two nearest output values from the index */
  6012. x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
  6013. x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
  6014. /* 20 bits for the fractional part */
  6015. /* yfract should be in 12.20 format */
  6016. yfract = (Y & (q31_t)0x000FFFFF);
  6017. /* Read two nearest output values from the index */
  6018. y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
  6019. y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
  6020. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
  6021. out = ((x1 * (0xFFFFF - xfract)));
  6022. acc = (((q63_t) out * (0xFFFFF - yfract)));
  6023. /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
  6024. out = ((x2 * (0xFFFFF - yfract)));
  6025. acc += (((q63_t) out * (xfract)));
  6026. /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
  6027. out = ((y1 * (0xFFFFF - xfract)));
  6028. acc += (((q63_t) out * (yfract)));
  6029. /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
  6030. out = ((y2 * (yfract)));
  6031. acc += (((q63_t) out * (xfract)));
  6032. /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
  6033. return ((q7_t)(acc >> 40));
  6034. }
  6035. /**
  6036. * @} end of BilinearInterpolate group
  6037. */
  6038. /* SMMLAR */
  6039. #define multAcc_32x32_keep32_R(a, x, y) \
  6040. a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
  6041. /* SMMLSR */
  6042. #define multSub_32x32_keep32_R(a, x, y) \
  6043. a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
  6044. /* SMMULR */
  6045. #define mult_32x32_keep32_R(a, x, y) \
  6046. a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
  6047. /* SMMLA */
  6048. #define multAcc_32x32_keep32(a, x, y) \
  6049. a += (q31_t) (((q63_t) x * y) >> 32)
  6050. /* SMMLS */
  6051. #define multSub_32x32_keep32(a, x, y) \
  6052. a -= (q31_t) (((q63_t) x * y) >> 32)
  6053. /* SMMUL */
  6054. #define mult_32x32_keep32(a, x, y) \
  6055. a = (q31_t) (((q63_t) x * y ) >> 32)
  6056. #if defined ( __CC_ARM )
  6057. /* Enter low optimization region - place directly above function definition */
  6058. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  6059. #define LOW_OPTIMIZATION_ENTER \
  6060. _Pragma ("push") \
  6061. _Pragma ("O1")
  6062. #else
  6063. #define LOW_OPTIMIZATION_ENTER
  6064. #endif
  6065. /* Exit low optimization region - place directly after end of function definition */
  6066. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  6067. #define LOW_OPTIMIZATION_EXIT \
  6068. _Pragma ("pop")
  6069. #else
  6070. #define LOW_OPTIMIZATION_EXIT
  6071. #endif
  6072. /* Enter low optimization region - place directly above function definition */
  6073. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6074. /* Exit low optimization region - place directly after end of function definition */
  6075. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6076. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  6077. #define LOW_OPTIMIZATION_ENTER
  6078. #define LOW_OPTIMIZATION_EXIT
  6079. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6080. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6081. #elif defined(__GNUC__)
  6082. #define LOW_OPTIMIZATION_ENTER __attribute__(( optimize("-O1") ))
  6083. #define LOW_OPTIMIZATION_EXIT
  6084. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6085. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6086. #elif defined(__ICCARM__)
  6087. /* Enter low optimization region - place directly above function definition */
  6088. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  6089. #define LOW_OPTIMIZATION_ENTER \
  6090. _Pragma ("optimize=low")
  6091. #else
  6092. #define LOW_OPTIMIZATION_ENTER
  6093. #endif
  6094. /* Exit low optimization region - place directly after end of function definition */
  6095. #define LOW_OPTIMIZATION_EXIT
  6096. /* Enter low optimization region - place directly above function definition */
  6097. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  6098. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
  6099. _Pragma ("optimize=low")
  6100. #else
  6101. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6102. #endif
  6103. /* Exit low optimization region - place directly after end of function definition */
  6104. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6105. #elif defined(__CSMC__)
  6106. #define LOW_OPTIMIZATION_ENTER
  6107. #define LOW_OPTIMIZATION_EXIT
  6108. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6109. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6110. #elif defined(__TASKING__)
  6111. #define LOW_OPTIMIZATION_ENTER
  6112. #define LOW_OPTIMIZATION_EXIT
  6113. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6114. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6115. #endif
  6116. #ifdef __cplusplus
  6117. }
  6118. #endif
  6119. #if defined ( __GNUC__ )
  6120. #pragma GCC diagnostic pop
  6121. #endif
  6122. #endif /* _ARM_MATH_H */
  6123. /**
  6124. *
  6125. * End of file.
  6126. */