arm_math.h 222 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907
  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. ARM_MATH_SUCCESS = 0, /**< No error */
  350. ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
  351. ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
  352. ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
  353. ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
  354. ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
  355. ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
  356. } arm_status;
  357. /**
  358. * @brief 8-bit fractional data type in 1.7 format.
  359. */
  360. typedef int8_t q7_t;
  361. /**
  362. * @brief 16-bit fractional data type in 1.15 format.
  363. */
  364. typedef int16_t q15_t;
  365. /**
  366. * @brief 32-bit fractional data type in 1.31 format.
  367. */
  368. typedef int32_t q31_t;
  369. /**
  370. * @brief 64-bit fractional data type in 1.63 format.
  371. */
  372. typedef int64_t q63_t;
  373. /**
  374. * @brief 32-bit floating-point type definition.
  375. */
  376. typedef float float32_t;
  377. /**
  378. * @brief 64-bit floating-point type definition.
  379. */
  380. typedef double float64_t;
  381. /**
  382. * @brief definition to read/write two 16 bit values.
  383. */
  384. #if defined __CC_ARM
  385. #define __SIMD32_TYPE int32_t __packed
  386. #define CMSIS_UNUSED __attribute__((unused))
  387. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  388. #define __SIMD32_TYPE int32_t
  389. #define CMSIS_UNUSED __attribute__((unused))
  390. #elif defined __GNUC__
  391. #define __SIMD32_TYPE int32_t
  392. #define CMSIS_UNUSED __attribute__((unused))
  393. #elif defined __ICCARM__
  394. #define __SIMD32_TYPE int32_t __packed
  395. #define CMSIS_UNUSED
  396. #elif defined __CSMC__
  397. #define __SIMD32_TYPE int32_t
  398. #define CMSIS_UNUSED
  399. #elif defined __TASKING__
  400. #define __SIMD32_TYPE __unaligned int32_t
  401. #define CMSIS_UNUSED
  402. #else
  403. #error Unknown compiler
  404. #endif
  405. #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
  406. #define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
  407. #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
  408. #define __SIMD64(addr) (*(int64_t **) & (addr))
  409. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  410. /**
  411. * @brief definition to pack two 16 bit values.
  412. */
  413. #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
  414. (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
  415. #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
  416. (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
  417. #endif
  418. /**
  419. * @brief definition to pack four 8 bit values.
  420. */
  421. #ifndef ARM_MATH_BIG_ENDIAN
  422. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
  423. (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
  424. (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
  425. (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
  426. #else
  427. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
  428. (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
  429. (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
  430. (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
  431. #endif
  432. /**
  433. * @brief Clips Q63 to Q31 values.
  434. */
  435. static __INLINE q31_t clip_q63_to_q31(
  436. q63_t x)
  437. {
  438. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  439. ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
  440. }
  441. /**
  442. * @brief Clips Q63 to Q15 values.
  443. */
  444. static __INLINE q15_t clip_q63_to_q15(
  445. q63_t x)
  446. {
  447. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  448. ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
  449. }
  450. /**
  451. * @brief Clips Q31 to Q7 values.
  452. */
  453. static __INLINE q7_t clip_q31_to_q7(
  454. q31_t x)
  455. {
  456. return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
  457. ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
  458. }
  459. /**
  460. * @brief Clips Q31 to Q15 values.
  461. */
  462. static __INLINE q15_t clip_q31_to_q15(
  463. q31_t x)
  464. {
  465. return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
  466. ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
  467. }
  468. /**
  469. * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
  470. */
  471. static __INLINE q63_t mult32x64(
  472. q63_t x,
  473. q31_t y)
  474. {
  475. return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
  476. (((q63_t) (x >> 32) * y)));
  477. }
  478. /*
  479. #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
  480. #define __CLZ __clz
  481. #endif
  482. */
  483. /* note: function can be removed when all toolchain support __CLZ for Cortex-M0 */
  484. #if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) )
  485. static __INLINE uint32_t __CLZ(
  486. q31_t data);
  487. static __INLINE uint32_t __CLZ(
  488. q31_t data)
  489. {
  490. uint32_t count = 0;
  491. uint32_t mask = 0x80000000;
  492. while((data & mask) == 0)
  493. {
  494. count += 1u;
  495. mask = mask >> 1u;
  496. }
  497. return (count);
  498. }
  499. #endif
  500. /**
  501. * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
  502. */
  503. static __INLINE uint32_t arm_recip_q31(
  504. q31_t in,
  505. q31_t * dst,
  506. q31_t * pRecipTable)
  507. {
  508. q31_t out;
  509. uint32_t tempVal;
  510. uint32_t index, i;
  511. uint32_t signBits;
  512. if(in > 0)
  513. {
  514. signBits = ((uint32_t) (__CLZ( in) - 1));
  515. }
  516. else
  517. {
  518. signBits = ((uint32_t) (__CLZ(-in) - 1));
  519. }
  520. /* Convert input sample to 1.31 format */
  521. in = (in << signBits);
  522. /* calculation of index for initial approximated Val */
  523. index = (uint32_t)(in >> 24);
  524. index = (index & INDEX_MASK);
  525. /* 1.31 with exp 1 */
  526. out = pRecipTable[index];
  527. /* calculation of reciprocal value */
  528. /* running approximation for two iterations */
  529. for (i = 0u; i < 2u; i++)
  530. {
  531. tempVal = (uint32_t) (((q63_t) in * out) >> 31);
  532. tempVal = 0x7FFFFFFFu - tempVal;
  533. /* 1.31 with exp 1 */
  534. /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */
  535. out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30);
  536. }
  537. /* write output */
  538. *dst = out;
  539. /* return num of signbits of out = 1/in value */
  540. return (signBits + 1u);
  541. }
  542. /**
  543. * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
  544. */
  545. static __INLINE uint32_t arm_recip_q15(
  546. q15_t in,
  547. q15_t * dst,
  548. q15_t * pRecipTable)
  549. {
  550. q15_t out = 0;
  551. uint32_t tempVal = 0;
  552. uint32_t index = 0, i = 0;
  553. uint32_t signBits = 0;
  554. if(in > 0)
  555. {
  556. signBits = ((uint32_t)(__CLZ( in) - 17));
  557. }
  558. else
  559. {
  560. signBits = ((uint32_t)(__CLZ(-in) - 17));
  561. }
  562. /* Convert input sample to 1.15 format */
  563. in = (in << signBits);
  564. /* calculation of index for initial approximated Val */
  565. index = (uint32_t)(in >> 8);
  566. index = (index & INDEX_MASK);
  567. /* 1.15 with exp 1 */
  568. out = pRecipTable[index];
  569. /* calculation of reciprocal value */
  570. /* running approximation for two iterations */
  571. for (i = 0u; i < 2u; i++)
  572. {
  573. tempVal = (uint32_t) (((q31_t) in * out) >> 15);
  574. tempVal = 0x7FFFu - tempVal;
  575. /* 1.15 with exp 1 */
  576. out = (q15_t) (((q31_t) out * tempVal) >> 14);
  577. /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */
  578. }
  579. /* write output */
  580. *dst = out;
  581. /* return num of signbits of out = 1/in value */
  582. return (signBits + 1);
  583. }
  584. /*
  585. * @brief C custom defined intrinisic function for only M0 processors
  586. */
  587. #if defined(ARM_MATH_CM0_FAMILY)
  588. static __INLINE q31_t __SSAT(
  589. q31_t x,
  590. uint32_t y)
  591. {
  592. int32_t posMax, negMin;
  593. uint32_t i;
  594. posMax = 1;
  595. for (i = 0; i < (y - 1); i++)
  596. {
  597. posMax = posMax * 2;
  598. }
  599. if(x > 0)
  600. {
  601. posMax = (posMax - 1);
  602. if(x > posMax)
  603. {
  604. x = posMax;
  605. }
  606. }
  607. else
  608. {
  609. negMin = -posMax;
  610. if(x < negMin)
  611. {
  612. x = negMin;
  613. }
  614. }
  615. return (x);
  616. }
  617. #endif /* end of ARM_MATH_CM0_FAMILY */
  618. /*
  619. * @brief C custom defined intrinsic function for M3 and M0 processors
  620. */
  621. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  622. /*
  623. * @brief C custom defined QADD8 for M3 and M0 processors
  624. */
  625. static __INLINE uint32_t __QADD8(
  626. uint32_t x,
  627. uint32_t y)
  628. {
  629. q31_t r, s, t, u;
  630. r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
  631. s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
  632. t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
  633. u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
  634. return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
  635. }
  636. /*
  637. * @brief C custom defined QSUB8 for M3 and M0 processors
  638. */
  639. static __INLINE uint32_t __QSUB8(
  640. uint32_t x,
  641. uint32_t y)
  642. {
  643. q31_t r, s, t, u;
  644. r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
  645. s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
  646. t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
  647. u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
  648. return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
  649. }
  650. /*
  651. * @brief C custom defined QADD16 for M3 and M0 processors
  652. */
  653. static __INLINE uint32_t __QADD16(
  654. uint32_t x,
  655. uint32_t y)
  656. {
  657. /* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */
  658. q31_t r = 0, s = 0;
  659. r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  660. s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  661. return ((uint32_t)((s << 16) | (r )));
  662. }
  663. /*
  664. * @brief C custom defined SHADD16 for M3 and M0 processors
  665. */
  666. static __INLINE uint32_t __SHADD16(
  667. uint32_t x,
  668. uint32_t y)
  669. {
  670. q31_t r, s;
  671. r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  672. s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  673. return ((uint32_t)((s << 16) | (r )));
  674. }
  675. /*
  676. * @brief C custom defined QSUB16 for M3 and M0 processors
  677. */
  678. static __INLINE uint32_t __QSUB16(
  679. uint32_t x,
  680. uint32_t y)
  681. {
  682. q31_t r, s;
  683. r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  684. s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  685. return ((uint32_t)((s << 16) | (r )));
  686. }
  687. /*
  688. * @brief C custom defined SHSUB16 for M3 and M0 processors
  689. */
  690. static __INLINE uint32_t __SHSUB16(
  691. uint32_t x,
  692. uint32_t y)
  693. {
  694. q31_t r, s;
  695. r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  696. s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  697. return ((uint32_t)((s << 16) | (r )));
  698. }
  699. /*
  700. * @brief C custom defined QASX for M3 and M0 processors
  701. */
  702. static __INLINE uint32_t __QASX(
  703. uint32_t x,
  704. uint32_t y)
  705. {
  706. q31_t r, s;
  707. r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  708. s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  709. return ((uint32_t)((s << 16) | (r )));
  710. }
  711. /*
  712. * @brief C custom defined SHASX for M3 and M0 processors
  713. */
  714. static __INLINE uint32_t __SHASX(
  715. uint32_t x,
  716. uint32_t y)
  717. {
  718. q31_t r, s;
  719. r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  720. s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  721. return ((uint32_t)((s << 16) | (r )));
  722. }
  723. /*
  724. * @brief C custom defined QSAX for M3 and M0 processors
  725. */
  726. static __INLINE uint32_t __QSAX(
  727. uint32_t x,
  728. uint32_t y)
  729. {
  730. q31_t r, s;
  731. r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  732. s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  733. return ((uint32_t)((s << 16) | (r )));
  734. }
  735. /*
  736. * @brief C custom defined SHSAX for M3 and M0 processors
  737. */
  738. static __INLINE uint32_t __SHSAX(
  739. uint32_t x,
  740. uint32_t y)
  741. {
  742. q31_t r, s;
  743. r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  744. s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  745. return ((uint32_t)((s << 16) | (r )));
  746. }
  747. /*
  748. * @brief C custom defined SMUSDX for M3 and M0 processors
  749. */
  750. static __INLINE uint32_t __SMUSDX(
  751. uint32_t x,
  752. uint32_t y)
  753. {
  754. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
  755. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
  756. }
  757. /*
  758. * @brief C custom defined SMUADX for M3 and M0 processors
  759. */
  760. static __INLINE uint32_t __SMUADX(
  761. uint32_t x,
  762. uint32_t y)
  763. {
  764. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  765. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
  766. }
  767. /*
  768. * @brief C custom defined QADD for M3 and M0 processors
  769. */
  770. static __INLINE int32_t __QADD(
  771. int32_t x,
  772. int32_t y)
  773. {
  774. return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y)));
  775. }
  776. /*
  777. * @brief C custom defined QSUB for M3 and M0 processors
  778. */
  779. static __INLINE int32_t __QSUB(
  780. int32_t x,
  781. int32_t y)
  782. {
  783. return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y)));
  784. }
  785. /*
  786. * @brief C custom defined SMLAD for M3 and M0 processors
  787. */
  788. static __INLINE uint32_t __SMLAD(
  789. uint32_t x,
  790. uint32_t y,
  791. uint32_t sum)
  792. {
  793. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  794. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
  795. ( ((q31_t)sum ) ) ));
  796. }
  797. /*
  798. * @brief C custom defined SMLADX for M3 and M0 processors
  799. */
  800. static __INLINE uint32_t __SMLADX(
  801. uint32_t x,
  802. uint32_t y,
  803. uint32_t sum)
  804. {
  805. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  806. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  807. ( ((q31_t)sum ) ) ));
  808. }
  809. /*
  810. * @brief C custom defined SMLSDX for M3 and M0 processors
  811. */
  812. static __INLINE uint32_t __SMLSDX(
  813. uint32_t x,
  814. uint32_t y,
  815. uint32_t sum)
  816. {
  817. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
  818. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  819. ( ((q31_t)sum ) ) ));
  820. }
  821. /*
  822. * @brief C custom defined SMLALD for M3 and M0 processors
  823. */
  824. static __INLINE uint64_t __SMLALD(
  825. uint32_t x,
  826. uint32_t y,
  827. uint64_t sum)
  828. {
  829. /* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */
  830. return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  831. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
  832. ( ((q63_t)sum ) ) ));
  833. }
  834. /*
  835. * @brief C custom defined SMLALDX for M3 and M0 processors
  836. */
  837. static __INLINE uint64_t __SMLALDX(
  838. uint32_t x,
  839. uint32_t y,
  840. uint64_t sum)
  841. {
  842. /* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */
  843. return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  844. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  845. ( ((q63_t)sum ) ) ));
  846. }
  847. /*
  848. * @brief C custom defined SMUAD for M3 and M0 processors
  849. */
  850. static __INLINE uint32_t __SMUAD(
  851. uint32_t x,
  852. uint32_t y)
  853. {
  854. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  855. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
  856. }
  857. /*
  858. * @brief C custom defined SMUSD for M3 and M0 processors
  859. */
  860. static __INLINE uint32_t __SMUSD(
  861. uint32_t x,
  862. uint32_t y)
  863. {
  864. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) -
  865. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
  866. }
  867. /*
  868. * @brief C custom defined SXTB16 for M3 and M0 processors
  869. */
  870. static __INLINE uint32_t __SXTB16(
  871. uint32_t x)
  872. {
  873. return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) |
  874. ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) ));
  875. }
  876. #endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
  877. /**
  878. * @brief Instance structure for the Q7 FIR filter.
  879. */
  880. typedef struct {
  881. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  882. q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  883. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  884. } arm_fir_instance_q7;
  885. /**
  886. * @brief Instance structure for the Q15 FIR filter.
  887. */
  888. typedef struct {
  889. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  890. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  891. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  892. } arm_fir_instance_q15;
  893. /**
  894. * @brief Instance structure for the Q31 FIR filter.
  895. */
  896. typedef struct {
  897. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  898. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  899. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  900. } arm_fir_instance_q31;
  901. /**
  902. * @brief Instance structure for the floating-point FIR filter.
  903. */
  904. typedef struct {
  905. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  906. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  907. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  908. } arm_fir_instance_f32;
  909. /**
  910. * @brief Processing function for the Q7 FIR filter.
  911. * @param[in] S points to an instance of the Q7 FIR filter structure.
  912. * @param[in] pSrc points to the block of input data.
  913. * @param[out] pDst points to the block of output data.
  914. * @param[in] blockSize number of samples to process.
  915. */
  916. void arm_fir_q7(const arm_fir_instance_q7 * S, q7_t * pSrc, q7_t * pDst,
  917. uint32_t blockSize);
  918. /**
  919. * @brief Initialization function for the Q7 FIR filter.
  920. * @param[in,out] S points to an instance of the Q7 FIR structure.
  921. * @param[in] numTaps Number of filter coefficients in the filter.
  922. * @param[in] pCoeffs points to the filter coefficients.
  923. * @param[in] pState points to the state buffer.
  924. * @param[in] blockSize number of samples that are processed.
  925. */
  926. void arm_fir_init_q7(arm_fir_instance_q7 * S, uint16_t numTaps, q7_t * pCoeffs,
  927. q7_t * pState, uint32_t blockSize);
  928. /**
  929. * @brief Processing function for the Q15 FIR filter.
  930. * @param[in] S points to an instance of the Q15 FIR structure.
  931. * @param[in] pSrc points to the block of input data.
  932. * @param[out] pDst points to the block of output data.
  933. * @param[in] blockSize number of samples to process.
  934. */
  935. void arm_fir_q15(const arm_fir_instance_q15 * S, q15_t * pSrc, q15_t * pDst,
  936. uint32_t blockSize);
  937. /**
  938. * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
  939. * @param[in] S points to an instance of the Q15 FIR filter structure.
  940. * @param[in] pSrc points to the block of input data.
  941. * @param[out] pDst points to the block of output data.
  942. * @param[in] blockSize number of samples to process.
  943. */
  944. void arm_fir_fast_q15(const arm_fir_instance_q15 * S, q15_t * pSrc,
  945. q15_t * pDst, uint32_t blockSize);
  946. /**
  947. * @brief Initialization function for the Q15 FIR filter.
  948. * @param[in,out] S points to an instance of the Q15 FIR filter structure.
  949. * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
  950. * @param[in] pCoeffs points to the filter coefficients.
  951. * @param[in] pState points to the state buffer.
  952. * @param[in] blockSize number of samples that are processed at a time.
  953. * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
  954. * <code>numTaps</code> is not a supported value.
  955. */
  956. arm_status arm_fir_init_q15(arm_fir_instance_q15 * S, uint16_t numTaps,
  957. q15_t * pCoeffs, q15_t * pState, uint32_t blockSize);
  958. /**
  959. * @brief Processing function for the Q31 FIR filter.
  960. * @param[in] S points to an instance of the Q31 FIR filter structure.
  961. * @param[in] pSrc points to the block of input data.
  962. * @param[out] pDst points to the block of output data.
  963. * @param[in] blockSize number of samples to process.
  964. */
  965. void arm_fir_q31(const arm_fir_instance_q31 * S, q31_t * pSrc, q31_t * pDst,
  966. uint32_t blockSize);
  967. /**
  968. * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
  969. * @param[in] S points to an instance of the Q31 FIR structure.
  970. * @param[in] pSrc points to the block of input data.
  971. * @param[out] pDst points to the block of output data.
  972. * @param[in] blockSize number of samples to process.
  973. */
  974. void arm_fir_fast_q31(const arm_fir_instance_q31 * S, q31_t * pSrc,
  975. q31_t * pDst, uint32_t blockSize);
  976. /**
  977. * @brief Initialization function for the Q31 FIR filter.
  978. * @param[in,out] S points to an instance of the Q31 FIR structure.
  979. * @param[in] numTaps Number of filter coefficients in the filter.
  980. * @param[in] pCoeffs points to the filter coefficients.
  981. * @param[in] pState points to the state buffer.
  982. * @param[in] blockSize number of samples that are processed at a time.
  983. */
  984. void arm_fir_init_q31(arm_fir_instance_q31 * S, uint16_t numTaps,
  985. q31_t * pCoeffs, q31_t * pState, uint32_t blockSize);
  986. /**
  987. * @brief Processing function for the floating-point FIR filter.
  988. * @param[in] S points to an instance of the floating-point FIR structure.
  989. * @param[in] pSrc points to the block of input data.
  990. * @param[out] pDst points to the block of output data.
  991. * @param[in] blockSize number of samples to process.
  992. */
  993. void arm_fir_f32(const arm_fir_instance_f32 * S, float32_t * pSrc,
  994. float32_t * pDst, uint32_t blockSize);
  995. /**
  996. * @brief Initialization function for the floating-point FIR filter.
  997. * @param[in,out] S points to an instance of the floating-point FIR filter structure.
  998. * @param[in] numTaps Number of filter coefficients in the filter.
  999. * @param[in] pCoeffs points to the filter coefficients.
  1000. * @param[in] pState points to the state buffer.
  1001. * @param[in] blockSize number of samples that are processed at a time.
  1002. */
  1003. void arm_fir_init_f32(arm_fir_instance_f32 * S, uint16_t numTaps,
  1004. float32_t * pCoeffs, float32_t * pState, uint32_t blockSize);
  1005. /**
  1006. * @brief Instance structure for the Q15 Biquad cascade filter.
  1007. */
  1008. typedef struct {
  1009. int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1010. q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1011. q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1012. int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1013. } arm_biquad_casd_df1_inst_q15;
  1014. /**
  1015. * @brief Instance structure for the Q31 Biquad cascade filter.
  1016. */
  1017. typedef struct {
  1018. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1019. q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1020. q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1021. uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1022. } arm_biquad_casd_df1_inst_q31;
  1023. /**
  1024. * @brief Instance structure for the floating-point Biquad cascade filter.
  1025. */
  1026. typedef struct {
  1027. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1028. float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1029. float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1030. } arm_biquad_casd_df1_inst_f32;
  1031. /**
  1032. * @brief Processing function for the Q15 Biquad cascade filter.
  1033. * @param[in] S points to an instance of the Q15 Biquad cascade structure.
  1034. * @param[in] pSrc points to the block of input data.
  1035. * @param[out] pDst points to the block of output data.
  1036. * @param[in] blockSize number of samples to process.
  1037. */
  1038. void arm_biquad_cascade_df1_q15(const arm_biquad_casd_df1_inst_q15 * S,
  1039. q15_t * pSrc, q15_t * pDst, uint32_t blockSize);
  1040. /**
  1041. * @brief Initialization function for the Q15 Biquad cascade filter.
  1042. * @param[in,out] S points to an instance of the Q15 Biquad cascade structure.
  1043. * @param[in] numStages number of 2nd order stages in the filter.
  1044. * @param[in] pCoeffs points to the filter coefficients.
  1045. * @param[in] pState points to the state buffer.
  1046. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1047. */
  1048. void arm_biquad_cascade_df1_init_q15(arm_biquad_casd_df1_inst_q15 * S,
  1049. uint8_t numStages, q15_t * pCoeffs, q15_t * pState, int8_t postShift);
  1050. /**
  1051. * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1052. * @param[in] S points to an instance of the Q15 Biquad cascade structure.
  1053. * @param[in] pSrc points to the block of input data.
  1054. * @param[out] pDst points to the block of output data.
  1055. * @param[in] blockSize number of samples to process.
  1056. */
  1057. void arm_biquad_cascade_df1_fast_q15(const arm_biquad_casd_df1_inst_q15 * S,
  1058. q15_t * pSrc, q15_t * pDst, uint32_t blockSize);
  1059. /**
  1060. * @brief Processing function for the Q31 Biquad cascade filter
  1061. * @param[in] S points to an instance of the Q31 Biquad cascade structure.
  1062. * @param[in] pSrc points to the block of input data.
  1063. * @param[out] pDst points to the block of output data.
  1064. * @param[in] blockSize number of samples to process.
  1065. */
  1066. void arm_biquad_cascade_df1_q31(const arm_biquad_casd_df1_inst_q31 * S,
  1067. q31_t * pSrc, q31_t * pDst, uint32_t blockSize);
  1068. /**
  1069. * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1070. * @param[in] S points to an instance of the Q31 Biquad cascade structure.
  1071. * @param[in] pSrc points to the block of input data.
  1072. * @param[out] pDst points to the block of output data.
  1073. * @param[in] blockSize number of samples to process.
  1074. */
  1075. void arm_biquad_cascade_df1_fast_q31(const arm_biquad_casd_df1_inst_q31 * S,
  1076. q31_t * pSrc, q31_t * pDst, uint32_t blockSize);
  1077. /**
  1078. * @brief Initialization function for the Q31 Biquad cascade filter.
  1079. * @param[in,out] S points to an instance of the Q31 Biquad cascade structure.
  1080. * @param[in] numStages number of 2nd order stages in the filter.
  1081. * @param[in] pCoeffs points to the filter coefficients.
  1082. * @param[in] pState points to the state buffer.
  1083. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1084. */
  1085. void arm_biquad_cascade_df1_init_q31(arm_biquad_casd_df1_inst_q31 * S,
  1086. uint8_t numStages, q31_t * pCoeffs, q31_t * pState, int8_t postShift);
  1087. /**
  1088. * @brief Processing function for the floating-point Biquad cascade filter.
  1089. * @param[in] S points to an instance of the floating-point Biquad cascade structure.
  1090. * @param[in] pSrc points to the block of input data.
  1091. * @param[out] pDst points to the block of output data.
  1092. * @param[in] blockSize number of samples to process.
  1093. */
  1094. void arm_biquad_cascade_df1_f32(const arm_biquad_casd_df1_inst_f32 * S,
  1095. float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  1096. /**
  1097. * @brief Initialization function for the floating-point Biquad cascade filter.
  1098. * @param[in,out] S points to an instance of the floating-point Biquad cascade structure.
  1099. * @param[in] numStages number of 2nd order stages in the filter.
  1100. * @param[in] pCoeffs points to the filter coefficients.
  1101. * @param[in] pState points to the state buffer.
  1102. */
  1103. void arm_biquad_cascade_df1_init_f32(arm_biquad_casd_df1_inst_f32 * S,
  1104. uint8_t numStages, float32_t * pCoeffs, float32_t * pState);
  1105. /**
  1106. * @brief Instance structure for the floating-point matrix structure.
  1107. */
  1108. typedef struct {
  1109. uint16_t numRows; /**< number of rows of the matrix. */
  1110. uint16_t numCols; /**< number of columns of the matrix. */
  1111. float32_t *pData; /**< points to the data of the matrix. */
  1112. } arm_matrix_instance_f32;
  1113. /**
  1114. * @brief Instance structure for the floating-point matrix structure.
  1115. */
  1116. typedef struct {
  1117. uint16_t numRows; /**< number of rows of the matrix. */
  1118. uint16_t numCols; /**< number of columns of the matrix. */
  1119. float64_t *pData; /**< points to the data of the matrix. */
  1120. } arm_matrix_instance_f64;
  1121. /**
  1122. * @brief Instance structure for the Q15 matrix structure.
  1123. */
  1124. typedef struct {
  1125. uint16_t numRows; /**< number of rows of the matrix. */
  1126. uint16_t numCols; /**< number of columns of the matrix. */
  1127. q15_t *pData; /**< points to the data of the matrix. */
  1128. } arm_matrix_instance_q15;
  1129. /**
  1130. * @brief Instance structure for the Q31 matrix structure.
  1131. */
  1132. typedef struct {
  1133. uint16_t numRows; /**< number of rows of the matrix. */
  1134. uint16_t numCols; /**< number of columns of the matrix. */
  1135. q31_t *pData; /**< points to the data of the matrix. */
  1136. } arm_matrix_instance_q31;
  1137. /**
  1138. * @brief Floating-point matrix addition.
  1139. * @param[in] pSrcA points to the first input matrix structure
  1140. * @param[in] pSrcB points to the second input matrix structure
  1141. * @param[out] pDst points to output matrix structure
  1142. * @return The function returns either
  1143. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1144. */
  1145. arm_status arm_mat_add_f32(const arm_matrix_instance_f32 * pSrcA,
  1146. const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst);
  1147. /**
  1148. * @brief Q15 matrix addition.
  1149. * @param[in] pSrcA points to the first input matrix structure
  1150. * @param[in] pSrcB points to the second input matrix structure
  1151. * @param[out] pDst points to output matrix structure
  1152. * @return The function returns either
  1153. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1154. */
  1155. arm_status arm_mat_add_q15(const arm_matrix_instance_q15 * pSrcA,
  1156. const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst);
  1157. /**
  1158. * @brief Q31 matrix addition.
  1159. * @param[in] pSrcA points to the first input matrix structure
  1160. * @param[in] pSrcB points to the second input matrix structure
  1161. * @param[out] pDst points to output matrix structure
  1162. * @return The function returns either
  1163. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1164. */
  1165. arm_status arm_mat_add_q31(const arm_matrix_instance_q31 * pSrcA,
  1166. const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst);
  1167. /**
  1168. * @brief Floating-point, complex, matrix multiplication.
  1169. * @param[in] pSrcA points to the first input matrix structure
  1170. * @param[in] pSrcB points to the second input matrix structure
  1171. * @param[out] pDst points to output matrix structure
  1172. * @return The function returns either
  1173. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1174. */
  1175. arm_status arm_mat_cmplx_mult_f32(const arm_matrix_instance_f32 * pSrcA,
  1176. const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst);
  1177. /**
  1178. * @brief Q15, complex, matrix multiplication.
  1179. * @param[in] pSrcA points to the first input matrix structure
  1180. * @param[in] pSrcB points to the second input matrix structure
  1181. * @param[out] pDst points to output matrix structure
  1182. * @return The function returns either
  1183. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1184. */
  1185. arm_status arm_mat_cmplx_mult_q15(const arm_matrix_instance_q15 * pSrcA,
  1186. const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst,
  1187. q15_t * pScratch);
  1188. /**
  1189. * @brief Q31, complex, matrix multiplication.
  1190. * @param[in] pSrcA points to the first input matrix structure
  1191. * @param[in] pSrcB points to the second input matrix structure
  1192. * @param[out] pDst points to output matrix structure
  1193. * @return The function returns either
  1194. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1195. */
  1196. arm_status arm_mat_cmplx_mult_q31(const arm_matrix_instance_q31 * pSrcA,
  1197. const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst);
  1198. /**
  1199. * @brief Floating-point matrix transpose.
  1200. * @param[in] pSrc points to the input matrix
  1201. * @param[out] pDst points to the output matrix
  1202. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1203. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1204. */
  1205. arm_status arm_mat_trans_f32(const arm_matrix_instance_f32 * pSrc,
  1206. arm_matrix_instance_f32 * pDst);
  1207. /**
  1208. * @brief Q15 matrix transpose.
  1209. * @param[in] pSrc points to the input matrix
  1210. * @param[out] pDst points to the output matrix
  1211. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1212. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1213. */
  1214. arm_status arm_mat_trans_q15(const arm_matrix_instance_q15 * pSrc,
  1215. arm_matrix_instance_q15 * pDst);
  1216. /**
  1217. * @brief Q31 matrix transpose.
  1218. * @param[in] pSrc points to the input matrix
  1219. * @param[out] pDst points to the output matrix
  1220. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1221. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1222. */
  1223. arm_status arm_mat_trans_q31(const arm_matrix_instance_q31 * pSrc,
  1224. arm_matrix_instance_q31 * pDst);
  1225. /**
  1226. * @brief Floating-point matrix multiplication
  1227. * @param[in] pSrcA points to the first input matrix structure
  1228. * @param[in] pSrcB points to the second input matrix structure
  1229. * @param[out] pDst points to output matrix structure
  1230. * @return The function returns either
  1231. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1232. */
  1233. arm_status arm_mat_mult_f32(const arm_matrix_instance_f32 * pSrcA,
  1234. const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst);
  1235. /**
  1236. * @brief Q15 matrix multiplication
  1237. * @param[in] pSrcA points to the first input matrix structure
  1238. * @param[in] pSrcB points to the second input matrix structure
  1239. * @param[out] pDst points to output matrix structure
  1240. * @param[in] pState points to the array for storing intermediate results
  1241. * @return The function returns either
  1242. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1243. */
  1244. arm_status arm_mat_mult_q15(const arm_matrix_instance_q15 * pSrcA,
  1245. const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst,
  1246. q15_t * pState);
  1247. /**
  1248. * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1249. * @param[in] pSrcA points to the first input matrix structure
  1250. * @param[in] pSrcB points to the second input matrix structure
  1251. * @param[out] pDst points to output matrix structure
  1252. * @param[in] pState points to the array for storing intermediate results
  1253. * @return The function returns either
  1254. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1255. */
  1256. arm_status arm_mat_mult_fast_q15(const arm_matrix_instance_q15 * pSrcA,
  1257. const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst,
  1258. q15_t * pState);
  1259. /**
  1260. * @brief Q31 matrix multiplication
  1261. * @param[in] pSrcA points to the first input matrix structure
  1262. * @param[in] pSrcB points to the second input matrix structure
  1263. * @param[out] pDst points to output matrix structure
  1264. * @return The function returns either
  1265. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1266. */
  1267. arm_status arm_mat_mult_q31(const arm_matrix_instance_q31 * pSrcA,
  1268. const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst);
  1269. /**
  1270. * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1271. * @param[in] pSrcA points to the first input matrix structure
  1272. * @param[in] pSrcB points to the second input matrix structure
  1273. * @param[out] pDst points to output matrix structure
  1274. * @return The function returns either
  1275. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1276. */
  1277. arm_status arm_mat_mult_fast_q31(const arm_matrix_instance_q31 * pSrcA,
  1278. const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst);
  1279. /**
  1280. * @brief Floating-point matrix subtraction
  1281. * @param[in] pSrcA points to the first input matrix structure
  1282. * @param[in] pSrcB points to the second input matrix structure
  1283. * @param[out] pDst points to output matrix structure
  1284. * @return The function returns either
  1285. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1286. */
  1287. arm_status arm_mat_sub_f32(const arm_matrix_instance_f32 * pSrcA,
  1288. const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst);
  1289. /**
  1290. * @brief Q15 matrix subtraction
  1291. * @param[in] pSrcA points to the first input matrix structure
  1292. * @param[in] pSrcB points to the second input matrix structure
  1293. * @param[out] pDst points to output matrix structure
  1294. * @return The function returns either
  1295. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1296. */
  1297. arm_status arm_mat_sub_q15(const arm_matrix_instance_q15 * pSrcA,
  1298. const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst);
  1299. /**
  1300. * @brief Q31 matrix subtraction
  1301. * @param[in] pSrcA points to the first input matrix structure
  1302. * @param[in] pSrcB points to the second input matrix structure
  1303. * @param[out] pDst points to output matrix structure
  1304. * @return The function returns either
  1305. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1306. */
  1307. arm_status arm_mat_sub_q31(const arm_matrix_instance_q31 * pSrcA,
  1308. const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst);
  1309. /**
  1310. * @brief Floating-point matrix scaling.
  1311. * @param[in] pSrc points to the input matrix
  1312. * @param[in] scale scale factor
  1313. * @param[out] pDst points to the output matrix
  1314. * @return The function returns either
  1315. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1316. */
  1317. arm_status arm_mat_scale_f32(const arm_matrix_instance_f32 * pSrc,
  1318. float32_t scale, arm_matrix_instance_f32 * pDst);
  1319. /**
  1320. * @brief Q15 matrix scaling.
  1321. * @param[in] pSrc points to input matrix
  1322. * @param[in] scaleFract fractional portion of the scale factor
  1323. * @param[in] shift number of bits to shift the result by
  1324. * @param[out] pDst points to output matrix
  1325. * @return The function returns either
  1326. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1327. */
  1328. arm_status arm_mat_scale_q15(const arm_matrix_instance_q15 * pSrc,
  1329. q15_t scaleFract, int32_t shift, arm_matrix_instance_q15 * pDst);
  1330. /**
  1331. * @brief Q31 matrix scaling.
  1332. * @param[in] pSrc points to input matrix
  1333. * @param[in] scaleFract fractional portion of the scale factor
  1334. * @param[in] shift number of bits to shift the result by
  1335. * @param[out] pDst points to output matrix structure
  1336. * @return The function returns either
  1337. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1338. */
  1339. arm_status arm_mat_scale_q31(const arm_matrix_instance_q31 * pSrc,
  1340. q31_t scaleFract, int32_t shift, arm_matrix_instance_q31 * pDst);
  1341. /**
  1342. * @brief Q31 matrix initialization.
  1343. * @param[in,out] S points to an instance of the floating-point matrix structure.
  1344. * @param[in] nRows number of rows in the matrix.
  1345. * @param[in] nColumns number of columns in the matrix.
  1346. * @param[in] pData points to the matrix data array.
  1347. */
  1348. void arm_mat_init_q31(arm_matrix_instance_q31 * S, uint16_t nRows,
  1349. uint16_t nColumns, q31_t * pData);
  1350. /**
  1351. * @brief Q15 matrix initialization.
  1352. * @param[in,out] S points to an instance of the floating-point matrix structure.
  1353. * @param[in] nRows number of rows in the matrix.
  1354. * @param[in] nColumns number of columns in the matrix.
  1355. * @param[in] pData points to the matrix data array.
  1356. */
  1357. void arm_mat_init_q15(arm_matrix_instance_q15 * S, uint16_t nRows,
  1358. uint16_t nColumns, q15_t * pData);
  1359. /**
  1360. * @brief Floating-point matrix initialization.
  1361. * @param[in,out] S points to an instance of the floating-point matrix structure.
  1362. * @param[in] nRows number of rows in the matrix.
  1363. * @param[in] nColumns number of columns in the matrix.
  1364. * @param[in] pData points to the matrix data array.
  1365. */
  1366. void arm_mat_init_f32(arm_matrix_instance_f32 * S, uint16_t nRows,
  1367. uint16_t nColumns, float32_t * pData);
  1368. /**
  1369. * @brief Instance structure for the Q15 PID Control.
  1370. */
  1371. typedef struct {
  1372. q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1373. #ifdef ARM_MATH_CM0_FAMILY
  1374. q15_t A1;
  1375. q15_t A2;
  1376. #else
  1377. q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
  1378. #endif
  1379. q15_t state[3]; /**< The state array of length 3. */
  1380. q15_t Kp; /**< The proportional gain. */
  1381. q15_t Ki; /**< The integral gain. */
  1382. q15_t Kd; /**< The derivative gain. */
  1383. } arm_pid_instance_q15;
  1384. /**
  1385. * @brief Instance structure for the Q31 PID Control.
  1386. */
  1387. typedef struct {
  1388. q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1389. q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1390. q31_t A2; /**< The derived gain, A2 = Kd . */
  1391. q31_t state[3]; /**< The state array of length 3. */
  1392. q31_t Kp; /**< The proportional gain. */
  1393. q31_t Ki; /**< The integral gain. */
  1394. q31_t Kd; /**< The derivative gain. */
  1395. } arm_pid_instance_q31;
  1396. /**
  1397. * @brief Instance structure for the floating-point PID Control.
  1398. */
  1399. typedef struct {
  1400. float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1401. float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1402. float32_t A2; /**< The derived gain, A2 = Kd . */
  1403. float32_t state[3]; /**< The state array of length 3. */
  1404. float32_t Kp; /**< The proportional gain. */
  1405. float32_t Ki; /**< The integral gain. */
  1406. float32_t Kd; /**< The derivative gain. */
  1407. } arm_pid_instance_f32;
  1408. /**
  1409. * @brief Initialization function for the floating-point PID Control.
  1410. * @param[in,out] S points to an instance of the PID structure.
  1411. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1412. */
  1413. void arm_pid_init_f32(arm_pid_instance_f32 * S, int32_t resetStateFlag);
  1414. /**
  1415. * @brief Reset function for the floating-point PID Control.
  1416. * @param[in,out] S is an instance of the floating-point PID Control structure
  1417. */
  1418. void arm_pid_reset_f32(arm_pid_instance_f32 * S);
  1419. /**
  1420. * @brief Initialization function for the Q31 PID Control.
  1421. * @param[in,out] S points to an instance of the Q15 PID structure.
  1422. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1423. */
  1424. void arm_pid_init_q31(arm_pid_instance_q31 * S, int32_t resetStateFlag);
  1425. /**
  1426. * @brief Reset function for the Q31 PID Control.
  1427. * @param[in,out] S points to an instance of the Q31 PID Control structure
  1428. */
  1429. void arm_pid_reset_q31(arm_pid_instance_q31 * S);
  1430. /**
  1431. * @brief Initialization function for the Q15 PID Control.
  1432. * @param[in,out] S points to an instance of the Q15 PID structure.
  1433. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1434. */
  1435. void arm_pid_init_q15(arm_pid_instance_q15 * S, int32_t resetStateFlag);
  1436. /**
  1437. * @brief Reset function for the Q15 PID Control.
  1438. * @param[in,out] S points to an instance of the q15 PID Control structure
  1439. */
  1440. void arm_pid_reset_q15(arm_pid_instance_q15 * S);
  1441. /**
  1442. * @brief Instance structure for the floating-point Linear Interpolate function.
  1443. */
  1444. typedef struct {
  1445. uint32_t nValues; /**< nValues */
  1446. float32_t x1; /**< x1 */
  1447. float32_t xSpacing; /**< xSpacing */
  1448. float32_t *pYData; /**< pointer to the table of Y values */
  1449. } arm_linear_interp_instance_f32;
  1450. /**
  1451. * @brief Instance structure for the floating-point bilinear interpolation function.
  1452. */
  1453. typedef struct {
  1454. uint16_t numRows; /**< number of rows in the data table. */
  1455. uint16_t numCols; /**< number of columns in the data table. */
  1456. float32_t *pData; /**< points to the data table. */
  1457. } arm_bilinear_interp_instance_f32;
  1458. /**
  1459. * @brief Instance structure for the Q31 bilinear interpolation function.
  1460. */
  1461. typedef struct {
  1462. uint16_t numRows; /**< number of rows in the data table. */
  1463. uint16_t numCols; /**< number of columns in the data table. */
  1464. q31_t *pData; /**< points to the data table. */
  1465. } arm_bilinear_interp_instance_q31;
  1466. /**
  1467. * @brief Instance structure for the Q15 bilinear interpolation function.
  1468. */
  1469. typedef struct {
  1470. uint16_t numRows; /**< number of rows in the data table. */
  1471. uint16_t numCols; /**< number of columns in the data table. */
  1472. q15_t *pData; /**< points to the data table. */
  1473. } arm_bilinear_interp_instance_q15;
  1474. /**
  1475. * @brief Instance structure for the Q15 bilinear interpolation function.
  1476. */
  1477. typedef struct {
  1478. uint16_t numRows; /**< number of rows in the data table. */
  1479. uint16_t numCols; /**< number of columns in the data table. */
  1480. q7_t *pData; /**< points to the data table. */
  1481. } arm_bilinear_interp_instance_q7;
  1482. /**
  1483. * @brief Q7 vector multiplication.
  1484. * @param[in] pSrcA points to the first input vector
  1485. * @param[in] pSrcB points to the second input vector
  1486. * @param[out] pDst points to the output vector
  1487. * @param[in] blockSize number of samples in each vector
  1488. */
  1489. void arm_mult_q7(q7_t * pSrcA, q7_t * pSrcB, q7_t * pDst, uint32_t blockSize);
  1490. /**
  1491. * @brief Q15 vector multiplication.
  1492. * @param[in] pSrcA points to the first input vector
  1493. * @param[in] pSrcB points to the second input vector
  1494. * @param[out] pDst points to the output vector
  1495. * @param[in] blockSize number of samples in each vector
  1496. */
  1497. void arm_mult_q15(q15_t * pSrcA, q15_t * pSrcB, q15_t * pDst,
  1498. uint32_t blockSize);
  1499. /**
  1500. * @brief Q31 vector multiplication.
  1501. * @param[in] pSrcA points to the first input vector
  1502. * @param[in] pSrcB points to the second input vector
  1503. * @param[out] pDst points to the output vector
  1504. * @param[in] blockSize number of samples in each vector
  1505. */
  1506. void arm_mult_q31(q31_t * pSrcA, q31_t * pSrcB, q31_t * pDst,
  1507. uint32_t blockSize);
  1508. /**
  1509. * @brief Floating-point vector multiplication.
  1510. * @param[in] pSrcA points to the first input vector
  1511. * @param[in] pSrcB points to the second input vector
  1512. * @param[out] pDst points to the output vector
  1513. * @param[in] blockSize number of samples in each vector
  1514. */
  1515. void arm_mult_f32(float32_t * pSrcA, float32_t * pSrcB, float32_t * pDst,
  1516. uint32_t blockSize);
  1517. /**
  1518. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1519. */
  1520. typedef struct {
  1521. uint16_t fftLen; /**< length of the FFT. */
  1522. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1523. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1524. q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
  1525. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1526. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1527. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1528. } arm_cfft_radix2_instance_q15;
  1529. /* Deprecated */
  1530. arm_status arm_cfft_radix2_init_q15(arm_cfft_radix2_instance_q15 * S,
  1531. uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag);
  1532. /* Deprecated */
  1533. void arm_cfft_radix2_q15(const arm_cfft_radix2_instance_q15 * S, q15_t * pSrc);
  1534. /**
  1535. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1536. */
  1537. typedef struct {
  1538. uint16_t fftLen; /**< length of the FFT. */
  1539. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1540. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1541. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  1542. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1543. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1544. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1545. } arm_cfft_radix4_instance_q15;
  1546. /* Deprecated */
  1547. arm_status arm_cfft_radix4_init_q15(arm_cfft_radix4_instance_q15 * S,
  1548. uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag);
  1549. /* Deprecated */
  1550. void arm_cfft_radix4_q15(const arm_cfft_radix4_instance_q15 * S, q15_t * pSrc);
  1551. /**
  1552. * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
  1553. */
  1554. typedef struct {
  1555. uint16_t fftLen; /**< length of the FFT. */
  1556. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1557. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1558. q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  1559. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1560. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1561. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1562. } arm_cfft_radix2_instance_q31;
  1563. /* Deprecated */
  1564. arm_status arm_cfft_radix2_init_q31(arm_cfft_radix2_instance_q31 * S,
  1565. uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag);
  1566. /* Deprecated */
  1567. void arm_cfft_radix2_q31(const arm_cfft_radix2_instance_q31 * S, q31_t * pSrc);
  1568. /**
  1569. * @brief Instance structure for the Q31 CFFT/CIFFT function.
  1570. */
  1571. typedef struct {
  1572. uint16_t fftLen; /**< length of the FFT. */
  1573. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1574. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1575. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  1576. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1577. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1578. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1579. } arm_cfft_radix4_instance_q31;
  1580. /* Deprecated */
  1581. void arm_cfft_radix4_q31(const arm_cfft_radix4_instance_q31 * S, q31_t * pSrc);
  1582. /* Deprecated */
  1583. arm_status arm_cfft_radix4_init_q31(arm_cfft_radix4_instance_q31 * S,
  1584. uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag);
  1585. /**
  1586. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1587. */
  1588. typedef struct {
  1589. uint16_t fftLen; /**< length of the FFT. */
  1590. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1591. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1592. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1593. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1594. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1595. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1596. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1597. } arm_cfft_radix2_instance_f32;
  1598. /* Deprecated */
  1599. arm_status arm_cfft_radix2_init_f32(arm_cfft_radix2_instance_f32 * S,
  1600. uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag);
  1601. /* Deprecated */
  1602. void arm_cfft_radix2_f32(const arm_cfft_radix2_instance_f32 * S,
  1603. float32_t * pSrc);
  1604. /**
  1605. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1606. */
  1607. typedef struct {
  1608. uint16_t fftLen; /**< length of the FFT. */
  1609. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1610. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1611. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1612. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1613. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1614. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1615. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1616. } arm_cfft_radix4_instance_f32;
  1617. /* Deprecated */
  1618. arm_status arm_cfft_radix4_init_f32(arm_cfft_radix4_instance_f32 * S,
  1619. uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag);
  1620. /* Deprecated */
  1621. void arm_cfft_radix4_f32(const arm_cfft_radix4_instance_f32 * S,
  1622. float32_t * pSrc);
  1623. /**
  1624. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  1625. */
  1626. typedef struct {
  1627. uint16_t fftLen; /**< length of the FFT. */
  1628. const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
  1629. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1630. uint16_t bitRevLength; /**< bit reversal table length. */
  1631. } arm_cfft_instance_q15;
  1632. void arm_cfft_q15(const arm_cfft_instance_q15 * S, q15_t * p1, uint8_t ifftFlag,
  1633. uint8_t bitReverseFlag);
  1634. /**
  1635. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  1636. */
  1637. typedef struct {
  1638. uint16_t fftLen; /**< length of the FFT. */
  1639. const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  1640. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1641. uint16_t bitRevLength; /**< bit reversal table length. */
  1642. } arm_cfft_instance_q31;
  1643. void arm_cfft_q31(const arm_cfft_instance_q31 * S, q31_t * p1, uint8_t ifftFlag,
  1644. uint8_t bitReverseFlag);
  1645. /**
  1646. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1647. */
  1648. typedef struct {
  1649. uint16_t fftLen; /**< length of the FFT. */
  1650. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1651. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1652. uint16_t bitRevLength; /**< bit reversal table length. */
  1653. } arm_cfft_instance_f32;
  1654. void arm_cfft_f32(const arm_cfft_instance_f32 * S, float32_t * p1,
  1655. uint8_t ifftFlag, uint8_t bitReverseFlag);
  1656. /**
  1657. * @brief Instance structure for the Q15 RFFT/RIFFT function.
  1658. */
  1659. typedef struct {
  1660. uint32_t fftLenReal; /**< length of the real FFT. */
  1661. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1662. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1663. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1664. q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1665. q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1666. const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  1667. } arm_rfft_instance_q15;
  1668. arm_status arm_rfft_init_q15(arm_rfft_instance_q15 * S, uint32_t fftLenReal,
  1669. uint32_t ifftFlagR, uint32_t bitReverseFlag);
  1670. void arm_rfft_q15(const arm_rfft_instance_q15 * S, q15_t * pSrc, q15_t * pDst);
  1671. /**
  1672. * @brief Instance structure for the Q31 RFFT/RIFFT function.
  1673. */
  1674. typedef struct {
  1675. uint32_t fftLenReal; /**< length of the real FFT. */
  1676. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1677. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1678. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1679. q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1680. q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1681. const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  1682. } arm_rfft_instance_q31;
  1683. arm_status arm_rfft_init_q31(arm_rfft_instance_q31 * S, uint32_t fftLenReal,
  1684. uint32_t ifftFlagR, uint32_t bitReverseFlag);
  1685. void arm_rfft_q31(const arm_rfft_instance_q31 * S, q31_t * pSrc, q31_t * pDst);
  1686. /**
  1687. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1688. */
  1689. typedef struct {
  1690. uint32_t fftLenReal; /**< length of the real FFT. */
  1691. uint16_t fftLenBy2; /**< length of the complex FFT. */
  1692. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1693. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1694. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1695. float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1696. float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1697. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1698. } arm_rfft_instance_f32;
  1699. arm_status arm_rfft_init_f32(arm_rfft_instance_f32 * S,
  1700. arm_cfft_radix4_instance_f32 * S_CFFT, uint32_t fftLenReal,
  1701. uint32_t ifftFlagR, uint32_t bitReverseFlag);
  1702. void arm_rfft_f32(const arm_rfft_instance_f32 * S, float32_t * pSrc,
  1703. float32_t * pDst);
  1704. /**
  1705. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1706. */
  1707. typedef struct {
  1708. arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
  1709. uint16_t fftLenRFFT; /**< length of the real sequence */
  1710. float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  1711. } arm_rfft_fast_instance_f32;
  1712. arm_status arm_rfft_fast_init_f32(arm_rfft_fast_instance_f32 * S,
  1713. uint16_t fftLen);
  1714. void arm_rfft_fast_f32(arm_rfft_fast_instance_f32 * S, float32_t * p,
  1715. float32_t * pOut, uint8_t ifftFlag);
  1716. /**
  1717. * @brief Instance structure for the floating-point DCT4/IDCT4 function.
  1718. */
  1719. typedef struct {
  1720. uint16_t N; /**< length of the DCT4. */
  1721. uint16_t Nby2; /**< half of the length of the DCT4. */
  1722. float32_t normalize; /**< normalizing factor. */
  1723. float32_t *pTwiddle; /**< points to the twiddle factor table. */
  1724. float32_t *pCosFactor; /**< points to the cosFactor table. */
  1725. arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
  1726. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1727. } arm_dct4_instance_f32;
  1728. /**
  1729. * @brief Initialization function for the floating-point DCT4/IDCT4.
  1730. * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure.
  1731. * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
  1732. * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
  1733. * @param[in] N length of the DCT4.
  1734. * @param[in] Nby2 half of the length of the DCT4.
  1735. * @param[in] normalize normalizing factor.
  1736. * @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.
  1737. */
  1738. arm_status arm_dct4_init_f32(arm_dct4_instance_f32 * S,
  1739. arm_rfft_instance_f32 * S_RFFT, arm_cfft_radix4_instance_f32 * S_CFFT,
  1740. uint16_t N, uint16_t Nby2, float32_t normalize);
  1741. /**
  1742. * @brief Processing function for the floating-point DCT4/IDCT4.
  1743. * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure.
  1744. * @param[in] pState points to state buffer.
  1745. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  1746. */
  1747. void arm_dct4_f32(const arm_dct4_instance_f32 * S, float32_t * pState,
  1748. float32_t * pInlineBuffer);
  1749. /**
  1750. * @brief Instance structure for the Q31 DCT4/IDCT4 function.
  1751. */
  1752. typedef struct {
  1753. uint16_t N; /**< length of the DCT4. */
  1754. uint16_t Nby2; /**< half of the length of the DCT4. */
  1755. q31_t normalize; /**< normalizing factor. */
  1756. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  1757. q31_t *pCosFactor; /**< points to the cosFactor table. */
  1758. arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
  1759. arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  1760. } arm_dct4_instance_q31;
  1761. /**
  1762. * @brief Initialization function for the Q31 DCT4/IDCT4.
  1763. * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure.
  1764. * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure
  1765. * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure
  1766. * @param[in] N length of the DCT4.
  1767. * @param[in] Nby2 half of the length of the DCT4.
  1768. * @param[in] normalize normalizing factor.
  1769. * @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.
  1770. */
  1771. arm_status arm_dct4_init_q31(arm_dct4_instance_q31 * S,
  1772. arm_rfft_instance_q31 * S_RFFT, arm_cfft_radix4_instance_q31 * S_CFFT,
  1773. uint16_t N, uint16_t Nby2, q31_t normalize);
  1774. /**
  1775. * @brief Processing function for the Q31 DCT4/IDCT4.
  1776. * @param[in] S points to an instance of the Q31 DCT4 structure.
  1777. * @param[in] pState points to state buffer.
  1778. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  1779. */
  1780. void arm_dct4_q31(const arm_dct4_instance_q31 * S, q31_t * pState,
  1781. q31_t * pInlineBuffer);
  1782. /**
  1783. * @brief Instance structure for the Q15 DCT4/IDCT4 function.
  1784. */
  1785. typedef struct {
  1786. uint16_t N; /**< length of the DCT4. */
  1787. uint16_t Nby2; /**< half of the length of the DCT4. */
  1788. q15_t normalize; /**< normalizing factor. */
  1789. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  1790. q15_t *pCosFactor; /**< points to the cosFactor table. */
  1791. arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
  1792. arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  1793. } arm_dct4_instance_q15;
  1794. /**
  1795. * @brief Initialization function for the Q15 DCT4/IDCT4.
  1796. * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure.
  1797. * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
  1798. * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
  1799. * @param[in] N length of the DCT4.
  1800. * @param[in] Nby2 half of the length of the DCT4.
  1801. * @param[in] normalize normalizing factor.
  1802. * @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.
  1803. */
  1804. arm_status arm_dct4_init_q15(arm_dct4_instance_q15 * S,
  1805. arm_rfft_instance_q15 * S_RFFT, arm_cfft_radix4_instance_q15 * S_CFFT,
  1806. uint16_t N, uint16_t Nby2, q15_t normalize);
  1807. /**
  1808. * @brief Processing function for the Q15 DCT4/IDCT4.
  1809. * @param[in] S points to an instance of the Q15 DCT4 structure.
  1810. * @param[in] pState points to state buffer.
  1811. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  1812. */
  1813. void arm_dct4_q15(const arm_dct4_instance_q15 * S, q15_t * pState,
  1814. q15_t * pInlineBuffer);
  1815. /**
  1816. * @brief Floating-point vector addition.
  1817. * @param[in] pSrcA points to the first input vector
  1818. * @param[in] pSrcB points to the second input vector
  1819. * @param[out] pDst points to the output vector
  1820. * @param[in] blockSize number of samples in each vector
  1821. */
  1822. void arm_add_f32(float32_t * pSrcA, float32_t * pSrcB, float32_t * pDst,
  1823. uint32_t blockSize);
  1824. /**
  1825. * @brief Q7 vector addition.
  1826. * @param[in] pSrcA points to the first input vector
  1827. * @param[in] pSrcB points to the second input vector
  1828. * @param[out] pDst points to the output vector
  1829. * @param[in] blockSize number of samples in each vector
  1830. */
  1831. void arm_add_q7(q7_t * pSrcA, q7_t * pSrcB, q7_t * pDst, uint32_t blockSize);
  1832. /**
  1833. * @brief Q15 vector addition.
  1834. * @param[in] pSrcA points to the first input vector
  1835. * @param[in] pSrcB points to the second input vector
  1836. * @param[out] pDst points to the output vector
  1837. * @param[in] blockSize number of samples in each vector
  1838. */
  1839. void arm_add_q15(q15_t * pSrcA, q15_t * pSrcB, q15_t * pDst, uint32_t blockSize);
  1840. /**
  1841. * @brief Q31 vector addition.
  1842. * @param[in] pSrcA points to the first input vector
  1843. * @param[in] pSrcB points to the second input vector
  1844. * @param[out] pDst points to the output vector
  1845. * @param[in] blockSize number of samples in each vector
  1846. */
  1847. void arm_add_q31(q31_t * pSrcA, q31_t * pSrcB, q31_t * pDst, uint32_t blockSize);
  1848. /**
  1849. * @brief Floating-point vector subtraction.
  1850. * @param[in] pSrcA points to the first input vector
  1851. * @param[in] pSrcB points to the second input vector
  1852. * @param[out] pDst points to the output vector
  1853. * @param[in] blockSize number of samples in each vector
  1854. */
  1855. void arm_sub_f32(float32_t * pSrcA, float32_t * pSrcB, float32_t * pDst,
  1856. uint32_t blockSize);
  1857. /**
  1858. * @brief Q7 vector subtraction.
  1859. * @param[in] pSrcA points to the first input vector
  1860. * @param[in] pSrcB points to the second input vector
  1861. * @param[out] pDst points to the output vector
  1862. * @param[in] blockSize number of samples in each vector
  1863. */
  1864. void arm_sub_q7(q7_t * pSrcA, q7_t * pSrcB, q7_t * pDst, uint32_t blockSize);
  1865. /**
  1866. * @brief Q15 vector subtraction.
  1867. * @param[in] pSrcA points to the first input vector
  1868. * @param[in] pSrcB points to the second input vector
  1869. * @param[out] pDst points to the output vector
  1870. * @param[in] blockSize number of samples in each vector
  1871. */
  1872. void arm_sub_q15(q15_t * pSrcA, q15_t * pSrcB, q15_t * pDst, uint32_t blockSize);
  1873. /**
  1874. * @brief Q31 vector subtraction.
  1875. * @param[in] pSrcA points to the first input vector
  1876. * @param[in] pSrcB points to the second input vector
  1877. * @param[out] pDst points to the output vector
  1878. * @param[in] blockSize number of samples in each vector
  1879. */
  1880. void arm_sub_q31(q31_t * pSrcA, q31_t * pSrcB, q31_t * pDst, uint32_t blockSize);
  1881. /**
  1882. * @brief Multiplies a floating-point vector by a scalar.
  1883. * @param[in] pSrc points to the input vector
  1884. * @param[in] scale scale factor to be applied
  1885. * @param[out] pDst points to the output vector
  1886. * @param[in] blockSize number of samples in the vector
  1887. */
  1888. void arm_scale_f32(float32_t * pSrc, float32_t scale, float32_t * pDst,
  1889. uint32_t blockSize);
  1890. /**
  1891. * @brief Multiplies a Q7 vector by a scalar.
  1892. * @param[in] pSrc points to the input vector
  1893. * @param[in] scaleFract fractional portion of the scale value
  1894. * @param[in] shift number of bits to shift the result by
  1895. * @param[out] pDst points to the output vector
  1896. * @param[in] blockSize number of samples in the vector
  1897. */
  1898. void arm_scale_q7(q7_t * pSrc, q7_t scaleFract, int8_t shift, q7_t * pDst,
  1899. uint32_t blockSize);
  1900. /**
  1901. * @brief Multiplies a Q15 vector by a scalar.
  1902. * @param[in] pSrc points to the input vector
  1903. * @param[in] scaleFract fractional portion of the scale value
  1904. * @param[in] shift number of bits to shift the result by
  1905. * @param[out] pDst points to the output vector
  1906. * @param[in] blockSize number of samples in the vector
  1907. */
  1908. void arm_scale_q15(q15_t * pSrc, q15_t scaleFract, int8_t shift, q15_t * pDst,
  1909. uint32_t blockSize);
  1910. /**
  1911. * @brief Multiplies a Q31 vector by a scalar.
  1912. * @param[in] pSrc points to the input vector
  1913. * @param[in] scaleFract fractional portion of the scale value
  1914. * @param[in] shift number of bits to shift the result by
  1915. * @param[out] pDst points to the output vector
  1916. * @param[in] blockSize number of samples in the vector
  1917. */
  1918. void arm_scale_q31(q31_t * pSrc, q31_t scaleFract, int8_t shift, q31_t * pDst,
  1919. uint32_t blockSize);
  1920. /**
  1921. * @brief Q7 vector absolute value.
  1922. * @param[in] pSrc points to the input buffer
  1923. * @param[out] pDst points to the output buffer
  1924. * @param[in] blockSize number of samples in each vector
  1925. */
  1926. void arm_abs_q7(q7_t * pSrc, q7_t * pDst, uint32_t blockSize);
  1927. /**
  1928. * @brief Floating-point vector absolute value.
  1929. * @param[in] pSrc points to the input buffer
  1930. * @param[out] pDst points to the output buffer
  1931. * @param[in] blockSize number of samples in each vector
  1932. */
  1933. void arm_abs_f32(float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  1934. /**
  1935. * @brief Q15 vector absolute value.
  1936. * @param[in] pSrc points to the input buffer
  1937. * @param[out] pDst points to the output buffer
  1938. * @param[in] blockSize number of samples in each vector
  1939. */
  1940. void arm_abs_q15(q15_t * pSrc, q15_t * pDst, uint32_t blockSize);
  1941. /**
  1942. * @brief Q31 vector absolute value.
  1943. * @param[in] pSrc points to the input buffer
  1944. * @param[out] pDst points to the output buffer
  1945. * @param[in] blockSize number of samples in each vector
  1946. */
  1947. void arm_abs_q31(q31_t * pSrc, q31_t * pDst, uint32_t blockSize);
  1948. /**
  1949. * @brief Dot product of floating-point vectors.
  1950. * @param[in] pSrcA points to the first input vector
  1951. * @param[in] pSrcB points to the second input vector
  1952. * @param[in] blockSize number of samples in each vector
  1953. * @param[out] result output result returned here
  1954. */
  1955. void arm_dot_prod_f32(float32_t * pSrcA, float32_t * pSrcB, uint32_t blockSize,
  1956. float32_t * result);
  1957. /**
  1958. * @brief Dot product of Q7 vectors.
  1959. * @param[in] pSrcA points to the first input vector
  1960. * @param[in] pSrcB points to the second input vector
  1961. * @param[in] blockSize number of samples in each vector
  1962. * @param[out] result output result returned here
  1963. */
  1964. void arm_dot_prod_q7(q7_t * pSrcA, q7_t * pSrcB, uint32_t blockSize,
  1965. q31_t * result);
  1966. /**
  1967. * @brief Dot product of Q15 vectors.
  1968. * @param[in] pSrcA points to the first input vector
  1969. * @param[in] pSrcB points to the second input vector
  1970. * @param[in] blockSize number of samples in each vector
  1971. * @param[out] result output result returned here
  1972. */
  1973. void arm_dot_prod_q15(q15_t * pSrcA, q15_t * pSrcB, uint32_t blockSize,
  1974. q63_t * result);
  1975. /**
  1976. * @brief Dot product of Q31 vectors.
  1977. * @param[in] pSrcA points to the first input vector
  1978. * @param[in] pSrcB points to the second input vector
  1979. * @param[in] blockSize number of samples in each vector
  1980. * @param[out] result output result returned here
  1981. */
  1982. void arm_dot_prod_q31(q31_t * pSrcA, q31_t * pSrcB, uint32_t blockSize,
  1983. q63_t * result);
  1984. /**
  1985. * @brief Shifts the elements of a Q7 vector a specified number of bits.
  1986. * @param[in] pSrc points to the input vector
  1987. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  1988. * @param[out] pDst points to the output vector
  1989. * @param[in] blockSize number of samples in the vector
  1990. */
  1991. void arm_shift_q7(q7_t * pSrc, int8_t shiftBits, q7_t * pDst,
  1992. uint32_t blockSize);
  1993. /**
  1994. * @brief Shifts the elements of a Q15 vector a specified number of bits.
  1995. * @param[in] pSrc points to the input vector
  1996. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  1997. * @param[out] pDst points to the output vector
  1998. * @param[in] blockSize number of samples in the vector
  1999. */
  2000. void arm_shift_q15(q15_t * pSrc, int8_t shiftBits, q15_t * pDst,
  2001. uint32_t blockSize);
  2002. /**
  2003. * @brief Shifts the elements of a Q31 vector a specified number of bits.
  2004. * @param[in] pSrc points to the input vector
  2005. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2006. * @param[out] pDst points to the output vector
  2007. * @param[in] blockSize number of samples in the vector
  2008. */
  2009. void arm_shift_q31(q31_t * pSrc, int8_t shiftBits, q31_t * pDst,
  2010. uint32_t blockSize);
  2011. /**
  2012. * @brief Adds a constant offset to a floating-point vector.
  2013. * @param[in] pSrc points to the input vector
  2014. * @param[in] offset is the offset to be added
  2015. * @param[out] pDst points to the output vector
  2016. * @param[in] blockSize number of samples in the vector
  2017. */
  2018. void arm_offset_f32(float32_t * pSrc, float32_t offset, float32_t * pDst,
  2019. uint32_t blockSize);
  2020. /**
  2021. * @brief Adds a constant offset to a Q7 vector.
  2022. * @param[in] pSrc points to the input vector
  2023. * @param[in] offset is the offset to be added
  2024. * @param[out] pDst points to the output vector
  2025. * @param[in] blockSize number of samples in the vector
  2026. */
  2027. void arm_offset_q7(q7_t * pSrc, q7_t offset, q7_t * pDst, uint32_t blockSize);
  2028. /**
  2029. * @brief Adds a constant offset to a Q15 vector.
  2030. * @param[in] pSrc points to the input vector
  2031. * @param[in] offset is the offset to be added
  2032. * @param[out] pDst points to the output vector
  2033. * @param[in] blockSize number of samples in the vector
  2034. */
  2035. void arm_offset_q15(q15_t * pSrc, q15_t offset, q15_t * pDst,
  2036. uint32_t blockSize);
  2037. /**
  2038. * @brief Adds a constant offset to a Q31 vector.
  2039. * @param[in] pSrc points to the input vector
  2040. * @param[in] offset is the offset to be added
  2041. * @param[out] pDst points to the output vector
  2042. * @param[in] blockSize number of samples in the vector
  2043. */
  2044. void arm_offset_q31(q31_t * pSrc, q31_t offset, q31_t * pDst,
  2045. uint32_t blockSize);
  2046. /**
  2047. * @brief Negates the elements of a floating-point vector.
  2048. * @param[in] pSrc points to the input vector
  2049. * @param[out] pDst points to the output vector
  2050. * @param[in] blockSize number of samples in the vector
  2051. */
  2052. void arm_negate_f32(float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  2053. /**
  2054. * @brief Negates the elements of a Q7 vector.
  2055. * @param[in] pSrc points to the input vector
  2056. * @param[out] pDst points to the output vector
  2057. * @param[in] blockSize number of samples in the vector
  2058. */
  2059. void arm_negate_q7(q7_t * pSrc, q7_t * pDst, uint32_t blockSize);
  2060. /**
  2061. * @brief Negates the elements of a Q15 vector.
  2062. * @param[in] pSrc points to the input vector
  2063. * @param[out] pDst points to the output vector
  2064. * @param[in] blockSize number of samples in the vector
  2065. */
  2066. void arm_negate_q15(q15_t * pSrc, q15_t * pDst, uint32_t blockSize);
  2067. /**
  2068. * @brief Negates the elements of a Q31 vector.
  2069. * @param[in] pSrc points to the input vector
  2070. * @param[out] pDst points to the output vector
  2071. * @param[in] blockSize number of samples in the vector
  2072. */
  2073. void arm_negate_q31(q31_t * pSrc, q31_t * pDst, uint32_t blockSize);
  2074. /**
  2075. * @brief Copies the elements of a floating-point vector.
  2076. * @param[in] pSrc input pointer
  2077. * @param[out] pDst output pointer
  2078. * @param[in] blockSize number of samples to process
  2079. */
  2080. void arm_copy_f32(float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  2081. /**
  2082. * @brief Copies the elements of a Q7 vector.
  2083. * @param[in] pSrc input pointer
  2084. * @param[out] pDst output pointer
  2085. * @param[in] blockSize number of samples to process
  2086. */
  2087. void arm_copy_q7(q7_t * pSrc, q7_t * pDst, uint32_t blockSize);
  2088. /**
  2089. * @brief Copies the elements of a Q15 vector.
  2090. * @param[in] pSrc input pointer
  2091. * @param[out] pDst output pointer
  2092. * @param[in] blockSize number of samples to process
  2093. */
  2094. void arm_copy_q15(q15_t * pSrc, q15_t * pDst, uint32_t blockSize);
  2095. /**
  2096. * @brief Copies the elements of a Q31 vector.
  2097. * @param[in] pSrc input pointer
  2098. * @param[out] pDst output pointer
  2099. * @param[in] blockSize number of samples to process
  2100. */
  2101. void arm_copy_q31(q31_t * pSrc, q31_t * pDst, uint32_t blockSize);
  2102. /**
  2103. * @brief Fills a constant value into a floating-point vector.
  2104. * @param[in] value input value to be filled
  2105. * @param[out] pDst output pointer
  2106. * @param[in] blockSize number of samples to process
  2107. */
  2108. void arm_fill_f32(float32_t value, float32_t * pDst, uint32_t blockSize);
  2109. /**
  2110. * @brief Fills a constant value into a Q7 vector.
  2111. * @param[in] value input value to be filled
  2112. * @param[out] pDst output pointer
  2113. * @param[in] blockSize number of samples to process
  2114. */
  2115. void arm_fill_q7(q7_t value, q7_t * pDst, uint32_t blockSize);
  2116. /**
  2117. * @brief Fills a constant value into a Q15 vector.
  2118. * @param[in] value input value to be filled
  2119. * @param[out] pDst output pointer
  2120. * @param[in] blockSize number of samples to process
  2121. */
  2122. void arm_fill_q15(q15_t value, q15_t * pDst, uint32_t blockSize);
  2123. /**
  2124. * @brief Fills a constant value into a Q31 vector.
  2125. * @param[in] value input value to be filled
  2126. * @param[out] pDst output pointer
  2127. * @param[in] blockSize number of samples to process
  2128. */
  2129. void arm_fill_q31(q31_t value, q31_t * pDst, uint32_t blockSize);
  2130. /**
  2131. * @brief Convolution of floating-point sequences.
  2132. * @param[in] pSrcA points to the first input sequence.
  2133. * @param[in] srcALen length of the first input sequence.
  2134. * @param[in] pSrcB points to the second input sequence.
  2135. * @param[in] srcBLen length of the second input sequence.
  2136. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2137. */
  2138. void arm_conv_f32(float32_t * pSrcA, uint32_t srcALen, float32_t * pSrcB,
  2139. uint32_t srcBLen, float32_t * pDst);
  2140. /**
  2141. * @brief Convolution of Q15 sequences.
  2142. * @param[in] pSrcA points to the first input sequence.
  2143. * @param[in] srcALen length of the first input sequence.
  2144. * @param[in] pSrcB points to the second input sequence.
  2145. * @param[in] srcBLen length of the second input sequence.
  2146. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2147. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2148. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2149. */
  2150. void arm_conv_opt_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  2151. uint32_t srcBLen, q15_t * pDst, q15_t * pScratch1, q15_t * pScratch2);
  2152. /**
  2153. * @brief Convolution of Q15 sequences.
  2154. * @param[in] pSrcA points to the first input sequence.
  2155. * @param[in] srcALen length of the first input sequence.
  2156. * @param[in] pSrcB points to the second input sequence.
  2157. * @param[in] srcBLen length of the second input sequence.
  2158. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2159. */
  2160. void arm_conv_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  2161. uint32_t srcBLen, q15_t * pDst);
  2162. /**
  2163. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2164. * @param[in] pSrcA points to the first input sequence.
  2165. * @param[in] srcALen length of the first input sequence.
  2166. * @param[in] pSrcB points to the second input sequence.
  2167. * @param[in] srcBLen length of the second input sequence.
  2168. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2169. */
  2170. void arm_conv_fast_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  2171. uint32_t srcBLen, q15_t * pDst);
  2172. /**
  2173. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2174. * @param[in] pSrcA points to the first input sequence.
  2175. * @param[in] srcALen length of the first input sequence.
  2176. * @param[in] pSrcB points to the second input sequence.
  2177. * @param[in] srcBLen length of the second input sequence.
  2178. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2179. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2180. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2181. */
  2182. void arm_conv_fast_opt_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  2183. uint32_t srcBLen, q15_t * pDst, q15_t * pScratch1, q15_t * pScratch2);
  2184. /**
  2185. * @brief Convolution of Q31 sequences.
  2186. * @param[in] pSrcA points to the first input sequence.
  2187. * @param[in] srcALen length of the first input sequence.
  2188. * @param[in] pSrcB points to the second input sequence.
  2189. * @param[in] srcBLen length of the second input sequence.
  2190. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2191. */
  2192. void arm_conv_q31(q31_t * pSrcA, uint32_t srcALen, q31_t * pSrcB,
  2193. uint32_t srcBLen, q31_t * pDst);
  2194. /**
  2195. * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2196. * @param[in] pSrcA points to the first input sequence.
  2197. * @param[in] srcALen length of the first input sequence.
  2198. * @param[in] pSrcB points to the second input sequence.
  2199. * @param[in] srcBLen length of the second input sequence.
  2200. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2201. */
  2202. void arm_conv_fast_q31(q31_t * pSrcA, uint32_t srcALen, q31_t * pSrcB,
  2203. uint32_t srcBLen, q31_t * pDst);
  2204. /**
  2205. * @brief Convolution of Q7 sequences.
  2206. * @param[in] pSrcA points to the first input sequence.
  2207. * @param[in] srcALen length of the first input sequence.
  2208. * @param[in] pSrcB points to the second input sequence.
  2209. * @param[in] srcBLen length of the second input sequence.
  2210. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2211. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2212. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2213. */
  2214. void arm_conv_opt_q7(q7_t * pSrcA, uint32_t srcALen, q7_t * pSrcB,
  2215. uint32_t srcBLen, q7_t * pDst, q15_t * pScratch1, q15_t * pScratch2);
  2216. /**
  2217. * @brief Convolution of Q7 sequences.
  2218. * @param[in] pSrcA points to the first input sequence.
  2219. * @param[in] srcALen length of the first input sequence.
  2220. * @param[in] pSrcB points to the second input sequence.
  2221. * @param[in] srcBLen length of the second input sequence.
  2222. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  2223. */
  2224. void arm_conv_q7(q7_t * pSrcA, uint32_t srcALen, q7_t * pSrcB, uint32_t srcBLen,
  2225. q7_t * pDst);
  2226. /**
  2227. * @brief Partial convolution of floating-point sequences.
  2228. * @param[in] pSrcA points to the first input sequence.
  2229. * @param[in] srcALen length of the first input sequence.
  2230. * @param[in] pSrcB points to the second input sequence.
  2231. * @param[in] srcBLen length of the second input sequence.
  2232. * @param[out] pDst points to the block of output data
  2233. * @param[in] firstIndex is the first output sample to start with.
  2234. * @param[in] numPoints is the number of output points to be computed.
  2235. * @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].
  2236. */
  2237. arm_status arm_conv_partial_f32(float32_t * pSrcA, uint32_t srcALen,
  2238. float32_t * pSrcB, uint32_t srcBLen, float32_t * pDst,
  2239. uint32_t firstIndex, uint32_t numPoints);
  2240. /**
  2241. * @brief Partial convolution of Q15 sequences.
  2242. * @param[in] pSrcA points to the first input sequence.
  2243. * @param[in] srcALen length of the first input sequence.
  2244. * @param[in] pSrcB points to the second input sequence.
  2245. * @param[in] srcBLen length of the second input sequence.
  2246. * @param[out] pDst points to the block of output data
  2247. * @param[in] firstIndex is the first output sample to start with.
  2248. * @param[in] numPoints is the number of output points to be computed.
  2249. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2250. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2251. * @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].
  2252. */
  2253. arm_status arm_conv_partial_opt_q15(q15_t * pSrcA, uint32_t srcALen,
  2254. q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex,
  2255. uint32_t numPoints, q15_t * pScratch1, q15_t * pScratch2);
  2256. /**
  2257. * @brief Partial convolution of Q15 sequences.
  2258. * @param[in] pSrcA points to the first input sequence.
  2259. * @param[in] srcALen length of the first input sequence.
  2260. * @param[in] pSrcB points to the second input sequence.
  2261. * @param[in] srcBLen length of the second input sequence.
  2262. * @param[out] pDst points to the block of output data
  2263. * @param[in] firstIndex is the first output sample to start with.
  2264. * @param[in] numPoints is the number of output points to be computed.
  2265. * @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].
  2266. */
  2267. arm_status arm_conv_partial_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  2268. uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex, uint32_t numPoints);
  2269. /**
  2270. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2271. * @param[in] pSrcA points to the first input sequence.
  2272. * @param[in] srcALen length of the first input sequence.
  2273. * @param[in] pSrcB points to the second input sequence.
  2274. * @param[in] srcBLen length of the second input sequence.
  2275. * @param[out] pDst points to the block of output data
  2276. * @param[in] firstIndex is the first output sample to start with.
  2277. * @param[in] numPoints is the number of output points to be computed.
  2278. * @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].
  2279. */
  2280. arm_status arm_conv_partial_fast_q15(q15_t * pSrcA, uint32_t srcALen,
  2281. q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex,
  2282. uint32_t numPoints);
  2283. /**
  2284. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2285. * @param[in] pSrcA points to the first input sequence.
  2286. * @param[in] srcALen length of the first input sequence.
  2287. * @param[in] pSrcB points to the second input sequence.
  2288. * @param[in] srcBLen length of the second input sequence.
  2289. * @param[out] pDst points to the block of output data
  2290. * @param[in] firstIndex is the first output sample to start with.
  2291. * @param[in] numPoints is the number of output points to be computed.
  2292. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2293. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2294. * @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].
  2295. */
  2296. arm_status arm_conv_partial_fast_opt_q15(q15_t * pSrcA, uint32_t srcALen,
  2297. q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex,
  2298. uint32_t numPoints, q15_t * pScratch1, q15_t * pScratch2);
  2299. /**
  2300. * @brief Partial convolution of Q31 sequences.
  2301. * @param[in] pSrcA points to the first input sequence.
  2302. * @param[in] srcALen length of the first input sequence.
  2303. * @param[in] pSrcB points to the second input sequence.
  2304. * @param[in] srcBLen length of the second input sequence.
  2305. * @param[out] pDst points to the block of output data
  2306. * @param[in] firstIndex is the first output sample to start with.
  2307. * @param[in] numPoints is the number of output points to be computed.
  2308. * @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].
  2309. */
  2310. arm_status arm_conv_partial_q31(q31_t * pSrcA, uint32_t srcALen, q31_t * pSrcB,
  2311. uint32_t srcBLen, q31_t * pDst, uint32_t firstIndex, uint32_t numPoints);
  2312. /**
  2313. * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2314. * @param[in] pSrcA points to the first input sequence.
  2315. * @param[in] srcALen length of the first input sequence.
  2316. * @param[in] pSrcB points to the second input sequence.
  2317. * @param[in] srcBLen length of the second input sequence.
  2318. * @param[out] pDst points to the block of output data
  2319. * @param[in] firstIndex is the first output sample to start with.
  2320. * @param[in] numPoints is the number of output points to be computed.
  2321. * @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].
  2322. */
  2323. arm_status arm_conv_partial_fast_q31(q31_t * pSrcA, uint32_t srcALen,
  2324. q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst, uint32_t firstIndex,
  2325. uint32_t numPoints);
  2326. /**
  2327. * @brief Partial convolution of Q7 sequences
  2328. * @param[in] pSrcA points to the first input sequence.
  2329. * @param[in] srcALen length of the first input sequence.
  2330. * @param[in] pSrcB points to the second input sequence.
  2331. * @param[in] srcBLen length of the second input sequence.
  2332. * @param[out] pDst points to the block of output data
  2333. * @param[in] firstIndex is the first output sample to start with.
  2334. * @param[in] numPoints is the number of output points to be computed.
  2335. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2336. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2337. * @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].
  2338. */
  2339. arm_status arm_conv_partial_opt_q7(q7_t * pSrcA, uint32_t srcALen, q7_t * pSrcB,
  2340. uint32_t srcBLen, q7_t * pDst, uint32_t firstIndex, uint32_t numPoints,
  2341. q15_t * pScratch1, q15_t * pScratch2);
  2342. /**
  2343. * @brief Partial convolution of Q7 sequences.
  2344. * @param[in] pSrcA points to the first input sequence.
  2345. * @param[in] srcALen length of the first input sequence.
  2346. * @param[in] pSrcB points to the second input sequence.
  2347. * @param[in] srcBLen length of the second input sequence.
  2348. * @param[out] pDst points to the block of output data
  2349. * @param[in] firstIndex is the first output sample to start with.
  2350. * @param[in] numPoints is the number of output points to be computed.
  2351. * @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].
  2352. */
  2353. arm_status arm_conv_partial_q7(q7_t * pSrcA, uint32_t srcALen, q7_t * pSrcB,
  2354. uint32_t srcBLen, q7_t * pDst, uint32_t firstIndex, uint32_t numPoints);
  2355. /**
  2356. * @brief Instance structure for the Q15 FIR decimator.
  2357. */
  2358. typedef struct {
  2359. uint8_t M; /**< decimation factor. */
  2360. uint16_t numTaps; /**< number of coefficients in the filter. */
  2361. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2362. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2363. } arm_fir_decimate_instance_q15;
  2364. /**
  2365. * @brief Instance structure for the Q31 FIR decimator.
  2366. */
  2367. typedef struct {
  2368. uint8_t M; /**< decimation factor. */
  2369. uint16_t numTaps; /**< number of coefficients in the filter. */
  2370. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2371. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2372. } arm_fir_decimate_instance_q31;
  2373. /**
  2374. * @brief Instance structure for the floating-point FIR decimator.
  2375. */
  2376. typedef struct {
  2377. uint8_t M; /**< decimation factor. */
  2378. uint16_t numTaps; /**< number of coefficients in the filter. */
  2379. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2380. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2381. } arm_fir_decimate_instance_f32;
  2382. /**
  2383. * @brief Processing function for the floating-point FIR decimator.
  2384. * @param[in] S points to an instance of the floating-point FIR decimator structure.
  2385. * @param[in] pSrc points to the block of input data.
  2386. * @param[out] pDst points to the block of output data
  2387. * @param[in] blockSize number of input samples to process per call.
  2388. */
  2389. void arm_fir_decimate_f32(const arm_fir_decimate_instance_f32 * S,
  2390. float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  2391. /**
  2392. * @brief Initialization function for the floating-point FIR decimator.
  2393. * @param[in,out] S points to an instance of the floating-point FIR decimator structure.
  2394. * @param[in] numTaps number of coefficients in the filter.
  2395. * @param[in] M decimation factor.
  2396. * @param[in] pCoeffs points to the filter coefficients.
  2397. * @param[in] pState points to the state buffer.
  2398. * @param[in] blockSize number of input samples to process per call.
  2399. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2400. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2401. */
  2402. arm_status arm_fir_decimate_init_f32(arm_fir_decimate_instance_f32 * S,
  2403. uint16_t numTaps, uint8_t M, float32_t * pCoeffs, float32_t * pState,
  2404. uint32_t blockSize);
  2405. /**
  2406. * @brief Processing function for the Q15 FIR decimator.
  2407. * @param[in] S points to an instance of the Q15 FIR decimator structure.
  2408. * @param[in] pSrc points to the block of input data.
  2409. * @param[out] pDst points to the block of output data
  2410. * @param[in] blockSize number of input samples to process per call.
  2411. */
  2412. void arm_fir_decimate_q15(const arm_fir_decimate_instance_q15 * S, q15_t * pSrc,
  2413. q15_t * pDst, uint32_t blockSize);
  2414. /**
  2415. * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  2416. * @param[in] S points to an instance of the Q15 FIR decimator structure.
  2417. * @param[in] pSrc points to the block of input data.
  2418. * @param[out] pDst points to the block of output data
  2419. * @param[in] blockSize number of input samples to process per call.
  2420. */
  2421. void arm_fir_decimate_fast_q15(const arm_fir_decimate_instance_q15 * S,
  2422. q15_t * pSrc, q15_t * pDst, uint32_t blockSize);
  2423. /**
  2424. * @brief Initialization function for the Q15 FIR decimator.
  2425. * @param[in,out] S points to an instance of the Q15 FIR decimator structure.
  2426. * @param[in] numTaps number of coefficients in the filter.
  2427. * @param[in] M decimation factor.
  2428. * @param[in] pCoeffs points to the filter coefficients.
  2429. * @param[in] pState points to the state buffer.
  2430. * @param[in] blockSize number of input samples to process per call.
  2431. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2432. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2433. */
  2434. arm_status arm_fir_decimate_init_q15(arm_fir_decimate_instance_q15 * S,
  2435. uint16_t numTaps, uint8_t M, q15_t * pCoeffs, q15_t * pState,
  2436. uint32_t blockSize);
  2437. /**
  2438. * @brief Processing function for the Q31 FIR decimator.
  2439. * @param[in] S points to an instance of the Q31 FIR decimator structure.
  2440. * @param[in] pSrc points to the block of input data.
  2441. * @param[out] pDst points to the block of output data
  2442. * @param[in] blockSize number of input samples to process per call.
  2443. */
  2444. void arm_fir_decimate_q31(const arm_fir_decimate_instance_q31 * S, q31_t * pSrc,
  2445. q31_t * pDst, uint32_t blockSize);
  2446. /**
  2447. * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  2448. * @param[in] S points to an instance of the Q31 FIR decimator structure.
  2449. * @param[in] pSrc points to the block of input data.
  2450. * @param[out] pDst points to the block of output data
  2451. * @param[in] blockSize number of input samples to process per call.
  2452. */
  2453. void arm_fir_decimate_fast_q31(arm_fir_decimate_instance_q31 * S, q31_t * pSrc,
  2454. q31_t * pDst, uint32_t blockSize);
  2455. /**
  2456. * @brief Initialization function for the Q31 FIR decimator.
  2457. * @param[in,out] S points to an instance of the Q31 FIR decimator structure.
  2458. * @param[in] numTaps number of coefficients in the filter.
  2459. * @param[in] M decimation factor.
  2460. * @param[in] pCoeffs points to the filter coefficients.
  2461. * @param[in] pState points to the state buffer.
  2462. * @param[in] blockSize number of input samples to process per call.
  2463. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2464. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2465. */
  2466. arm_status arm_fir_decimate_init_q31(arm_fir_decimate_instance_q31 * S,
  2467. uint16_t numTaps, uint8_t M, q31_t * pCoeffs, q31_t * pState,
  2468. uint32_t blockSize);
  2469. /**
  2470. * @brief Instance structure for the Q15 FIR interpolator.
  2471. */
  2472. typedef struct {
  2473. uint8_t L; /**< upsample factor. */
  2474. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2475. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2476. q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  2477. } arm_fir_interpolate_instance_q15;
  2478. /**
  2479. * @brief Instance structure for the Q31 FIR interpolator.
  2480. */
  2481. typedef struct {
  2482. uint8_t L; /**< upsample factor. */
  2483. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2484. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2485. q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  2486. } arm_fir_interpolate_instance_q31;
  2487. /**
  2488. * @brief Instance structure for the floating-point FIR interpolator.
  2489. */
  2490. typedef struct {
  2491. uint8_t L; /**< upsample factor. */
  2492. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2493. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2494. float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
  2495. } arm_fir_interpolate_instance_f32;
  2496. /**
  2497. * @brief Processing function for the Q15 FIR interpolator.
  2498. * @param[in] S points to an instance of the Q15 FIR interpolator structure.
  2499. * @param[in] pSrc points to the block of input data.
  2500. * @param[out] pDst points to the block of output data.
  2501. * @param[in] blockSize number of input samples to process per call.
  2502. */
  2503. void arm_fir_interpolate_q15(const arm_fir_interpolate_instance_q15 * S,
  2504. q15_t * pSrc, q15_t * pDst, uint32_t blockSize);
  2505. /**
  2506. * @brief Initialization function for the Q15 FIR interpolator.
  2507. * @param[in,out] S points to an instance of the Q15 FIR interpolator structure.
  2508. * @param[in] L upsample factor.
  2509. * @param[in] numTaps number of filter coefficients in the filter.
  2510. * @param[in] pCoeffs points to the filter coefficient buffer.
  2511. * @param[in] pState points to the state buffer.
  2512. * @param[in] blockSize number of input samples to process per call.
  2513. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2514. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  2515. */
  2516. arm_status arm_fir_interpolate_init_q15(arm_fir_interpolate_instance_q15 * S,
  2517. uint8_t L, uint16_t numTaps, q15_t * pCoeffs, q15_t * pState,
  2518. uint32_t blockSize);
  2519. /**
  2520. * @brief Processing function for the Q31 FIR interpolator.
  2521. * @param[in] S points to an instance of the Q15 FIR interpolator structure.
  2522. * @param[in] pSrc points to the block of input data.
  2523. * @param[out] pDst points to the block of output data.
  2524. * @param[in] blockSize number of input samples to process per call.
  2525. */
  2526. void arm_fir_interpolate_q31(const arm_fir_interpolate_instance_q31 * S,
  2527. q31_t * pSrc, q31_t * pDst, uint32_t blockSize);
  2528. /**
  2529. * @brief Initialization function for the Q31 FIR interpolator.
  2530. * @param[in,out] S points to an instance of the Q31 FIR interpolator structure.
  2531. * @param[in] L upsample factor.
  2532. * @param[in] numTaps number of filter coefficients in the filter.
  2533. * @param[in] pCoeffs points to the filter coefficient buffer.
  2534. * @param[in] pState points to the state buffer.
  2535. * @param[in] blockSize number of input samples to process per call.
  2536. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2537. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  2538. */
  2539. arm_status arm_fir_interpolate_init_q31(arm_fir_interpolate_instance_q31 * S,
  2540. uint8_t L, uint16_t numTaps, q31_t * pCoeffs, q31_t * pState,
  2541. uint32_t blockSize);
  2542. /**
  2543. * @brief Processing function for the floating-point FIR interpolator.
  2544. * @param[in] S points to an instance of the floating-point FIR interpolator structure.
  2545. * @param[in] pSrc points to the block of input data.
  2546. * @param[out] pDst points to the block of output data.
  2547. * @param[in] blockSize number of input samples to process per call.
  2548. */
  2549. void arm_fir_interpolate_f32(const arm_fir_interpolate_instance_f32 * S,
  2550. float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  2551. /**
  2552. * @brief Initialization function for the floating-point FIR interpolator.
  2553. * @param[in,out] S points to an instance of the floating-point FIR interpolator structure.
  2554. * @param[in] L upsample factor.
  2555. * @param[in] numTaps number of filter coefficients in the filter.
  2556. * @param[in] pCoeffs points to the filter coefficient buffer.
  2557. * @param[in] pState points to the state buffer.
  2558. * @param[in] blockSize number of input samples to process per call.
  2559. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2560. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  2561. */
  2562. arm_status arm_fir_interpolate_init_f32(arm_fir_interpolate_instance_f32 * S,
  2563. uint8_t L, uint16_t numTaps, float32_t * pCoeffs, float32_t * pState,
  2564. uint32_t blockSize);
  2565. /**
  2566. * @brief Instance structure for the high precision Q31 Biquad cascade filter.
  2567. */
  2568. typedef struct {
  2569. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  2570. q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  2571. q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  2572. uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
  2573. } arm_biquad_cas_df1_32x64_ins_q31;
  2574. /**
  2575. * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure.
  2576. * @param[in] pSrc points to the block of input data.
  2577. * @param[out] pDst points to the block of output data
  2578. * @param[in] blockSize number of samples to process.
  2579. */
  2580. void arm_biquad_cas_df1_32x64_q31(const arm_biquad_cas_df1_32x64_ins_q31 * S,
  2581. q31_t * pSrc, q31_t * pDst, uint32_t blockSize);
  2582. /**
  2583. * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure.
  2584. * @param[in] numStages number of 2nd order stages in the filter.
  2585. * @param[in] pCoeffs points to the filter coefficients.
  2586. * @param[in] pState points to the state buffer.
  2587. * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
  2588. */
  2589. void arm_biquad_cas_df1_32x64_init_q31(arm_biquad_cas_df1_32x64_ins_q31 * S,
  2590. uint8_t numStages, q31_t * pCoeffs, q63_t * pState, uint8_t postShift);
  2591. /**
  2592. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  2593. */
  2594. typedef struct {
  2595. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  2596. float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  2597. float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  2598. } arm_biquad_cascade_df2T_instance_f32;
  2599. /**
  2600. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  2601. */
  2602. typedef struct {
  2603. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  2604. float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  2605. float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  2606. } arm_biquad_cascade_stereo_df2T_instance_f32;
  2607. /**
  2608. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  2609. */
  2610. typedef struct {
  2611. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  2612. float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  2613. float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  2614. } arm_biquad_cascade_df2T_instance_f64;
  2615. /**
  2616. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  2617. * @param[in] S points to an instance of the filter data structure.
  2618. * @param[in] pSrc points to the block of input data.
  2619. * @param[out] pDst points to the block of output data
  2620. * @param[in] blockSize number of samples to process.
  2621. */
  2622. void arm_biquad_cascade_df2T_f32(const arm_biquad_cascade_df2T_instance_f32 * S,
  2623. float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  2624. /**
  2625. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
  2626. * @param[in] S points to an instance of the filter data structure.
  2627. * @param[in] pSrc points to the block of input data.
  2628. * @param[out] pDst points to the block of output data
  2629. * @param[in] blockSize number of samples to process.
  2630. */
  2631. void arm_biquad_cascade_stereo_df2T_f32(
  2632. const arm_biquad_cascade_stereo_df2T_instance_f32 * S, float32_t * pSrc,
  2633. float32_t * pDst, uint32_t blockSize);
  2634. /**
  2635. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  2636. * @param[in] S points to an instance of the filter data structure.
  2637. * @param[in] pSrc points to the block of input data.
  2638. * @param[out] pDst points to the block of output data
  2639. * @param[in] blockSize number of samples to process.
  2640. */
  2641. void arm_biquad_cascade_df2T_f64(const arm_biquad_cascade_df2T_instance_f64 * S,
  2642. float64_t * pSrc, float64_t * pDst, uint32_t blockSize);
  2643. /**
  2644. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  2645. * @param[in,out] S points to an instance of the filter data structure.
  2646. * @param[in] numStages number of 2nd order stages in the filter.
  2647. * @param[in] pCoeffs points to the filter coefficients.
  2648. * @param[in] pState points to the state buffer.
  2649. */
  2650. void arm_biquad_cascade_df2T_init_f32(arm_biquad_cascade_df2T_instance_f32 * S,
  2651. uint8_t numStages, float32_t * pCoeffs, float32_t * pState);
  2652. /**
  2653. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  2654. * @param[in,out] S points to an instance of the filter data structure.
  2655. * @param[in] numStages number of 2nd order stages in the filter.
  2656. * @param[in] pCoeffs points to the filter coefficients.
  2657. * @param[in] pState points to the state buffer.
  2658. */
  2659. void arm_biquad_cascade_stereo_df2T_init_f32(
  2660. arm_biquad_cascade_stereo_df2T_instance_f32 * S, uint8_t numStages,
  2661. float32_t * pCoeffs, float32_t * pState);
  2662. /**
  2663. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  2664. * @param[in,out] S points to an instance of the filter data structure.
  2665. * @param[in] numStages number of 2nd order stages in the filter.
  2666. * @param[in] pCoeffs points to the filter coefficients.
  2667. * @param[in] pState points to the state buffer.
  2668. */
  2669. void arm_biquad_cascade_df2T_init_f64(arm_biquad_cascade_df2T_instance_f64 * S,
  2670. uint8_t numStages, float64_t * pCoeffs, float64_t * pState);
  2671. /**
  2672. * @brief Instance structure for the Q15 FIR lattice filter.
  2673. */
  2674. typedef struct {
  2675. uint16_t numStages; /**< number of filter stages. */
  2676. q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
  2677. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  2678. } arm_fir_lattice_instance_q15;
  2679. /**
  2680. * @brief Instance structure for the Q31 FIR lattice filter.
  2681. */
  2682. typedef struct {
  2683. uint16_t numStages; /**< number of filter stages. */
  2684. q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
  2685. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  2686. } arm_fir_lattice_instance_q31;
  2687. /**
  2688. * @brief Instance structure for the floating-point FIR lattice filter.
  2689. */
  2690. typedef struct {
  2691. uint16_t numStages; /**< number of filter stages. */
  2692. float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
  2693. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  2694. } arm_fir_lattice_instance_f32;
  2695. /**
  2696. * @brief Initialization function for the Q15 FIR lattice filter.
  2697. * @param[in] S points to an instance of the Q15 FIR lattice structure.
  2698. * @param[in] numStages number of filter stages.
  2699. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  2700. * @param[in] pState points to the state buffer. The array is of length numStages.
  2701. */
  2702. void arm_fir_lattice_init_q15(arm_fir_lattice_instance_q15 * S,
  2703. uint16_t numStages, q15_t * pCoeffs, q15_t * pState);
  2704. /**
  2705. * @brief Processing function for the Q15 FIR lattice filter.
  2706. * @param[in] S points to an instance of the Q15 FIR lattice structure.
  2707. * @param[in] pSrc points to the block of input data.
  2708. * @param[out] pDst points to the block of output data.
  2709. * @param[in] blockSize number of samples to process.
  2710. */
  2711. void arm_fir_lattice_q15(const arm_fir_lattice_instance_q15 * S, q15_t * pSrc,
  2712. q15_t * pDst, uint32_t blockSize);
  2713. /**
  2714. * @brief Initialization function for the Q31 FIR lattice filter.
  2715. * @param[in] S points to an instance of the Q31 FIR lattice structure.
  2716. * @param[in] numStages number of filter stages.
  2717. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  2718. * @param[in] pState points to the state buffer. The array is of length numStages.
  2719. */
  2720. void arm_fir_lattice_init_q31(arm_fir_lattice_instance_q31 * S,
  2721. uint16_t numStages, q31_t * pCoeffs, q31_t * pState);
  2722. /**
  2723. * @brief Processing function for the Q31 FIR lattice filter.
  2724. * @param[in] S points to an instance of the Q31 FIR lattice structure.
  2725. * @param[in] pSrc points to the block of input data.
  2726. * @param[out] pDst points to the block of output data
  2727. * @param[in] blockSize number of samples to process.
  2728. */
  2729. void arm_fir_lattice_q31(const arm_fir_lattice_instance_q31 * S, q31_t * pSrc,
  2730. q31_t * pDst, uint32_t blockSize);
  2731. /**
  2732. * @brief Initialization function for the floating-point FIR lattice filter.
  2733. * @param[in] S points to an instance of the floating-point FIR lattice structure.
  2734. * @param[in] numStages number of filter stages.
  2735. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  2736. * @param[in] pState points to the state buffer. The array is of length numStages.
  2737. */
  2738. void arm_fir_lattice_init_f32(arm_fir_lattice_instance_f32 * S,
  2739. uint16_t numStages, float32_t * pCoeffs, float32_t * pState);
  2740. /**
  2741. * @brief Processing function for the floating-point FIR lattice filter.
  2742. * @param[in] S points to an instance of the floating-point FIR lattice structure.
  2743. * @param[in] pSrc points to the block of input data.
  2744. * @param[out] pDst points to the block of output data
  2745. * @param[in] blockSize number of samples to process.
  2746. */
  2747. void arm_fir_lattice_f32(const arm_fir_lattice_instance_f32 * S,
  2748. float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  2749. /**
  2750. * @brief Instance structure for the Q15 IIR lattice filter.
  2751. */
  2752. typedef struct {
  2753. uint16_t numStages; /**< number of stages in the filter. */
  2754. q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  2755. q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  2756. q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  2757. } arm_iir_lattice_instance_q15;
  2758. /**
  2759. * @brief Instance structure for the Q31 IIR lattice filter.
  2760. */
  2761. typedef struct {
  2762. uint16_t numStages; /**< number of stages in the filter. */
  2763. q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  2764. q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  2765. q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  2766. } arm_iir_lattice_instance_q31;
  2767. /**
  2768. * @brief Instance structure for the floating-point IIR lattice filter.
  2769. */
  2770. typedef struct {
  2771. uint16_t numStages; /**< number of stages in the filter. */
  2772. float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  2773. float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  2774. float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  2775. } arm_iir_lattice_instance_f32;
  2776. /**
  2777. * @brief Processing function for the floating-point IIR lattice filter.
  2778. * @param[in] S points to an instance of the floating-point IIR lattice structure.
  2779. * @param[in] pSrc points to the block of input data.
  2780. * @param[out] pDst points to the block of output data.
  2781. * @param[in] blockSize number of samples to process.
  2782. */
  2783. void arm_iir_lattice_f32(const arm_iir_lattice_instance_f32 * S,
  2784. float32_t * pSrc, float32_t * pDst, uint32_t blockSize);
  2785. /**
  2786. * @brief Initialization function for the floating-point IIR lattice filter.
  2787. * @param[in] S points to an instance of the floating-point IIR lattice structure.
  2788. * @param[in] numStages number of stages in the filter.
  2789. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  2790. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  2791. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1.
  2792. * @param[in] blockSize number of samples to process.
  2793. */
  2794. void arm_iir_lattice_init_f32(arm_iir_lattice_instance_f32 * S,
  2795. uint16_t numStages, float32_t * pkCoeffs, float32_t * pvCoeffs,
  2796. float32_t * pState, uint32_t blockSize);
  2797. /**
  2798. * @brief Processing function for the Q31 IIR lattice filter.
  2799. * @param[in] S points to an instance of the Q31 IIR lattice structure.
  2800. * @param[in] pSrc points to the block of input data.
  2801. * @param[out] pDst points to the block of output data.
  2802. * @param[in] blockSize number of samples to process.
  2803. */
  2804. void arm_iir_lattice_q31(const arm_iir_lattice_instance_q31 * S, q31_t * pSrc,
  2805. q31_t * pDst, uint32_t blockSize);
  2806. /**
  2807. * @brief Initialization function for the Q31 IIR lattice filter.
  2808. * @param[in] S points to an instance of the Q31 IIR lattice structure.
  2809. * @param[in] numStages number of stages in the filter.
  2810. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  2811. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  2812. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize.
  2813. * @param[in] blockSize number of samples to process.
  2814. */
  2815. void arm_iir_lattice_init_q31(arm_iir_lattice_instance_q31 * S,
  2816. uint16_t numStages, q31_t * pkCoeffs, q31_t * pvCoeffs, q31_t * pState,
  2817. uint32_t blockSize);
  2818. /**
  2819. * @brief Processing function for the Q15 IIR lattice filter.
  2820. * @param[in] S points to an instance of the Q15 IIR lattice structure.
  2821. * @param[in] pSrc points to the block of input data.
  2822. * @param[out] pDst points to the block of output data.
  2823. * @param[in] blockSize number of samples to process.
  2824. */
  2825. void arm_iir_lattice_q15(const arm_iir_lattice_instance_q15 * S, q15_t * pSrc,
  2826. q15_t * pDst, uint32_t blockSize);
  2827. /**
  2828. * @brief Initialization function for the Q15 IIR lattice filter.
  2829. * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure.
  2830. * @param[in] numStages number of stages in the filter.
  2831. * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
  2832. * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
  2833. * @param[in] pState points to state buffer. The array is of length numStages+blockSize.
  2834. * @param[in] blockSize number of samples to process per call.
  2835. */
  2836. void arm_iir_lattice_init_q15(arm_iir_lattice_instance_q15 * S,
  2837. uint16_t numStages, q15_t * pkCoeffs, q15_t * pvCoeffs, q15_t * pState,
  2838. uint32_t blockSize);
  2839. /**
  2840. * @brief Instance structure for the floating-point LMS filter.
  2841. */
  2842. typedef struct {
  2843. uint16_t numTaps; /**< number of coefficients in the filter. */
  2844. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2845. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  2846. float32_t mu; /**< step size that controls filter coefficient updates. */
  2847. } arm_lms_instance_f32;
  2848. /**
  2849. * @brief Processing function for floating-point LMS filter.
  2850. * @param[in] S points to an instance of the floating-point LMS filter structure.
  2851. * @param[in] pSrc points to the block of input data.
  2852. * @param[in] pRef points to the block of reference data.
  2853. * @param[out] pOut points to the block of output data.
  2854. * @param[out] pErr points to the block of error data.
  2855. * @param[in] blockSize number of samples to process.
  2856. */
  2857. void arm_lms_f32(const arm_lms_instance_f32 * S, float32_t * pSrc,
  2858. float32_t * pRef, float32_t * pOut, float32_t * pErr,
  2859. uint32_t blockSize);
  2860. /**
  2861. * @brief Initialization function for floating-point LMS filter.
  2862. * @param[in] S points to an instance of the floating-point LMS filter structure.
  2863. * @param[in] numTaps number of filter coefficients.
  2864. * @param[in] pCoeffs points to the coefficient buffer.
  2865. * @param[in] pState points to state buffer.
  2866. * @param[in] mu step size that controls filter coefficient updates.
  2867. * @param[in] blockSize number of samples to process.
  2868. */
  2869. void arm_lms_init_f32(arm_lms_instance_f32 * S, uint16_t numTaps,
  2870. float32_t * pCoeffs, float32_t * pState, float32_t mu,
  2871. uint32_t blockSize);
  2872. /**
  2873. * @brief Instance structure for the Q15 LMS filter.
  2874. */
  2875. typedef struct {
  2876. uint16_t numTaps; /**< number of coefficients in the filter. */
  2877. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2878. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  2879. q15_t mu; /**< step size that controls filter coefficient updates. */
  2880. uint32_t postShift; /**< bit shift applied to coefficients. */
  2881. } arm_lms_instance_q15;
  2882. /**
  2883. * @brief Initialization function for the Q15 LMS filter.
  2884. * @param[in] S points to an instance of the Q15 LMS filter structure.
  2885. * @param[in] numTaps number of filter coefficients.
  2886. * @param[in] pCoeffs points to the coefficient buffer.
  2887. * @param[in] pState points to the state buffer.
  2888. * @param[in] mu step size that controls filter coefficient updates.
  2889. * @param[in] blockSize number of samples to process.
  2890. * @param[in] postShift bit shift applied to coefficients.
  2891. */
  2892. void arm_lms_init_q15(arm_lms_instance_q15 * S, uint16_t numTaps,
  2893. q15_t * pCoeffs, q15_t * pState, q15_t mu, uint32_t blockSize,
  2894. uint32_t postShift);
  2895. /**
  2896. * @brief Processing function for Q15 LMS filter.
  2897. * @param[in] S points to an instance of the Q15 LMS filter structure.
  2898. * @param[in] pSrc points to the block of input data.
  2899. * @param[in] pRef points to the block of reference data.
  2900. * @param[out] pOut points to the block of output data.
  2901. * @param[out] pErr points to the block of error data.
  2902. * @param[in] blockSize number of samples to process.
  2903. */
  2904. void arm_lms_q15(const arm_lms_instance_q15 * S, q15_t * pSrc, q15_t * pRef,
  2905. q15_t * pOut, q15_t * pErr, uint32_t blockSize);
  2906. /**
  2907. * @brief Instance structure for the Q31 LMS filter.
  2908. */
  2909. typedef struct {
  2910. uint16_t numTaps; /**< number of coefficients in the filter. */
  2911. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2912. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  2913. q31_t mu; /**< step size that controls filter coefficient updates. */
  2914. uint32_t postShift; /**< bit shift applied to coefficients. */
  2915. } arm_lms_instance_q31;
  2916. /**
  2917. * @brief Processing function for Q31 LMS filter.
  2918. * @param[in] S points to an instance of the Q15 LMS filter structure.
  2919. * @param[in] pSrc points to the block of input data.
  2920. * @param[in] pRef points to the block of reference data.
  2921. * @param[out] pOut points to the block of output data.
  2922. * @param[out] pErr points to the block of error data.
  2923. * @param[in] blockSize number of samples to process.
  2924. */
  2925. void arm_lms_q31(const arm_lms_instance_q31 * S, q31_t * pSrc, q31_t * pRef,
  2926. q31_t * pOut, q31_t * pErr, uint32_t blockSize);
  2927. /**
  2928. * @brief Initialization function for Q31 LMS filter.
  2929. * @param[in] S points to an instance of the Q31 LMS filter structure.
  2930. * @param[in] numTaps number of filter coefficients.
  2931. * @param[in] pCoeffs points to coefficient buffer.
  2932. * @param[in] pState points to state buffer.
  2933. * @param[in] mu step size that controls filter coefficient updates.
  2934. * @param[in] blockSize number of samples to process.
  2935. * @param[in] postShift bit shift applied to coefficients.
  2936. */
  2937. void arm_lms_init_q31(arm_lms_instance_q31 * S, uint16_t numTaps,
  2938. q31_t * pCoeffs, q31_t * pState, q31_t mu, uint32_t blockSize,
  2939. uint32_t postShift);
  2940. /**
  2941. * @brief Instance structure for the floating-point normalized LMS filter.
  2942. */
  2943. typedef struct {
  2944. uint16_t numTaps; /**< number of coefficients in the filter. */
  2945. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2946. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  2947. float32_t mu; /**< step size that control filter coefficient updates. */
  2948. float32_t energy; /**< saves previous frame energy. */
  2949. float32_t x0; /**< saves previous input sample. */
  2950. } arm_lms_norm_instance_f32;
  2951. /**
  2952. * @brief Processing function for floating-point normalized LMS filter.
  2953. * @param[in] S points to an instance of the floating-point normalized LMS filter structure.
  2954. * @param[in] pSrc points to the block of input data.
  2955. * @param[in] pRef points to the block of reference data.
  2956. * @param[out] pOut points to the block of output data.
  2957. * @param[out] pErr points to the block of error data.
  2958. * @param[in] blockSize number of samples to process.
  2959. */
  2960. void arm_lms_norm_f32(arm_lms_norm_instance_f32 * S, float32_t * pSrc,
  2961. float32_t * pRef, float32_t * pOut, float32_t * pErr,
  2962. uint32_t blockSize);
  2963. /**
  2964. * @brief Initialization function for floating-point normalized LMS filter.
  2965. * @param[in] S points to an instance of the floating-point LMS filter structure.
  2966. * @param[in] numTaps number of filter coefficients.
  2967. * @param[in] pCoeffs points to coefficient buffer.
  2968. * @param[in] pState points to state buffer.
  2969. * @param[in] mu step size that controls filter coefficient updates.
  2970. * @param[in] blockSize number of samples to process.
  2971. */
  2972. void arm_lms_norm_init_f32(arm_lms_norm_instance_f32 * S, uint16_t numTaps,
  2973. float32_t * pCoeffs, float32_t * pState, float32_t mu,
  2974. uint32_t blockSize);
  2975. /**
  2976. * @brief Instance structure for the Q31 normalized LMS filter.
  2977. */
  2978. typedef struct {
  2979. uint16_t numTaps; /**< number of coefficients in the filter. */
  2980. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2981. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  2982. q31_t mu; /**< step size that controls filter coefficient updates. */
  2983. uint8_t postShift; /**< bit shift applied to coefficients. */
  2984. q31_t *recipTable; /**< points to the reciprocal initial value table. */
  2985. q31_t energy; /**< saves previous frame energy. */
  2986. q31_t x0; /**< saves previous input sample. */
  2987. } arm_lms_norm_instance_q31;
  2988. /**
  2989. * @brief Processing function for Q31 normalized LMS filter.
  2990. * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
  2991. * @param[in] pSrc points to the block of input data.
  2992. * @param[in] pRef points to the block of reference data.
  2993. * @param[out] pOut points to the block of output data.
  2994. * @param[out] pErr points to the block of error data.
  2995. * @param[in] blockSize number of samples to process.
  2996. */
  2997. void arm_lms_norm_q31(arm_lms_norm_instance_q31 * S, q31_t * pSrc, q31_t * pRef,
  2998. q31_t * pOut, q31_t * pErr, uint32_t blockSize);
  2999. /**
  3000. * @brief Initialization function for Q31 normalized LMS filter.
  3001. * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
  3002. * @param[in] numTaps number of filter coefficients.
  3003. * @param[in] pCoeffs points to coefficient buffer.
  3004. * @param[in] pState points to state buffer.
  3005. * @param[in] mu step size that controls filter coefficient updates.
  3006. * @param[in] blockSize number of samples to process.
  3007. * @param[in] postShift bit shift applied to coefficients.
  3008. */
  3009. void arm_lms_norm_init_q31(arm_lms_norm_instance_q31 * S, uint16_t numTaps,
  3010. q31_t * pCoeffs, q31_t * pState, q31_t mu, uint32_t blockSize,
  3011. uint8_t postShift);
  3012. /**
  3013. * @brief Instance structure for the Q15 normalized LMS filter.
  3014. */
  3015. typedef struct {
  3016. uint16_t numTaps; /**< Number of coefficients in the filter. */
  3017. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3018. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3019. q15_t mu; /**< step size that controls filter coefficient updates. */
  3020. uint8_t postShift; /**< bit shift applied to coefficients. */
  3021. q15_t *recipTable; /**< Points to the reciprocal initial value table. */
  3022. q15_t energy; /**< saves previous frame energy. */
  3023. q15_t x0; /**< saves previous input sample. */
  3024. } arm_lms_norm_instance_q15;
  3025. /**
  3026. * @brief Processing function for Q15 normalized LMS filter.
  3027. * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
  3028. * @param[in] pSrc points to the block of input data.
  3029. * @param[in] pRef points to the block of reference data.
  3030. * @param[out] pOut points to the block of output data.
  3031. * @param[out] pErr points to the block of error data.
  3032. * @param[in] blockSize number of samples to process.
  3033. */
  3034. void arm_lms_norm_q15(arm_lms_norm_instance_q15 * S, q15_t * pSrc, q15_t * pRef,
  3035. q15_t * pOut, q15_t * pErr, uint32_t blockSize);
  3036. /**
  3037. * @brief Initialization function for Q15 normalized LMS filter.
  3038. * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
  3039. * @param[in] numTaps number of filter coefficients.
  3040. * @param[in] pCoeffs points to coefficient buffer.
  3041. * @param[in] pState points to state buffer.
  3042. * @param[in] mu step size that controls filter coefficient updates.
  3043. * @param[in] blockSize number of samples to process.
  3044. * @param[in] postShift bit shift applied to coefficients.
  3045. */
  3046. void arm_lms_norm_init_q15(arm_lms_norm_instance_q15 * S, uint16_t numTaps,
  3047. q15_t * pCoeffs, q15_t * pState, q15_t mu, uint32_t blockSize,
  3048. uint8_t postShift);
  3049. /**
  3050. * @brief Correlation of floating-point sequences.
  3051. * @param[in] pSrcA points to the first input sequence.
  3052. * @param[in] srcALen length of the first input sequence.
  3053. * @param[in] pSrcB points to the second input sequence.
  3054. * @param[in] srcBLen length of the second input sequence.
  3055. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3056. */
  3057. void arm_correlate_f32(float32_t * pSrcA, uint32_t srcALen, float32_t * pSrcB,
  3058. uint32_t srcBLen, float32_t * pDst);
  3059. /**
  3060. * @brief Correlation of Q15 sequences
  3061. * @param[in] pSrcA points to the first input sequence.
  3062. * @param[in] srcALen length of the first input sequence.
  3063. * @param[in] pSrcB points to the second input sequence.
  3064. * @param[in] srcBLen length of the second input sequence.
  3065. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3066. * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3067. */
  3068. void arm_correlate_opt_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  3069. uint32_t srcBLen, q15_t * pDst, q15_t * pScratch);
  3070. /**
  3071. * @brief Correlation of Q15 sequences.
  3072. * @param[in] pSrcA points to the first input sequence.
  3073. * @param[in] srcALen length of the first input sequence.
  3074. * @param[in] pSrcB points to the second input sequence.
  3075. * @param[in] srcBLen length of the second input sequence.
  3076. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3077. */
  3078. void arm_correlate_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  3079. uint32_t srcBLen, q15_t * pDst);
  3080. /**
  3081. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3082. * @param[in] pSrcA points to the first input sequence.
  3083. * @param[in] srcALen length of the first input sequence.
  3084. * @param[in] pSrcB points to the second input sequence.
  3085. * @param[in] srcBLen length of the second input sequence.
  3086. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3087. */
  3088. void arm_correlate_fast_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  3089. uint32_t srcBLen, q15_t * pDst);
  3090. /**
  3091. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3092. * @param[in] pSrcA points to the first input sequence.
  3093. * @param[in] srcALen length of the first input sequence.
  3094. * @param[in] pSrcB points to the second input sequence.
  3095. * @param[in] srcBLen length of the second input sequence.
  3096. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3097. * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3098. */
  3099. void arm_correlate_fast_opt_q15(q15_t * pSrcA, uint32_t srcALen, q15_t * pSrcB,
  3100. uint32_t srcBLen, q15_t * pDst, q15_t * pScratch);
  3101. /**
  3102. * @brief Correlation of Q31 sequences.
  3103. * @param[in] pSrcA points to the first input sequence.
  3104. * @param[in] srcALen length of the first input sequence.
  3105. * @param[in] pSrcB points to the second input sequence.
  3106. * @param[in] srcBLen length of the second input sequence.
  3107. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3108. */
  3109. void arm_correlate_q31(q31_t * pSrcA, uint32_t srcALen, q31_t * pSrcB,
  3110. uint32_t srcBLen, q31_t * pDst);
  3111. /**
  3112. * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  3113. * @param[in] pSrcA points to the first input sequence.
  3114. * @param[in] srcALen length of the first input sequence.
  3115. * @param[in] pSrcB points to the second input sequence.
  3116. * @param[in] srcBLen length of the second input sequence.
  3117. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3118. */
  3119. void arm_correlate_fast_q31(q31_t * pSrcA, uint32_t srcALen, q31_t * pSrcB,
  3120. uint32_t srcBLen, q31_t * pDst);
  3121. /**
  3122. * @brief Correlation of Q7 sequences.
  3123. * @param[in] pSrcA points to the first input sequence.
  3124. * @param[in] srcALen length of the first input sequence.
  3125. * @param[in] pSrcB points to the second input sequence.
  3126. * @param[in] srcBLen length of the second input sequence.
  3127. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3128. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3129. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  3130. */
  3131. void arm_correlate_opt_q7(q7_t * pSrcA, uint32_t srcALen, q7_t * pSrcB,
  3132. uint32_t srcBLen, q7_t * pDst, q15_t * pScratch1, q15_t * pScratch2);
  3133. /**
  3134. * @brief Correlation of Q7 sequences.
  3135. * @param[in] pSrcA points to the first input sequence.
  3136. * @param[in] srcALen length of the first input sequence.
  3137. * @param[in] pSrcB points to the second input sequence.
  3138. * @param[in] srcBLen length of the second input sequence.
  3139. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3140. */
  3141. void arm_correlate_q7(q7_t * pSrcA, uint32_t srcALen, q7_t * pSrcB,
  3142. uint32_t srcBLen, q7_t * pDst);
  3143. /**
  3144. * @brief Instance structure for the floating-point sparse FIR filter.
  3145. */
  3146. typedef struct {
  3147. uint16_t numTaps; /**< number of coefficients in the filter. */
  3148. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3149. float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3150. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3151. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3152. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3153. } arm_fir_sparse_instance_f32;
  3154. /**
  3155. * @brief Instance structure for the Q31 sparse FIR filter.
  3156. */
  3157. typedef struct {
  3158. uint16_t numTaps; /**< number of coefficients in the filter. */
  3159. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3160. q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3161. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3162. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3163. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3164. } arm_fir_sparse_instance_q31;
  3165. /**
  3166. * @brief Instance structure for the Q15 sparse FIR filter.
  3167. */
  3168. typedef struct {
  3169. uint16_t numTaps; /**< number of coefficients in the filter. */
  3170. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3171. q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3172. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3173. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3174. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3175. } arm_fir_sparse_instance_q15;
  3176. /**
  3177. * @brief Instance structure for the Q7 sparse FIR filter.
  3178. */
  3179. typedef struct {
  3180. uint16_t numTaps; /**< number of coefficients in the filter. */
  3181. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3182. q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3183. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3184. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3185. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3186. } arm_fir_sparse_instance_q7;
  3187. /**
  3188. * @brief Processing function for the floating-point sparse FIR filter.
  3189. * @param[in] S points to an instance of the floating-point sparse FIR structure.
  3190. * @param[in] pSrc points to the block of input data.
  3191. * @param[out] pDst points to the block of output data
  3192. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3193. * @param[in] blockSize number of input samples to process per call.
  3194. */
  3195. void arm_fir_sparse_f32(arm_fir_sparse_instance_f32 * S, float32_t * pSrc,
  3196. float32_t * pDst, float32_t * pScratchIn, uint32_t blockSize);
  3197. /**
  3198. * @brief Initialization function for the floating-point sparse FIR filter.
  3199. * @param[in,out] S points to an instance of the floating-point sparse FIR structure.
  3200. * @param[in] numTaps number of nonzero coefficients in the filter.
  3201. * @param[in] pCoeffs points to the array of filter coefficients.
  3202. * @param[in] pState points to the state buffer.
  3203. * @param[in] pTapDelay points to the array of offset times.
  3204. * @param[in] maxDelay maximum offset time supported.
  3205. * @param[in] blockSize number of samples that will be processed per block.
  3206. */
  3207. void arm_fir_sparse_init_f32(arm_fir_sparse_instance_f32 * S, uint16_t numTaps,
  3208. float32_t * pCoeffs, float32_t * pState, int32_t * pTapDelay,
  3209. uint16_t maxDelay, uint32_t blockSize);
  3210. /**
  3211. * @brief Processing function for the Q31 sparse FIR filter.
  3212. * @param[in] S points to an instance of the Q31 sparse FIR structure.
  3213. * @param[in] pSrc points to the block of input data.
  3214. * @param[out] pDst points to the block of output data
  3215. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3216. * @param[in] blockSize number of input samples to process per call.
  3217. */
  3218. void arm_fir_sparse_q31(arm_fir_sparse_instance_q31 * S, q31_t * pSrc,
  3219. q31_t * pDst, q31_t * pScratchIn, uint32_t blockSize);
  3220. /**
  3221. * @brief Initialization function for the Q31 sparse FIR filter.
  3222. * @param[in,out] S points to an instance of the Q31 sparse FIR structure.
  3223. * @param[in] numTaps number of nonzero coefficients in the filter.
  3224. * @param[in] pCoeffs points to the array of filter coefficients.
  3225. * @param[in] pState points to the state buffer.
  3226. * @param[in] pTapDelay points to the array of offset times.
  3227. * @param[in] maxDelay maximum offset time supported.
  3228. * @param[in] blockSize number of samples that will be processed per block.
  3229. */
  3230. void arm_fir_sparse_init_q31(arm_fir_sparse_instance_q31 * S, uint16_t numTaps,
  3231. q31_t * pCoeffs, q31_t * pState, int32_t * pTapDelay, uint16_t maxDelay,
  3232. uint32_t blockSize);
  3233. /**
  3234. * @brief Processing function for the Q15 sparse FIR filter.
  3235. * @param[in] S points to an instance of the Q15 sparse FIR structure.
  3236. * @param[in] pSrc points to the block of input data.
  3237. * @param[out] pDst points to the block of output data
  3238. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3239. * @param[in] pScratchOut points to a temporary buffer of size blockSize.
  3240. * @param[in] blockSize number of input samples to process per call.
  3241. */
  3242. void arm_fir_sparse_q15(arm_fir_sparse_instance_q15 * S, q15_t * pSrc,
  3243. q15_t * pDst, q15_t * pScratchIn, q31_t * pScratchOut,
  3244. uint32_t blockSize);
  3245. /**
  3246. * @brief Initialization function for the Q15 sparse FIR filter.
  3247. * @param[in,out] S points to an instance of the Q15 sparse FIR structure.
  3248. * @param[in] numTaps number of nonzero coefficients in the filter.
  3249. * @param[in] pCoeffs points to the array of filter coefficients.
  3250. * @param[in] pState points to the state buffer.
  3251. * @param[in] pTapDelay points to the array of offset times.
  3252. * @param[in] maxDelay maximum offset time supported.
  3253. * @param[in] blockSize number of samples that will be processed per block.
  3254. */
  3255. void arm_fir_sparse_init_q15(arm_fir_sparse_instance_q15 * S, uint16_t numTaps,
  3256. q15_t * pCoeffs, q15_t * pState, int32_t * pTapDelay, uint16_t maxDelay,
  3257. uint32_t blockSize);
  3258. /**
  3259. * @brief Processing function for the Q7 sparse FIR filter.
  3260. * @param[in] S points to an instance of the Q7 sparse FIR structure.
  3261. * @param[in] pSrc points to the block of input data.
  3262. * @param[out] pDst points to the block of output data
  3263. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  3264. * @param[in] pScratchOut points to a temporary buffer of size blockSize.
  3265. * @param[in] blockSize number of input samples to process per call.
  3266. */
  3267. void arm_fir_sparse_q7(arm_fir_sparse_instance_q7 * S, q7_t * pSrc, q7_t * pDst,
  3268. q7_t * pScratchIn, q31_t * pScratchOut, uint32_t blockSize);
  3269. /**
  3270. * @brief Initialization function for the Q7 sparse FIR filter.
  3271. * @param[in,out] S points to an instance of the Q7 sparse FIR structure.
  3272. * @param[in] numTaps number of nonzero coefficients in the filter.
  3273. * @param[in] pCoeffs points to the array of filter coefficients.
  3274. * @param[in] pState points to the state buffer.
  3275. * @param[in] pTapDelay points to the array of offset times.
  3276. * @param[in] maxDelay maximum offset time supported.
  3277. * @param[in] blockSize number of samples that will be processed per block.
  3278. */
  3279. void arm_fir_sparse_init_q7(arm_fir_sparse_instance_q7 * S, uint16_t numTaps,
  3280. q7_t * pCoeffs, q7_t * pState, int32_t * pTapDelay, uint16_t maxDelay,
  3281. uint32_t blockSize);
  3282. /**
  3283. * @brief Floating-point sin_cos function.
  3284. * @param[in] theta input value in degrees
  3285. * @param[out] pSinVal points to the processed sine output.
  3286. * @param[out] pCosVal points to the processed cos output.
  3287. */
  3288. void arm_sin_cos_f32(float32_t theta, float32_t * pSinVal, float32_t * pCosVal);
  3289. /**
  3290. * @brief Q31 sin_cos function.
  3291. * @param[in] theta scaled input value in degrees
  3292. * @param[out] pSinVal points to the processed sine output.
  3293. * @param[out] pCosVal points to the processed cosine output.
  3294. */
  3295. void arm_sin_cos_q31(q31_t theta, q31_t * pSinVal, q31_t * pCosVal);
  3296. /**
  3297. * @brief Floating-point complex conjugate.
  3298. * @param[in] pSrc points to the input vector
  3299. * @param[out] pDst points to the output vector
  3300. * @param[in] numSamples number of complex samples in each vector
  3301. */
  3302. void arm_cmplx_conj_f32(float32_t * pSrc, float32_t * pDst, uint32_t numSamples);
  3303. /**
  3304. * @brief Q31 complex conjugate.
  3305. * @param[in] pSrc points to the input vector
  3306. * @param[out] pDst points to the output vector
  3307. * @param[in] numSamples number of complex samples in each vector
  3308. */
  3309. void arm_cmplx_conj_q31(q31_t * pSrc, q31_t * pDst, uint32_t numSamples);
  3310. /**
  3311. * @brief Q15 complex conjugate.
  3312. * @param[in] pSrc points to the input vector
  3313. * @param[out] pDst points to the output vector
  3314. * @param[in] numSamples number of complex samples in each vector
  3315. */
  3316. void arm_cmplx_conj_q15(q15_t * pSrc, q15_t * pDst, uint32_t numSamples);
  3317. /**
  3318. * @brief Floating-point complex magnitude squared
  3319. * @param[in] pSrc points to the complex input vector
  3320. * @param[out] pDst points to the real output vector
  3321. * @param[in] numSamples number of complex samples in the input vector
  3322. */
  3323. void arm_cmplx_mag_squared_f32(float32_t * pSrc, float32_t * pDst,
  3324. uint32_t numSamples);
  3325. /**
  3326. * @brief Q31 complex magnitude squared
  3327. * @param[in] pSrc points to the complex input vector
  3328. * @param[out] pDst points to the real output vector
  3329. * @param[in] numSamples number of complex samples in the input vector
  3330. */
  3331. void arm_cmplx_mag_squared_q31(q31_t * pSrc, q31_t * pDst, uint32_t numSamples);
  3332. /**
  3333. * @brief Q15 complex magnitude squared
  3334. * @param[in] pSrc points to the complex input vector
  3335. * @param[out] pDst points to the real output vector
  3336. * @param[in] numSamples number of complex samples in the input vector
  3337. */
  3338. void arm_cmplx_mag_squared_q15(q15_t * pSrc, q15_t * pDst, uint32_t numSamples);
  3339. /**
  3340. * @ingroup groupController
  3341. */
  3342. /**
  3343. * @defgroup PID PID Motor Control
  3344. *
  3345. * A Proportional Integral Derivative (PID) controller is a generic feedback control
  3346. * loop mechanism widely used in industrial control systems.
  3347. * A PID controller is the most commonly used type of feedback controller.
  3348. *
  3349. * This set of functions implements (PID) controllers
  3350. * for Q15, Q31, and floating-point data types. The functions operate on a single sample
  3351. * of data and each call to the function returns a single processed value.
  3352. * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
  3353. * is the input sample value. The functions return the output value.
  3354. *
  3355. * \par Algorithm:
  3356. * <pre>
  3357. * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
  3358. * A0 = Kp + Ki + Kd
  3359. * A1 = (-Kp ) - (2 * Kd )
  3360. * A2 = Kd </pre>
  3361. *
  3362. * \par
  3363. * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
  3364. *
  3365. * \par
  3366. * \image html PID.gif "Proportional Integral Derivative Controller"
  3367. *
  3368. * \par
  3369. * The PID controller calculates an "error" value as the difference between
  3370. * the measured output and the reference input.
  3371. * The controller attempts to minimize the error by adjusting the process control inputs.
  3372. * The proportional value determines the reaction to the current error,
  3373. * the integral value determines the reaction based on the sum of recent errors,
  3374. * and the derivative value determines the reaction based on the rate at which the error has been changing.
  3375. *
  3376. * \par Instance Structure
  3377. * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
  3378. * A separate instance structure must be defined for each PID Controller.
  3379. * There are separate instance structure declarations for each of the 3 supported data types.
  3380. *
  3381. * \par Reset Functions
  3382. * There is also an associated reset function for each data type which clears the state array.
  3383. *
  3384. * \par Initialization Functions
  3385. * There is also an associated initialization function for each data type.
  3386. * The initialization function performs the following operations:
  3387. * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
  3388. * - Zeros out the values in the state buffer.
  3389. *
  3390. * \par
  3391. * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
  3392. *
  3393. * \par Fixed-Point Behavior
  3394. * Care must be taken when using the fixed-point versions of the PID Controller functions.
  3395. * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
  3396. * Refer to the function specific documentation below for usage guidelines.
  3397. */
  3398. /**
  3399. * @addtogroup PID
  3400. * @{
  3401. */
  3402. /**
  3403. * @brief Process function for the floating-point PID Control.
  3404. * @param[in,out] S is an instance of the floating-point PID Control structure
  3405. * @param[in] in input sample to process
  3406. * @return out processed output sample.
  3407. */
  3408. static __INLINE float32_t arm_pid_f32(
  3409. arm_pid_instance_f32 * S,
  3410. float32_t in)
  3411. {
  3412. float32_t out;
  3413. /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
  3414. out = (S->A0 * in) +
  3415. (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
  3416. /* Update state */
  3417. S->state[1] = S->state[0];
  3418. S->state[0] = in;
  3419. S->state[2] = out;
  3420. /* return to application */
  3421. return (out);
  3422. }
  3423. /**
  3424. * @brief Process function for the Q31 PID Control.
  3425. * @param[in,out] S points to an instance of the Q31 PID Control structure
  3426. * @param[in] in input sample to process
  3427. * @return out processed output sample.
  3428. *
  3429. * <b>Scaling and Overflow Behavior:</b>
  3430. * \par
  3431. * The function is implemented using an internal 64-bit accumulator.
  3432. * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
  3433. * Thus, if the accumulator result overflows it wraps around rather than clip.
  3434. * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
  3435. * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
  3436. */
  3437. static __INLINE q31_t arm_pid_q31(
  3438. arm_pid_instance_q31 * S,
  3439. q31_t in)
  3440. {
  3441. q63_t acc;
  3442. q31_t out;
  3443. /* acc = A0 * x[n] */
  3444. acc = (q63_t) S->A0 * in;
  3445. /* acc += A1 * x[n-1] */
  3446. acc += (q63_t) S->A1 * S->state[0];
  3447. /* acc += A2 * x[n-2] */
  3448. acc += (q63_t) S->A2 * S->state[1];
  3449. /* convert output to 1.31 format to add y[n-1] */
  3450. out = (q31_t) (acc >> 31u);
  3451. /* out += y[n-1] */
  3452. out += S->state[2];
  3453. /* Update state */
  3454. S->state[1] = S->state[0];
  3455. S->state[0] = in;
  3456. S->state[2] = out;
  3457. /* return to application */
  3458. return (out);
  3459. }
  3460. /**
  3461. * @brief Process function for the Q15 PID Control.
  3462. * @param[in,out] S points to an instance of the Q15 PID Control structure
  3463. * @param[in] in input sample to process
  3464. * @return out processed output sample.
  3465. *
  3466. * <b>Scaling and Overflow Behavior:</b>
  3467. * \par
  3468. * The function is implemented using a 64-bit internal accumulator.
  3469. * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
  3470. * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
  3471. * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
  3472. * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
  3473. * Lastly, the accumulator is saturated to yield a result in 1.15 format.
  3474. */
  3475. static __INLINE q15_t arm_pid_q15(
  3476. arm_pid_instance_q15 * S,
  3477. q15_t in)
  3478. {
  3479. q63_t acc;
  3480. q15_t out;
  3481. #ifndef ARM_MATH_CM0_FAMILY
  3482. __SIMD32_TYPE *vstate;
  3483. /* Implementation of PID controller */
  3484. /* acc = A0 * x[n] */
  3485. acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in);
  3486. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  3487. vstate = __SIMD32_CONST(S->state); acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)*vstate, (uint64_t)acc);
  3488. #else
  3489. /* acc = A0 * x[n] */
  3490. acc = ((q31_t) S->A0) * in;
  3491. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  3492. acc += (q31_t) S->A1 * S->state[0];
  3493. acc += (q31_t) S->A2 * S->state[1];
  3494. #endif
  3495. /* acc += y[n-1] */
  3496. acc += (q31_t) S->state[2] << 15;
  3497. /* saturate the output */
  3498. out = (q15_t) (__SSAT((acc >> 15), 16));
  3499. /* Update state */
  3500. S->state[1] = S->state[0];
  3501. S->state[0] = in;
  3502. S->state[2] = out;
  3503. /* return to application */
  3504. return (out);
  3505. }
  3506. /**
  3507. * @} end of PID group
  3508. */
  3509. /**
  3510. * @brief Floating-point matrix inverse.
  3511. * @param[in] src points to the instance of the input floating-point matrix structure.
  3512. * @param[out] dst points to the instance of the output floating-point matrix structure.
  3513. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  3514. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  3515. */
  3516. arm_status arm_mat_inverse_f32(const arm_matrix_instance_f32 * src,
  3517. arm_matrix_instance_f32 * dst);
  3518. /**
  3519. * @brief Floating-point matrix inverse.
  3520. * @param[in] src points to the instance of the input floating-point matrix structure.
  3521. * @param[out] dst points to the instance of the output floating-point matrix structure.
  3522. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  3523. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  3524. */
  3525. arm_status arm_mat_inverse_f64(const arm_matrix_instance_f64 * src,
  3526. arm_matrix_instance_f64 * dst);
  3527. /**
  3528. * @ingroup groupController
  3529. */
  3530. /**
  3531. * @defgroup clarke Vector Clarke Transform
  3532. * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
  3533. * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
  3534. * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
  3535. * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
  3536. * \image html clarke.gif Stator current space vector and its components in (a,b).
  3537. * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
  3538. * can be calculated using only <code>Ia</code> and <code>Ib</code>.
  3539. *
  3540. * The function operates on a single sample of data and each call to the function returns the processed output.
  3541. * The library provides separate functions for Q31 and floating-point data types.
  3542. * \par Algorithm
  3543. * \image html clarkeFormula.gif
  3544. * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
  3545. * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
  3546. * \par Fixed-Point Behavior
  3547. * Care must be taken when using the Q31 version of the Clarke transform.
  3548. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  3549. * Refer to the function specific documentation below for usage guidelines.
  3550. */
  3551. /**
  3552. * @addtogroup clarke
  3553. * @{
  3554. */
  3555. /**
  3556. *
  3557. * @brief Floating-point Clarke transform
  3558. * @param[in] Ia input three-phase coordinate <code>a</code>
  3559. * @param[in] Ib input three-phase coordinate <code>b</code>
  3560. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  3561. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  3562. */
  3563. static __INLINE void arm_clarke_f32(
  3564. float32_t Ia,
  3565. float32_t Ib,
  3566. float32_t * pIalpha,
  3567. float32_t * pIbeta)
  3568. {
  3569. /* Calculate pIalpha using the equation, pIalpha = Ia */
  3570. *pIalpha = Ia;
  3571. /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
  3572. *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
  3573. }
  3574. /**
  3575. * @brief Clarke transform for Q31 version
  3576. * @param[in] Ia input three-phase coordinate <code>a</code>
  3577. * @param[in] Ib input three-phase coordinate <code>b</code>
  3578. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  3579. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  3580. *
  3581. * <b>Scaling and Overflow Behavior:</b>
  3582. * \par
  3583. * The function is implemented using an internal 32-bit accumulator.
  3584. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  3585. * There is saturation on the addition, hence there is no risk of overflow.
  3586. */
  3587. static __INLINE void arm_clarke_q31(
  3588. q31_t Ia,
  3589. q31_t Ib,
  3590. q31_t * pIalpha,
  3591. q31_t * pIbeta)
  3592. {
  3593. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  3594. /* Calculating pIalpha from Ia by equation pIalpha = Ia */
  3595. *pIalpha = Ia;
  3596. /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
  3597. product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
  3598. /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
  3599. product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
  3600. /* pIbeta is calculated by adding the intermediate products */
  3601. *pIbeta = __QADD(product1, product2);
  3602. }
  3603. /**
  3604. * @} end of clarke group
  3605. */
  3606. /**
  3607. * @brief Converts the elements of the Q7 vector to Q31 vector.
  3608. * @param[in] pSrc input pointer
  3609. * @param[out] pDst output pointer
  3610. * @param[in] blockSize number of samples to process
  3611. */
  3612. void arm_q7_to_q31(q7_t * pSrc, q31_t * pDst, uint32_t blockSize);
  3613. /**
  3614. * @ingroup groupController
  3615. */
  3616. /**
  3617. * @defgroup inv_clarke Vector Inverse Clarke Transform
  3618. * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
  3619. *
  3620. * The function operates on a single sample of data and each call to the function returns the processed output.
  3621. * The library provides separate functions for Q31 and floating-point data types.
  3622. * \par Algorithm
  3623. * \image html clarkeInvFormula.gif
  3624. * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
  3625. * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
  3626. * \par Fixed-Point Behavior
  3627. * Care must be taken when using the Q31 version of the Clarke transform.
  3628. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  3629. * Refer to the function specific documentation below for usage guidelines.
  3630. */
  3631. /**
  3632. * @addtogroup inv_clarke
  3633. * @{
  3634. */
  3635. /**
  3636. * @brief Floating-point Inverse Clarke transform
  3637. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  3638. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  3639. * @param[out] pIa points to output three-phase coordinate <code>a</code>
  3640. * @param[out] pIb points to output three-phase coordinate <code>b</code>
  3641. */
  3642. static __INLINE void arm_inv_clarke_f32(
  3643. float32_t Ialpha,
  3644. float32_t Ibeta,
  3645. float32_t * pIa,
  3646. float32_t * pIb)
  3647. {
  3648. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  3649. *pIa = Ialpha;
  3650. /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
  3651. *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta;
  3652. }
  3653. /**
  3654. * @brief Inverse Clarke transform for Q31 version
  3655. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  3656. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  3657. * @param[out] pIa points to output three-phase coordinate <code>a</code>
  3658. * @param[out] pIb points to output three-phase coordinate <code>b</code>
  3659. *
  3660. * <b>Scaling and Overflow Behavior:</b>
  3661. * \par
  3662. * The function is implemented using an internal 32-bit accumulator.
  3663. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  3664. * There is saturation on the subtraction, hence there is no risk of overflow.
  3665. */
  3666. static __INLINE void arm_inv_clarke_q31(
  3667. q31_t Ialpha,
  3668. q31_t Ibeta,
  3669. q31_t * pIa,
  3670. q31_t * pIb)
  3671. {
  3672. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  3673. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  3674. *pIa = Ialpha;
  3675. /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
  3676. product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
  3677. /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
  3678. product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
  3679. /* pIb is calculated by subtracting the products */
  3680. *pIb = __QSUB(product2, product1);
  3681. }
  3682. /**
  3683. * @} end of inv_clarke group
  3684. */
  3685. /**
  3686. * @brief Converts the elements of the Q7 vector to Q15 vector.
  3687. * @param[in] pSrc input pointer
  3688. * @param[out] pDst output pointer
  3689. * @param[in] blockSize number of samples to process
  3690. */
  3691. void arm_q7_to_q15(q7_t * pSrc, q15_t * pDst, uint32_t blockSize);
  3692. /**
  3693. * @ingroup groupController
  3694. */
  3695. /**
  3696. * @defgroup park Vector Park Transform
  3697. *
  3698. * Forward Park transform converts the input two-coordinate vector to flux and torque components.
  3699. * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
  3700. * from the stationary to the moving reference frame and control the spatial relationship between
  3701. * the stator vector current and rotor flux vector.
  3702. * If we consider the d axis aligned with the rotor flux, the diagram below shows the
  3703. * current vector and the relationship from the two reference frames:
  3704. * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
  3705. *
  3706. * The function operates on a single sample of data and each call to the function returns the processed output.
  3707. * The library provides separate functions for Q31 and floating-point data types.
  3708. * \par Algorithm
  3709. * \image html parkFormula.gif
  3710. * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
  3711. * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  3712. * cosine and sine values of theta (rotor flux position).
  3713. * \par Fixed-Point Behavior
  3714. * Care must be taken when using the Q31 version of the Park transform.
  3715. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  3716. * Refer to the function specific documentation below for usage guidelines.
  3717. */
  3718. /**
  3719. * @addtogroup park
  3720. * @{
  3721. */
  3722. /**
  3723. * @brief Floating-point Park transform
  3724. * @param[in] Ialpha input two-phase vector coordinate alpha
  3725. * @param[in] Ibeta input two-phase vector coordinate beta
  3726. * @param[out] pId points to output rotor reference frame d
  3727. * @param[out] pIq points to output rotor reference frame q
  3728. * @param[in] sinVal sine value of rotation angle theta
  3729. * @param[in] cosVal cosine value of rotation angle theta
  3730. *
  3731. * The function implements the forward Park transform.
  3732. *
  3733. */
  3734. static __INLINE void arm_park_f32(
  3735. float32_t Ialpha,
  3736. float32_t Ibeta,
  3737. float32_t * pId,
  3738. float32_t * pIq,
  3739. float32_t sinVal,
  3740. float32_t cosVal)
  3741. {
  3742. /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
  3743. *pId = Ialpha * cosVal + Ibeta * sinVal;
  3744. /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
  3745. *pIq = -Ialpha * sinVal + Ibeta * cosVal;
  3746. }
  3747. /**
  3748. * @brief Park transform for Q31 version
  3749. * @param[in] Ialpha input two-phase vector coordinate alpha
  3750. * @param[in] Ibeta input two-phase vector coordinate beta
  3751. * @param[out] pId points to output rotor reference frame d
  3752. * @param[out] pIq points to output rotor reference frame q
  3753. * @param[in] sinVal sine value of rotation angle theta
  3754. * @param[in] cosVal cosine value of rotation angle theta
  3755. *
  3756. * <b>Scaling and Overflow Behavior:</b>
  3757. * \par
  3758. * The function is implemented using an internal 32-bit accumulator.
  3759. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  3760. * There is saturation on the addition and subtraction, hence there is no risk of overflow.
  3761. */
  3762. static __INLINE void arm_park_q31(
  3763. q31_t Ialpha,
  3764. q31_t Ibeta,
  3765. q31_t * pId,
  3766. q31_t * pIq,
  3767. q31_t sinVal,
  3768. q31_t cosVal)
  3769. {
  3770. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  3771. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  3772. /* Intermediate product is calculated by (Ialpha * cosVal) */
  3773. product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
  3774. /* Intermediate product is calculated by (Ibeta * sinVal) */
  3775. product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
  3776. /* Intermediate product is calculated by (Ialpha * sinVal) */
  3777. product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
  3778. /* Intermediate product is calculated by (Ibeta * cosVal) */
  3779. product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
  3780. /* Calculate pId by adding the two intermediate products 1 and 2 */
  3781. *pId = __QADD(product1, product2);
  3782. /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
  3783. *pIq = __QSUB(product4, product3);
  3784. }
  3785. /**
  3786. * @} end of park group
  3787. */
  3788. /**
  3789. * @brief Converts the elements of the Q7 vector to floating-point vector.
  3790. * @param[in] pSrc is input pointer
  3791. * @param[out] pDst is output pointer
  3792. * @param[in] blockSize is the number of samples to process
  3793. */
  3794. void arm_q7_to_float(q7_t * pSrc, float32_t * pDst, uint32_t blockSize);
  3795. /**
  3796. * @ingroup groupController
  3797. */
  3798. /**
  3799. * @defgroup inv_park Vector Inverse Park transform
  3800. * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
  3801. *
  3802. * The function operates on a single sample of data and each call to the function returns the processed output.
  3803. * The library provides separate functions for Q31 and floating-point data types.
  3804. * \par Algorithm
  3805. * \image html parkInvFormula.gif
  3806. * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
  3807. * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  3808. * cosine and sine values of theta (rotor flux position).
  3809. * \par Fixed-Point Behavior
  3810. * Care must be taken when using the Q31 version of the Park transform.
  3811. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  3812. * Refer to the function specific documentation below for usage guidelines.
  3813. */
  3814. /**
  3815. * @addtogroup inv_park
  3816. * @{
  3817. */
  3818. /**
  3819. * @brief Floating-point Inverse Park transform
  3820. * @param[in] Id input coordinate of rotor reference frame d
  3821. * @param[in] Iq input coordinate of rotor reference frame q
  3822. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  3823. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  3824. * @param[in] sinVal sine value of rotation angle theta
  3825. * @param[in] cosVal cosine value of rotation angle theta
  3826. */
  3827. static __INLINE void arm_inv_park_f32(
  3828. float32_t Id,
  3829. float32_t Iq,
  3830. float32_t * pIalpha,
  3831. float32_t * pIbeta,
  3832. float32_t sinVal,
  3833. float32_t cosVal)
  3834. {
  3835. /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
  3836. *pIalpha = Id * cosVal - Iq * sinVal;
  3837. /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
  3838. *pIbeta = Id * sinVal + Iq * cosVal;
  3839. }
  3840. /**
  3841. * @brief Inverse Park transform for Q31 version
  3842. * @param[in] Id input coordinate of rotor reference frame d
  3843. * @param[in] Iq input coordinate of rotor reference frame q
  3844. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  3845. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  3846. * @param[in] sinVal sine value of rotation angle theta
  3847. * @param[in] cosVal cosine value of rotation angle theta
  3848. *
  3849. * <b>Scaling and Overflow Behavior:</b>
  3850. * \par
  3851. * The function is implemented using an internal 32-bit accumulator.
  3852. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  3853. * There is saturation on the addition, hence there is no risk of overflow.
  3854. */
  3855. static __INLINE void arm_inv_park_q31(
  3856. q31_t Id,
  3857. q31_t Iq,
  3858. q31_t * pIalpha,
  3859. q31_t * pIbeta,
  3860. q31_t sinVal,
  3861. q31_t cosVal)
  3862. {
  3863. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  3864. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  3865. /* Intermediate product is calculated by (Id * cosVal) */
  3866. product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
  3867. /* Intermediate product is calculated by (Iq * sinVal) */
  3868. product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
  3869. /* Intermediate product is calculated by (Id * sinVal) */
  3870. product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
  3871. /* Intermediate product is calculated by (Iq * cosVal) */
  3872. product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
  3873. /* Calculate pIalpha by using the two intermediate products 1 and 2 */
  3874. *pIalpha = __QSUB(product1, product2);
  3875. /* Calculate pIbeta by using the two intermediate products 3 and 4 */
  3876. *pIbeta = __QADD(product4, product3);
  3877. }
  3878. /**
  3879. * @} end of Inverse park group
  3880. */
  3881. /**
  3882. * @brief Converts the elements of the Q31 vector to floating-point vector.
  3883. * @param[in] pSrc is input pointer
  3884. * @param[out] pDst is output pointer
  3885. * @param[in] blockSize is the number of samples to process
  3886. */
  3887. void arm_q31_to_float(q31_t * pSrc, float32_t * pDst, uint32_t blockSize);
  3888. /**
  3889. * @ingroup groupInterpolation
  3890. */
  3891. /**
  3892. * @defgroup LinearInterpolate Linear Interpolation
  3893. *
  3894. * Linear interpolation is a method of curve fitting using linear polynomials.
  3895. * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
  3896. *
  3897. * \par
  3898. * \image html LinearInterp.gif "Linear interpolation"
  3899. *
  3900. * \par
  3901. * A Linear Interpolate function calculates an output value(y), for the input(x)
  3902. * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
  3903. *
  3904. * \par Algorithm:
  3905. * <pre>
  3906. * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
  3907. * where x0, x1 are nearest values of input x
  3908. * y0, y1 are nearest values to output y
  3909. * </pre>
  3910. *
  3911. * \par
  3912. * This set of functions implements Linear interpolation process
  3913. * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
  3914. * sample of data and each call to the function returns a single processed value.
  3915. * <code>S</code> points to an instance of the Linear Interpolate function data structure.
  3916. * <code>x</code> is the input sample value. The functions returns the output value.
  3917. *
  3918. * \par
  3919. * if x is outside of the table boundary, Linear interpolation returns first value of the table
  3920. * if x is below input range and returns last value of table if x is above range.
  3921. */
  3922. /**
  3923. * @addtogroup LinearInterpolate
  3924. * @{
  3925. */
  3926. /**
  3927. * @brief Process function for the floating-point Linear Interpolation Function.
  3928. * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
  3929. * @param[in] x input sample to process
  3930. * @return y processed output sample.
  3931. *
  3932. */
  3933. static __INLINE float32_t arm_linear_interp_f32(
  3934. arm_linear_interp_instance_f32 * S,
  3935. float32_t x)
  3936. {
  3937. float32_t y;
  3938. float32_t x0, x1; /* Nearest input values */
  3939. float32_t y0, y1; /* Nearest output values */
  3940. float32_t xSpacing = S->xSpacing; /* spacing between input values */
  3941. int32_t i; /* Index variable */
  3942. float32_t *pYData = S->pYData; /* pointer to output table */
  3943. /* Calculation of index */
  3944. i = (int32_t) ((x - S->x1) / xSpacing);
  3945. if(i < 0)
  3946. {
  3947. /* Iniatilize output for below specified range as least output value of table */
  3948. y = pYData[0];
  3949. }
  3950. else if((uint32_t)i >= S->nValues)
  3951. {
  3952. /* Iniatilize output for above specified range as last output value of table */
  3953. y = pYData[S->nValues - 1];
  3954. }
  3955. else
  3956. {
  3957. /* Calculation of nearest input values */
  3958. x0 = S->x1 + i * xSpacing;
  3959. x1 = S->x1 + (i + 1) * xSpacing;
  3960. /* Read of nearest output values */
  3961. y0 = pYData[i];
  3962. y1 = pYData[i + 1];
  3963. /* Calculation of output */
  3964. y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
  3965. }
  3966. /* returns output value */
  3967. return (y);
  3968. }
  3969. /**
  3970. *
  3971. * @brief Process function for the Q31 Linear Interpolation Function.
  3972. * @param[in] pYData pointer to Q31 Linear Interpolation table
  3973. * @param[in] x input sample to process
  3974. * @param[in] nValues number of table values
  3975. * @return y processed output sample.
  3976. *
  3977. * \par
  3978. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  3979. * This function can support maximum of table size 2^12.
  3980. *
  3981. */
  3982. static __INLINE q31_t arm_linear_interp_q31(
  3983. q31_t * pYData,
  3984. q31_t x,
  3985. uint32_t nValues)
  3986. {
  3987. q31_t y; /* output */
  3988. q31_t y0, y1; /* Nearest output values */
  3989. q31_t fract; /* fractional part */
  3990. int32_t index; /* Index to read nearest output values */
  3991. /* Input is in 12.20 format */
  3992. /* 12 bits for the table index */
  3993. /* Index value calculation */
  3994. index = ((x & (q31_t)0xFFF00000) >> 20);
  3995. if(index >= (int32_t)(nValues - 1))
  3996. {
  3997. return (pYData[nValues - 1]);
  3998. }
  3999. else if(index < 0)
  4000. {
  4001. return (pYData[0]);
  4002. }
  4003. else
  4004. {
  4005. /* 20 bits for the fractional part */
  4006. /* shift left by 11 to keep fract in 1.31 format */
  4007. fract = (x & 0x000FFFFF) << 11;
  4008. /* Read two nearest output values from the index in 1.31(q31) format */
  4009. y0 = pYData[index];
  4010. y1 = pYData[index + 1];
  4011. /* Calculation of y0 * (1-fract) and y is in 2.30 format */
  4012. y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
  4013. /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
  4014. y += ((q31_t) (((q63_t) y1 * fract) >> 32));
  4015. /* Convert y to 1.31 format */
  4016. return (y << 1u);
  4017. }
  4018. }
  4019. /**
  4020. *
  4021. * @brief Process function for the Q15 Linear Interpolation Function.
  4022. * @param[in] pYData pointer to Q15 Linear Interpolation table
  4023. * @param[in] x input sample to process
  4024. * @param[in] nValues number of table values
  4025. * @return y processed output sample.
  4026. *
  4027. * \par
  4028. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4029. * This function can support maximum of table size 2^12.
  4030. *
  4031. */
  4032. static __INLINE q15_t arm_linear_interp_q15(
  4033. q15_t * pYData,
  4034. q31_t x,
  4035. uint32_t nValues)
  4036. {
  4037. q63_t y; /* output */
  4038. q15_t y0, y1; /* Nearest output values */
  4039. q31_t fract; /* fractional part */
  4040. int32_t index; /* Index to read nearest output values */
  4041. /* Input is in 12.20 format */
  4042. /* 12 bits for the table index */
  4043. /* Index value calculation */
  4044. index = ((x & (int32_t)0xFFF00000) >> 20);
  4045. if(index >= (int32_t)(nValues - 1))
  4046. {
  4047. return (pYData[nValues - 1]);
  4048. }
  4049. else if(index < 0)
  4050. {
  4051. return (pYData[0]);
  4052. }
  4053. else
  4054. {
  4055. /* 20 bits for the fractional part */
  4056. /* fract is in 12.20 format */
  4057. fract = (x & 0x000FFFFF);
  4058. /* Read two nearest output values from the index */
  4059. y0 = pYData[index];
  4060. y1 = pYData[index + 1];
  4061. /* Calculation of y0 * (1-fract) and y is in 13.35 format */
  4062. y = ((q63_t) y0 * (0xFFFFF - fract));
  4063. /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
  4064. y += ((q63_t) y1 * (fract));
  4065. /* convert y to 1.15 format */
  4066. return (q15_t) (y >> 20);
  4067. }
  4068. }
  4069. /**
  4070. *
  4071. * @brief Process function for the Q7 Linear Interpolation Function.
  4072. * @param[in] pYData pointer to Q7 Linear Interpolation table
  4073. * @param[in] x input sample to process
  4074. * @param[in] nValues number of table values
  4075. * @return y processed output sample.
  4076. *
  4077. * \par
  4078. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4079. * This function can support maximum of table size 2^12.
  4080. */
  4081. static __INLINE q7_t arm_linear_interp_q7(
  4082. q7_t * pYData,
  4083. q31_t x,
  4084. uint32_t nValues)
  4085. {
  4086. q31_t y; /* output */
  4087. q7_t y0, y1; /* Nearest output values */
  4088. q31_t fract; /* fractional part */
  4089. uint32_t index; /* Index to read nearest output values */
  4090. /* Input is in 12.20 format */
  4091. /* 12 bits for the table index */
  4092. /* Index value calculation */
  4093. if (x < 0)
  4094. {
  4095. return (pYData[0]);
  4096. }
  4097. index = (x >> 20) & 0xfff;
  4098. if(index >= (nValues - 1))
  4099. {
  4100. return (pYData[nValues - 1]);
  4101. }
  4102. else
  4103. {
  4104. /* 20 bits for the fractional part */
  4105. /* fract is in 12.20 format */
  4106. fract = (x & 0x000FFFFF);
  4107. /* Read two nearest output values from the index and are in 1.7(q7) format */
  4108. y0 = pYData[index];
  4109. y1 = pYData[index + 1];
  4110. /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
  4111. y = ((y0 * (0xFFFFF - fract)));
  4112. /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
  4113. y += (y1 * fract);
  4114. /* convert y to 1.7(q7) format */
  4115. return (q7_t) (y >> 20);
  4116. }
  4117. }
  4118. /**
  4119. * @} end of LinearInterpolate group
  4120. */
  4121. /**
  4122. * @brief Fast approximation to the trigonometric sine function for floating-point data.
  4123. * @param[in] x input value in radians.
  4124. * @return sin(x).
  4125. */
  4126. float32_t arm_sin_f32(float32_t x);
  4127. /**
  4128. * @brief Fast approximation to the trigonometric sine function for Q31 data.
  4129. * @param[in] x Scaled input value in radians.
  4130. * @return sin(x).
  4131. */
  4132. q31_t arm_sin_q31(q31_t x);
  4133. /**
  4134. * @brief Fast approximation to the trigonometric sine function for Q15 data.
  4135. * @param[in] x Scaled input value in radians.
  4136. * @return sin(x).
  4137. */
  4138. q15_t arm_sin_q15(q15_t x);
  4139. /**
  4140. * @brief Fast approximation to the trigonometric cosine function for floating-point data.
  4141. * @param[in] x input value in radians.
  4142. * @return cos(x).
  4143. */
  4144. float32_t arm_cos_f32(float32_t x);
  4145. /**
  4146. * @brief Fast approximation to the trigonometric cosine function for Q31 data.
  4147. * @param[in] x Scaled input value in radians.
  4148. * @return cos(x).
  4149. */
  4150. q31_t arm_cos_q31(q31_t x);
  4151. /**
  4152. * @brief Fast approximation to the trigonometric cosine function for Q15 data.
  4153. * @param[in] x Scaled input value in radians.
  4154. * @return cos(x).
  4155. */
  4156. q15_t arm_cos_q15(q15_t x);
  4157. /**
  4158. * @ingroup groupFastMath
  4159. */
  4160. /**
  4161. * @defgroup SQRT Square Root
  4162. *
  4163. * Computes the square root of a number.
  4164. * There are separate functions for Q15, Q31, and floating-point data types.
  4165. * The square root function is computed using the Newton-Raphson algorithm.
  4166. * This is an iterative algorithm of the form:
  4167. * <pre>
  4168. * x1 = x0 - f(x0)/f'(x0)
  4169. * </pre>
  4170. * where <code>x1</code> is the current estimate,
  4171. * <code>x0</code> is the previous estimate, and
  4172. * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
  4173. * For the square root function, the algorithm reduces to:
  4174. * <pre>
  4175. * x0 = in/2 [initial guess]
  4176. * x1 = 1/2 * ( x0 + in / x0) [each iteration]
  4177. * </pre>
  4178. */
  4179. /**
  4180. * @addtogroup SQRT
  4181. * @{
  4182. */
  4183. /**
  4184. * @brief Floating-point square root function.
  4185. * @param[in] in input value.
  4186. * @param[out] pOut square root of input value.
  4187. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4188. * <code>in</code> is negative value and returns zero output for negative values.
  4189. */
  4190. static __INLINE arm_status arm_sqrt_f32(
  4191. float32_t in,
  4192. float32_t * pOut)
  4193. {
  4194. if(in >= 0.0f)
  4195. {
  4196. #if (__FPU_USED == 1) && defined ( __CC_ARM )
  4197. *pOut = __sqrtf(in);
  4198. #elif (__FPU_USED == 1) && (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
  4199. *pOut = __builtin_sqrtf(in);
  4200. #elif (__FPU_USED == 1) && defined(__GNUC__)
  4201. *pOut = __builtin_sqrtf(in);
  4202. #elif (__FPU_USED == 1) && defined ( __ICCARM__ ) && (__VER__ >= 6040000)
  4203. __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in));
  4204. #else
  4205. *pOut = sqrtf(in);
  4206. #endif
  4207. return (ARM_MATH_SUCCESS);
  4208. }
  4209. else
  4210. {
  4211. *pOut = 0.0f;
  4212. return (ARM_MATH_ARGUMENT_ERROR);
  4213. }
  4214. }
  4215. /**
  4216. * @brief Q31 square root function.
  4217. * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
  4218. * @param[out] pOut square root of input value.
  4219. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4220. * <code>in</code> is negative value and returns zero output for negative values.
  4221. */
  4222. arm_status arm_sqrt_q31(q31_t in, q31_t * pOut);
  4223. /**
  4224. * @brief Q15 square root function.
  4225. * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
  4226. * @param[out] pOut square root of input value.
  4227. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4228. * <code>in</code> is negative value and returns zero output for negative values.
  4229. */
  4230. arm_status arm_sqrt_q15(q15_t in, q15_t * pOut);
  4231. /**
  4232. * @} end of SQRT group
  4233. */
  4234. /**
  4235. * @brief floating-point Circular write function.
  4236. */
  4237. static __INLINE void arm_circularWrite_f32(
  4238. int32_t * circBuffer,
  4239. int32_t L,
  4240. uint16_t * writeOffset,
  4241. int32_t bufferInc,
  4242. const int32_t * src,
  4243. int32_t srcInc,
  4244. uint32_t blockSize)
  4245. {
  4246. uint32_t i = 0u;
  4247. int32_t wOffset;
  4248. /* Copy the value of Index pointer that points
  4249. * to the current location where the input samples to be copied */
  4250. wOffset = *writeOffset;
  4251. /* Loop over the blockSize */
  4252. i = blockSize;
  4253. while(i > 0u)
  4254. {
  4255. /* copy the input sample to the circular buffer */
  4256. circBuffer[wOffset] = *src;
  4257. /* Update the input pointer */
  4258. src += srcInc;
  4259. /* Circularly update wOffset. Watch out for positive and negative value */
  4260. wOffset += bufferInc;
  4261. if(wOffset >= L)
  4262. wOffset -= L;
  4263. /* Decrement the loop counter */
  4264. i--;
  4265. }
  4266. /* Update the index pointer */
  4267. *writeOffset = (uint16_t)wOffset;
  4268. }
  4269. /**
  4270. * @brief floating-point Circular Read function.
  4271. */
  4272. static __INLINE void arm_circularRead_f32(
  4273. int32_t * circBuffer,
  4274. int32_t L,
  4275. int32_t * readOffset,
  4276. int32_t bufferInc,
  4277. int32_t * dst,
  4278. int32_t * dst_base,
  4279. int32_t dst_length,
  4280. int32_t dstInc,
  4281. uint32_t blockSize)
  4282. {
  4283. uint32_t i = 0u;
  4284. int32_t rOffset, dst_end;
  4285. /* Copy the value of Index pointer that points
  4286. * to the current location from where the input samples to be read */
  4287. rOffset = *readOffset;
  4288. dst_end = (int32_t) (dst_base + dst_length);
  4289. /* Loop over the blockSize */
  4290. i = blockSize;
  4291. while(i > 0u)
  4292. {
  4293. /* copy the sample from the circular buffer to the destination buffer */
  4294. *dst = circBuffer[rOffset];
  4295. /* Update the input pointer */
  4296. dst += dstInc;
  4297. if(dst == (int32_t *) dst_end)
  4298. {
  4299. dst = dst_base;
  4300. }
  4301. /* Circularly update rOffset. Watch out for positive and negative value */
  4302. rOffset += bufferInc;
  4303. if(rOffset >= L)
  4304. {
  4305. rOffset -= L;
  4306. }
  4307. /* Decrement the loop counter */
  4308. i--;
  4309. }
  4310. /* Update the index pointer */
  4311. *readOffset = rOffset;
  4312. }
  4313. /**
  4314. * @brief Q15 Circular write function.
  4315. */
  4316. static __INLINE void arm_circularWrite_q15(
  4317. q15_t * circBuffer,
  4318. int32_t L,
  4319. uint16_t * writeOffset,
  4320. int32_t bufferInc,
  4321. const q15_t * src,
  4322. int32_t srcInc,
  4323. uint32_t blockSize)
  4324. {
  4325. uint32_t i = 0u;
  4326. int32_t wOffset;
  4327. /* Copy the value of Index pointer that points
  4328. * to the current location where the input samples to be copied */
  4329. wOffset = *writeOffset;
  4330. /* Loop over the blockSize */
  4331. i = blockSize;
  4332. while(i > 0u)
  4333. {
  4334. /* copy the input sample to the circular buffer */
  4335. circBuffer[wOffset] = *src;
  4336. /* Update the input pointer */
  4337. src += srcInc;
  4338. /* Circularly update wOffset. Watch out for positive and negative value */
  4339. wOffset += bufferInc;
  4340. if(wOffset >= L)
  4341. wOffset -= L;
  4342. /* Decrement the loop counter */
  4343. i--;
  4344. }
  4345. /* Update the index pointer */
  4346. *writeOffset = (uint16_t)wOffset;
  4347. }
  4348. /**
  4349. * @brief Q15 Circular Read function.
  4350. */
  4351. static __INLINE void arm_circularRead_q15(
  4352. q15_t * circBuffer,
  4353. int32_t L,
  4354. int32_t * readOffset,
  4355. int32_t bufferInc,
  4356. q15_t * dst,
  4357. q15_t * dst_base,
  4358. int32_t dst_length,
  4359. int32_t dstInc,
  4360. uint32_t blockSize)
  4361. {
  4362. uint32_t i = 0;
  4363. int32_t rOffset, dst_end;
  4364. /* Copy the value of Index pointer that points
  4365. * to the current location from where the input samples to be read */
  4366. rOffset = *readOffset;
  4367. dst_end = (int32_t) (dst_base + dst_length);
  4368. /* Loop over the blockSize */
  4369. i = blockSize;
  4370. while(i > 0u)
  4371. {
  4372. /* copy the sample from the circular buffer to the destination buffer */
  4373. *dst = circBuffer[rOffset];
  4374. /* Update the input pointer */
  4375. dst += dstInc;
  4376. if(dst == (q15_t *) dst_end)
  4377. {
  4378. dst = dst_base;
  4379. }
  4380. /* Circularly update wOffset. Watch out for positive and negative value */
  4381. rOffset += bufferInc;
  4382. if(rOffset >= L)
  4383. {
  4384. rOffset -= L;
  4385. }
  4386. /* Decrement the loop counter */
  4387. i--;
  4388. }
  4389. /* Update the index pointer */
  4390. *readOffset = rOffset;
  4391. }
  4392. /**
  4393. * @brief Q7 Circular write function.
  4394. */
  4395. static __INLINE void arm_circularWrite_q7(
  4396. q7_t * circBuffer,
  4397. int32_t L,
  4398. uint16_t * writeOffset,
  4399. int32_t bufferInc,
  4400. const q7_t * src,
  4401. int32_t srcInc,
  4402. uint32_t blockSize)
  4403. {
  4404. uint32_t i = 0u;
  4405. int32_t wOffset;
  4406. /* Copy the value of Index pointer that points
  4407. * to the current location where the input samples to be copied */
  4408. wOffset = *writeOffset;
  4409. /* Loop over the blockSize */
  4410. i = blockSize;
  4411. while(i > 0u)
  4412. {
  4413. /* copy the input sample to the circular buffer */
  4414. circBuffer[wOffset] = *src;
  4415. /* Update the input pointer */
  4416. src += srcInc;
  4417. /* Circularly update wOffset. Watch out for positive and negative value */
  4418. wOffset += bufferInc;
  4419. if(wOffset >= L)
  4420. wOffset -= L;
  4421. /* Decrement the loop counter */
  4422. i--;
  4423. }
  4424. /* Update the index pointer */
  4425. *writeOffset = (uint16_t)wOffset;
  4426. }
  4427. /**
  4428. * @brief Q7 Circular Read function.
  4429. */
  4430. static __INLINE void arm_circularRead_q7(
  4431. q7_t * circBuffer,
  4432. int32_t L,
  4433. int32_t * readOffset,
  4434. int32_t bufferInc,
  4435. q7_t * dst,
  4436. q7_t * dst_base,
  4437. int32_t dst_length,
  4438. int32_t dstInc,
  4439. uint32_t blockSize)
  4440. {
  4441. uint32_t i = 0;
  4442. int32_t rOffset, dst_end;
  4443. /* Copy the value of Index pointer that points
  4444. * to the current location from where the input samples to be read */
  4445. rOffset = *readOffset;
  4446. dst_end = (int32_t) (dst_base + dst_length);
  4447. /* Loop over the blockSize */
  4448. i = blockSize;
  4449. while(i > 0u)
  4450. {
  4451. /* copy the sample from the circular buffer to the destination buffer */
  4452. *dst = circBuffer[rOffset];
  4453. /* Update the input pointer */
  4454. dst += dstInc;
  4455. if(dst == (q7_t *) dst_end)
  4456. {
  4457. dst = dst_base;
  4458. }
  4459. /* Circularly update rOffset. Watch out for positive and negative value */
  4460. rOffset += bufferInc;
  4461. if(rOffset >= L)
  4462. {
  4463. rOffset -= L;
  4464. }
  4465. /* Decrement the loop counter */
  4466. i--;
  4467. }
  4468. /* Update the index pointer */
  4469. *readOffset = rOffset;
  4470. }
  4471. /**
  4472. * @brief Sum of the squares of the elements of a Q31 vector.
  4473. * @param[in] pSrc is input pointer
  4474. * @param[in] blockSize is the number of samples to process
  4475. * @param[out] pResult is output value.
  4476. */
  4477. void arm_power_q31(q31_t * pSrc, uint32_t blockSize, q63_t * pResult);
  4478. /**
  4479. * @brief Sum of the squares of the elements of a floating-point vector.
  4480. * @param[in] pSrc is input pointer
  4481. * @param[in] blockSize is the number of samples to process
  4482. * @param[out] pResult is output value.
  4483. */
  4484. void arm_power_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult);
  4485. /**
  4486. * @brief Sum of the squares of the elements of a Q15 vector.
  4487. * @param[in] pSrc is input pointer
  4488. * @param[in] blockSize is the number of samples to process
  4489. * @param[out] pResult is output value.
  4490. */
  4491. void arm_power_q15(q15_t * pSrc, uint32_t blockSize, q63_t * pResult);
  4492. /**
  4493. * @brief Sum of the squares of the elements of a Q7 vector.
  4494. * @param[in] pSrc is input pointer
  4495. * @param[in] blockSize is the number of samples to process
  4496. * @param[out] pResult is output value.
  4497. */
  4498. void arm_power_q7(q7_t * pSrc, uint32_t blockSize, q31_t * pResult);
  4499. /**
  4500. * @brief Mean value of a Q7 vector.
  4501. * @param[in] pSrc is input pointer
  4502. * @param[in] blockSize is the number of samples to process
  4503. * @param[out] pResult is output value.
  4504. */
  4505. void arm_mean_q7(q7_t * pSrc, uint32_t blockSize, q7_t * pResult);
  4506. /**
  4507. * @brief Mean value of a Q15 vector.
  4508. * @param[in] pSrc is input pointer
  4509. * @param[in] blockSize is the number of samples to process
  4510. * @param[out] pResult is output value.
  4511. */
  4512. void arm_mean_q15(q15_t * pSrc, uint32_t blockSize, q15_t * pResult);
  4513. /**
  4514. * @brief Mean value of a Q31 vector.
  4515. * @param[in] pSrc is input pointer
  4516. * @param[in] blockSize is the number of samples to process
  4517. * @param[out] pResult is output value.
  4518. */
  4519. void arm_mean_q31(q31_t * pSrc, uint32_t blockSize, q31_t * pResult);
  4520. /**
  4521. * @brief Mean value of a floating-point vector.
  4522. * @param[in] pSrc is input pointer
  4523. * @param[in] blockSize is the number of samples to process
  4524. * @param[out] pResult is output value.
  4525. */
  4526. void arm_mean_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult);
  4527. /**
  4528. * @brief Variance of the elements of a floating-point vector.
  4529. * @param[in] pSrc is input pointer
  4530. * @param[in] blockSize is the number of samples to process
  4531. * @param[out] pResult is output value.
  4532. */
  4533. void arm_var_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult);
  4534. /**
  4535. * @brief Variance of the elements of a Q31 vector.
  4536. * @param[in] pSrc is input pointer
  4537. * @param[in] blockSize is the number of samples to process
  4538. * @param[out] pResult is output value.
  4539. */
  4540. void arm_var_q31(q31_t * pSrc, uint32_t blockSize, q31_t * pResult);
  4541. /**
  4542. * @brief Variance of the elements of a Q15 vector.
  4543. * @param[in] pSrc is input pointer
  4544. * @param[in] blockSize is the number of samples to process
  4545. * @param[out] pResult is output value.
  4546. */
  4547. void arm_var_q15(q15_t * pSrc, uint32_t blockSize, q15_t * pResult);
  4548. /**
  4549. * @brief Root Mean Square of the elements of a floating-point vector.
  4550. * @param[in] pSrc is input pointer
  4551. * @param[in] blockSize is the number of samples to process
  4552. * @param[out] pResult is output value.
  4553. */
  4554. void arm_rms_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult);
  4555. /**
  4556. * @brief Root Mean Square of the elements of a Q31 vector.
  4557. * @param[in] pSrc is input pointer
  4558. * @param[in] blockSize is the number of samples to process
  4559. * @param[out] pResult is output value.
  4560. */
  4561. void arm_rms_q31(q31_t * pSrc, uint32_t blockSize, q31_t * pResult);
  4562. /**
  4563. * @brief Root Mean Square of the elements of a Q15 vector.
  4564. * @param[in] pSrc is input pointer
  4565. * @param[in] blockSize is the number of samples to process
  4566. * @param[out] pResult is output value.
  4567. */
  4568. void arm_rms_q15(q15_t * pSrc, uint32_t blockSize, q15_t * pResult);
  4569. /**
  4570. * @brief Standard deviation of the elements of a floating-point vector.
  4571. * @param[in] pSrc is input pointer
  4572. * @param[in] blockSize is the number of samples to process
  4573. * @param[out] pResult is output value.
  4574. */
  4575. void arm_std_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult);
  4576. /**
  4577. * @brief Standard deviation of the elements of a Q31 vector.
  4578. * @param[in] pSrc is input pointer
  4579. * @param[in] blockSize is the number of samples to process
  4580. * @param[out] pResult is output value.
  4581. */
  4582. void arm_std_q31(q31_t * pSrc, uint32_t blockSize, q31_t * pResult);
  4583. /**
  4584. * @brief Standard deviation of the elements of a Q15 vector.
  4585. * @param[in] pSrc is input pointer
  4586. * @param[in] blockSize is the number of samples to process
  4587. * @param[out] pResult is output value.
  4588. */
  4589. void arm_std_q15(q15_t * pSrc, uint32_t blockSize, q15_t * pResult);
  4590. /**
  4591. * @brief Floating-point complex magnitude
  4592. * @param[in] pSrc points to the complex input vector
  4593. * @param[out] pDst points to the real output vector
  4594. * @param[in] numSamples number of complex samples in the input vector
  4595. */
  4596. void arm_cmplx_mag_f32(float32_t * pSrc, float32_t * pDst, uint32_t numSamples);
  4597. /**
  4598. * @brief Q31 complex magnitude
  4599. * @param[in] pSrc points to the complex input vector
  4600. * @param[out] pDst points to the real output vector
  4601. * @param[in] numSamples number of complex samples in the input vector
  4602. */
  4603. void arm_cmplx_mag_q31(q31_t * pSrc, q31_t * pDst, uint32_t numSamples);
  4604. /**
  4605. * @brief Q15 complex magnitude
  4606. * @param[in] pSrc points to the complex input vector
  4607. * @param[out] pDst points to the real output vector
  4608. * @param[in] numSamples number of complex samples in the input vector
  4609. */
  4610. void arm_cmplx_mag_q15(q15_t * pSrc, q15_t * pDst, uint32_t numSamples);
  4611. /**
  4612. * @brief Q15 complex dot product
  4613. * @param[in] pSrcA points to the first input vector
  4614. * @param[in] pSrcB points to the second input vector
  4615. * @param[in] numSamples number of complex samples in each vector
  4616. * @param[out] realResult real part of the result returned here
  4617. * @param[out] imagResult imaginary part of the result returned here
  4618. */
  4619. void arm_cmplx_dot_prod_q15(q15_t * pSrcA, q15_t * pSrcB, uint32_t numSamples,
  4620. q31_t * realResult, q31_t * imagResult);
  4621. /**
  4622. * @brief Q31 complex dot product
  4623. * @param[in] pSrcA points to the first input vector
  4624. * @param[in] pSrcB points to the second input vector
  4625. * @param[in] numSamples number of complex samples in each vector
  4626. * @param[out] realResult real part of the result returned here
  4627. * @param[out] imagResult imaginary part of the result returned here
  4628. */
  4629. void arm_cmplx_dot_prod_q31(q31_t * pSrcA, q31_t * pSrcB, uint32_t numSamples,
  4630. q63_t * realResult, q63_t * imagResult);
  4631. /**
  4632. * @brief Floating-point complex dot product
  4633. * @param[in] pSrcA points to the first input vector
  4634. * @param[in] pSrcB points to the second input vector
  4635. * @param[in] numSamples number of complex samples in each vector
  4636. * @param[out] realResult real part of the result returned here
  4637. * @param[out] imagResult imaginary part of the result returned here
  4638. */
  4639. void arm_cmplx_dot_prod_f32(float32_t * pSrcA, float32_t * pSrcB,
  4640. uint32_t numSamples, float32_t * realResult, float32_t * imagResult);
  4641. /**
  4642. * @brief Q15 complex-by-real multiplication
  4643. * @param[in] pSrcCmplx points to the complex input vector
  4644. * @param[in] pSrcReal points to the real input vector
  4645. * @param[out] pCmplxDst points to the complex output vector
  4646. * @param[in] numSamples number of samples in each vector
  4647. */
  4648. void arm_cmplx_mult_real_q15(q15_t * pSrcCmplx, q15_t * pSrcReal,
  4649. q15_t * pCmplxDst, uint32_t numSamples);
  4650. /**
  4651. * @brief Q31 complex-by-real multiplication
  4652. * @param[in] pSrcCmplx points to the complex input vector
  4653. * @param[in] pSrcReal points to the real input vector
  4654. * @param[out] pCmplxDst points to the complex output vector
  4655. * @param[in] numSamples number of samples in each vector
  4656. */
  4657. void arm_cmplx_mult_real_q31(q31_t * pSrcCmplx, q31_t * pSrcReal,
  4658. q31_t * pCmplxDst, uint32_t numSamples);
  4659. /**
  4660. * @brief Floating-point complex-by-real multiplication
  4661. * @param[in] pSrcCmplx points to the complex input vector
  4662. * @param[in] pSrcReal points to the real input vector
  4663. * @param[out] pCmplxDst points to the complex output vector
  4664. * @param[in] numSamples number of samples in each vector
  4665. */
  4666. void arm_cmplx_mult_real_f32(float32_t * pSrcCmplx, float32_t * pSrcReal,
  4667. float32_t * pCmplxDst, uint32_t numSamples);
  4668. /**
  4669. * @brief Minimum value of a Q7 vector.
  4670. * @param[in] pSrc is input pointer
  4671. * @param[in] blockSize is the number of samples to process
  4672. * @param[out] result is output pointer
  4673. * @param[in] index is the array index of the minimum value in the input buffer.
  4674. */
  4675. void arm_min_q7(q7_t * pSrc, uint32_t blockSize, q7_t * result,
  4676. uint32_t * index);
  4677. /**
  4678. * @brief Minimum value of a Q15 vector.
  4679. * @param[in] pSrc is input pointer
  4680. * @param[in] blockSize is the number of samples to process
  4681. * @param[out] pResult is output pointer
  4682. * @param[in] pIndex is the array index of the minimum value in the input buffer.
  4683. */
  4684. void arm_min_q15(q15_t * pSrc, uint32_t blockSize, q15_t * pResult,
  4685. uint32_t * pIndex);
  4686. /**
  4687. * @brief Minimum value of a Q31 vector.
  4688. * @param[in] pSrc is input pointer
  4689. * @param[in] blockSize is the number of samples to process
  4690. * @param[out] pResult is output pointer
  4691. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  4692. */
  4693. void arm_min_q31(q31_t * pSrc, uint32_t blockSize, q31_t * pResult,
  4694. uint32_t * pIndex);
  4695. /**
  4696. * @brief Minimum value of a floating-point vector.
  4697. * @param[in] pSrc is input pointer
  4698. * @param[in] blockSize is the number of samples to process
  4699. * @param[out] pResult is output pointer
  4700. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  4701. */
  4702. void arm_min_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult,
  4703. uint32_t * pIndex);
  4704. /**
  4705. * @brief Maximum value of a Q7 vector.
  4706. * @param[in] pSrc points to the input buffer
  4707. * @param[in] blockSize length of the input vector
  4708. * @param[out] pResult maximum value returned here
  4709. * @param[out] pIndex index of maximum value returned here
  4710. */
  4711. void arm_max_q7(q7_t * pSrc, uint32_t blockSize, q7_t * pResult,
  4712. uint32_t * pIndex);
  4713. /**
  4714. * @brief Maximum value of a Q15 vector.
  4715. * @param[in] pSrc points to the input buffer
  4716. * @param[in] blockSize length of the input vector
  4717. * @param[out] pResult maximum value returned here
  4718. * @param[out] pIndex index of maximum value returned here
  4719. */
  4720. void arm_max_q15(q15_t * pSrc, uint32_t blockSize, q15_t * pResult,
  4721. uint32_t * pIndex);
  4722. /**
  4723. * @brief Maximum value of a Q31 vector.
  4724. * @param[in] pSrc points to the input buffer
  4725. * @param[in] blockSize length of the input vector
  4726. * @param[out] pResult maximum value returned here
  4727. * @param[out] pIndex index of maximum value returned here
  4728. */
  4729. void arm_max_q31(q31_t * pSrc, uint32_t blockSize, q31_t * pResult,
  4730. uint32_t * pIndex);
  4731. /**
  4732. * @brief Maximum value of a floating-point vector.
  4733. * @param[in] pSrc points to the input buffer
  4734. * @param[in] blockSize length of the input vector
  4735. * @param[out] pResult maximum value returned here
  4736. * @param[out] pIndex index of maximum value returned here
  4737. */
  4738. void arm_max_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult,
  4739. uint32_t * pIndex);
  4740. /**
  4741. * @brief Q15 complex-by-complex multiplication
  4742. * @param[in] pSrcA points to the first input vector
  4743. * @param[in] pSrcB points to the second input vector
  4744. * @param[out] pDst points to the output vector
  4745. * @param[in] numSamples number of complex samples in each vector
  4746. */
  4747. void arm_cmplx_mult_cmplx_q15(q15_t * pSrcA, q15_t * pSrcB, q15_t * pDst,
  4748. uint32_t numSamples);
  4749. /**
  4750. * @brief Q31 complex-by-complex multiplication
  4751. * @param[in] pSrcA points to the first input vector
  4752. * @param[in] pSrcB points to the second input vector
  4753. * @param[out] pDst points to the output vector
  4754. * @param[in] numSamples number of complex samples in each vector
  4755. */
  4756. void arm_cmplx_mult_cmplx_q31(q31_t * pSrcA, q31_t * pSrcB, q31_t * pDst,
  4757. uint32_t numSamples);
  4758. /**
  4759. * @brief Floating-point complex-by-complex multiplication
  4760. * @param[in] pSrcA points to the first input vector
  4761. * @param[in] pSrcB points to the second input vector
  4762. * @param[out] pDst points to the output vector
  4763. * @param[in] numSamples number of complex samples in each vector
  4764. */
  4765. void arm_cmplx_mult_cmplx_f32(float32_t * pSrcA, float32_t * pSrcB,
  4766. float32_t * pDst, uint32_t numSamples);
  4767. /**
  4768. * @brief Converts the elements of the floating-point vector to Q31 vector.
  4769. * @param[in] pSrc points to the floating-point input vector
  4770. * @param[out] pDst points to the Q31 output vector
  4771. * @param[in] blockSize length of the input vector
  4772. */
  4773. void arm_float_to_q31(float32_t * pSrc, q31_t * pDst, uint32_t blockSize);
  4774. /**
  4775. * @brief Converts the elements of the floating-point vector to Q15 vector.
  4776. * @param[in] pSrc points to the floating-point input vector
  4777. * @param[out] pDst points to the Q15 output vector
  4778. * @param[in] blockSize length of the input vector
  4779. */
  4780. void arm_float_to_q15(float32_t * pSrc, q15_t * pDst, uint32_t blockSize);
  4781. /**
  4782. * @brief Converts the elements of the floating-point vector to Q7 vector.
  4783. * @param[in] pSrc points to the floating-point input vector
  4784. * @param[out] pDst points to the Q7 output vector
  4785. * @param[in] blockSize length of the input vector
  4786. */
  4787. void arm_float_to_q7(float32_t * pSrc, q7_t * pDst, uint32_t blockSize);
  4788. /**
  4789. * @brief Converts the elements of the Q31 vector to Q15 vector.
  4790. * @param[in] pSrc is input pointer
  4791. * @param[out] pDst is output pointer
  4792. * @param[in] blockSize is the number of samples to process
  4793. */
  4794. void arm_q31_to_q15(q31_t * pSrc, q15_t * pDst, uint32_t blockSize);
  4795. /**
  4796. * @brief Converts the elements of the Q31 vector to Q7 vector.
  4797. * @param[in] pSrc is input pointer
  4798. * @param[out] pDst is output pointer
  4799. * @param[in] blockSize is the number of samples to process
  4800. */
  4801. void arm_q31_to_q7(q31_t * pSrc, q7_t * pDst, uint32_t blockSize);
  4802. /**
  4803. * @brief Converts the elements of the Q15 vector to floating-point vector.
  4804. * @param[in] pSrc is input pointer
  4805. * @param[out] pDst is output pointer
  4806. * @param[in] blockSize is the number of samples to process
  4807. */
  4808. void arm_q15_to_float(q15_t * pSrc, float32_t * pDst, uint32_t blockSize);
  4809. /**
  4810. * @brief Converts the elements of the Q15 vector to Q31 vector.
  4811. * @param[in] pSrc is input pointer
  4812. * @param[out] pDst is output pointer
  4813. * @param[in] blockSize is the number of samples to process
  4814. */
  4815. void arm_q15_to_q31(q15_t * pSrc, q31_t * pDst, uint32_t blockSize);
  4816. /**
  4817. * @brief Converts the elements of the Q15 vector to Q7 vector.
  4818. * @param[in] pSrc is input pointer
  4819. * @param[out] pDst is output pointer
  4820. * @param[in] blockSize is the number of samples to process
  4821. */
  4822. void arm_q15_to_q7(q15_t * pSrc, q7_t * pDst, uint32_t blockSize);
  4823. /**
  4824. * @ingroup groupInterpolation
  4825. */
  4826. /**
  4827. * @defgroup BilinearInterpolate Bilinear Interpolation
  4828. *
  4829. * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
  4830. * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
  4831. * determines values between the grid points.
  4832. * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
  4833. * Bilinear interpolation is often used in image processing to rescale images.
  4834. * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
  4835. *
  4836. * <b>Algorithm</b>
  4837. * \par
  4838. * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
  4839. * For floating-point, the instance structure is defined as:
  4840. * <pre>
  4841. * typedef struct
  4842. * {
  4843. * uint16_t numRows;
  4844. * uint16_t numCols;
  4845. * float32_t *pData;
  4846. * } arm_bilinear_interp_instance_f32;
  4847. * </pre>
  4848. *
  4849. * \par
  4850. * where <code>numRows</code> specifies the number of rows in the table;
  4851. * <code>numCols</code> specifies the number of columns in the table;
  4852. * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
  4853. * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
  4854. * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
  4855. *
  4856. * \par
  4857. * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
  4858. * <pre>
  4859. * XF = floor(x)
  4860. * YF = floor(y)
  4861. * </pre>
  4862. * \par
  4863. * The interpolated output point is computed as:
  4864. * <pre>
  4865. * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
  4866. * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
  4867. * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
  4868. * + f(XF+1, YF+1) * (x-XF)*(y-YF)
  4869. * </pre>
  4870. * Note that the coordinates (x, y) contain integer and fractional components.
  4871. * The integer components specify which portion of the table to use while the
  4872. * fractional components control the interpolation processor.
  4873. *
  4874. * \par
  4875. * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
  4876. */
  4877. /**
  4878. * @addtogroup BilinearInterpolate
  4879. * @{
  4880. */
  4881. /**
  4882. *
  4883. * @brief Floating-point bilinear interpolation.
  4884. * @param[in,out] S points to an instance of the interpolation structure.
  4885. * @param[in] X interpolation coordinate.
  4886. * @param[in] Y interpolation coordinate.
  4887. * @return out interpolated value.
  4888. */
  4889. static __INLINE float32_t arm_bilinear_interp_f32(
  4890. const arm_bilinear_interp_instance_f32 * S,
  4891. float32_t X,
  4892. float32_t Y)
  4893. {
  4894. float32_t out;
  4895. float32_t f00, f01, f10, f11;
  4896. float32_t *pData = S->pData;
  4897. int32_t xIndex, yIndex, index;
  4898. float32_t xdiff, ydiff;
  4899. float32_t b1, b2, b3, b4;
  4900. xIndex = (int32_t) X;
  4901. yIndex = (int32_t) Y;
  4902. /* Care taken for table outside boundary */
  4903. /* Returns zero output when values are outside table boundary */
  4904. if(xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1))
  4905. {
  4906. return (0);
  4907. }
  4908. /* Calculation of index for two nearest points in X-direction */
  4909. index = (xIndex - 1) + (yIndex - 1) * S->numCols;
  4910. /* Read two nearest points in X-direction */
  4911. f00 = pData[index];
  4912. f01 = pData[index + 1];
  4913. /* Calculation of index for two nearest points in Y-direction */
  4914. index = (xIndex - 1) + (yIndex) * S->numCols;
  4915. /* Read two nearest points in Y-direction */
  4916. f10 = pData[index];
  4917. f11 = pData[index + 1];
  4918. /* Calculation of intermediate values */
  4919. b1 = f00;
  4920. b2 = f01 - f00;
  4921. b3 = f10 - f00;
  4922. b4 = f00 - f01 - f10 + f11;
  4923. /* Calculation of fractional part in X */
  4924. xdiff = X - xIndex;
  4925. /* Calculation of fractional part in Y */
  4926. ydiff = Y - yIndex;
  4927. /* Calculation of bi-linear interpolated output */
  4928. out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
  4929. /* return to application */
  4930. return (out);
  4931. }
  4932. /**
  4933. *
  4934. * @brief Q31 bilinear interpolation.
  4935. * @param[in,out] S points to an instance of the interpolation structure.
  4936. * @param[in] X interpolation coordinate in 12.20 format.
  4937. * @param[in] Y interpolation coordinate in 12.20 format.
  4938. * @return out interpolated value.
  4939. */
  4940. static __INLINE q31_t arm_bilinear_interp_q31(
  4941. arm_bilinear_interp_instance_q31 * S,
  4942. q31_t X,
  4943. q31_t Y)
  4944. {
  4945. q31_t out; /* Temporary output */
  4946. q31_t acc = 0; /* output */
  4947. q31_t xfract, yfract; /* X, Y fractional parts */
  4948. q31_t x1, x2, y1, y2; /* Nearest output values */
  4949. int32_t rI, cI; /* Row and column indices */
  4950. q31_t *pYData = S->pData; /* pointer to output table values */
  4951. uint32_t nCols = S->numCols; /* num of rows */
  4952. /* Input is in 12.20 format */
  4953. /* 12 bits for the table index */
  4954. /* Index value calculation */
  4955. rI = ((X & (q31_t)0xFFF00000) >> 20);
  4956. /* Input is in 12.20 format */
  4957. /* 12 bits for the table index */
  4958. /* Index value calculation */
  4959. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  4960. /* Care taken for table outside boundary */
  4961. /* Returns zero output when values are outside table boundary */
  4962. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  4963. {
  4964. return (0);
  4965. }
  4966. /* 20 bits for the fractional part */
  4967. /* shift left xfract by 11 to keep 1.31 format */
  4968. xfract = (X & 0x000FFFFF) << 11u;
  4969. /* Read two nearest output values from the index */
  4970. x1 = pYData[(rI) + (int32_t)nCols * (cI) ];
  4971. x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1];
  4972. /* 20 bits for the fractional part */
  4973. /* shift left yfract by 11 to keep 1.31 format */
  4974. yfract = (Y & 0x000FFFFF) << 11u;
  4975. /* Read two nearest output values from the index */
  4976. y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ];
  4977. y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1];
  4978. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
  4979. out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
  4980. acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
  4981. /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
  4982. out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
  4983. acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
  4984. /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
  4985. out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
  4986. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  4987. /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
  4988. out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
  4989. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  4990. /* Convert acc to 1.31(q31) format */
  4991. return ((q31_t)(acc << 2));
  4992. }
  4993. /**
  4994. * @brief Q15 bilinear interpolation.
  4995. * @param[in,out] S points to an instance of the interpolation structure.
  4996. * @param[in] X interpolation coordinate in 12.20 format.
  4997. * @param[in] Y interpolation coordinate in 12.20 format.
  4998. * @return out interpolated value.
  4999. */
  5000. static __INLINE q15_t arm_bilinear_interp_q15(
  5001. arm_bilinear_interp_instance_q15 * S,
  5002. q31_t X,
  5003. q31_t Y)
  5004. {
  5005. q63_t acc = 0; /* output */
  5006. q31_t out; /* Temporary output */
  5007. q15_t x1, x2, y1, y2; /* Nearest output values */
  5008. q31_t xfract, yfract; /* X, Y fractional parts */
  5009. int32_t rI, cI; /* Row and column indices */
  5010. q15_t *pYData = S->pData; /* pointer to output table values */
  5011. uint32_t nCols = S->numCols; /* num of rows */
  5012. /* Input is in 12.20 format */
  5013. /* 12 bits for the table index */
  5014. /* Index value calculation */
  5015. rI = ((X & (q31_t)0xFFF00000) >> 20);
  5016. /* Input is in 12.20 format */
  5017. /* 12 bits for the table index */
  5018. /* Index value calculation */
  5019. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  5020. /* Care taken for table outside boundary */
  5021. /* Returns zero output when values are outside table boundary */
  5022. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  5023. {
  5024. return (0);
  5025. }
  5026. /* 20 bits for the fractional part */
  5027. /* xfract should be in 12.20 format */
  5028. xfract = (X & 0x000FFFFF);
  5029. /* Read two nearest output values from the index */
  5030. x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
  5031. x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
  5032. /* 20 bits for the fractional part */
  5033. /* yfract should be in 12.20 format */
  5034. yfract = (Y & 0x000FFFFF);
  5035. /* Read two nearest output values from the index */
  5036. y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
  5037. y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
  5038. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
  5039. /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
  5040. /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
  5041. out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);
  5042. acc = ((q63_t) out * (0xFFFFF - yfract));
  5043. /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
  5044. out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);
  5045. acc += ((q63_t) out * (xfract));
  5046. /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
  5047. out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);
  5048. acc += ((q63_t) out * (yfract));
  5049. /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
  5050. out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u);
  5051. acc += ((q63_t) out * (yfract));
  5052. /* acc is in 13.51 format and down shift acc by 36 times */
  5053. /* Convert out to 1.15 format */
  5054. return ((q15_t)(acc >> 36));
  5055. }
  5056. /**
  5057. * @brief Q7 bilinear interpolation.
  5058. * @param[in,out] S points to an instance of the interpolation structure.
  5059. * @param[in] X interpolation coordinate in 12.20 format.
  5060. * @param[in] Y interpolation coordinate in 12.20 format.
  5061. * @return out interpolated value.
  5062. */
  5063. static __INLINE q7_t arm_bilinear_interp_q7(
  5064. arm_bilinear_interp_instance_q7 * S,
  5065. q31_t X,
  5066. q31_t Y)
  5067. {
  5068. q63_t acc = 0; /* output */
  5069. q31_t out; /* Temporary output */
  5070. q31_t xfract, yfract; /* X, Y fractional parts */
  5071. q7_t x1, x2, y1, y2; /* Nearest output values */
  5072. int32_t rI, cI; /* Row and column indices */
  5073. q7_t *pYData = S->pData; /* pointer to output table values */
  5074. uint32_t nCols = S->numCols; /* num of rows */
  5075. /* Input is in 12.20 format */
  5076. /* 12 bits for the table index */
  5077. /* Index value calculation */
  5078. rI = ((X & (q31_t)0xFFF00000) >> 20);
  5079. /* Input is in 12.20 format */
  5080. /* 12 bits for the table index */
  5081. /* Index value calculation */
  5082. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  5083. /* Care taken for table outside boundary */
  5084. /* Returns zero output when values are outside table boundary */
  5085. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  5086. {
  5087. return (0);
  5088. }
  5089. /* 20 bits for the fractional part */
  5090. /* xfract should be in 12.20 format */
  5091. xfract = (X & (q31_t)0x000FFFFF);
  5092. /* Read two nearest output values from the index */
  5093. x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
  5094. x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
  5095. /* 20 bits for the fractional part */
  5096. /* yfract should be in 12.20 format */
  5097. yfract = (Y & (q31_t)0x000FFFFF);
  5098. /* Read two nearest output values from the index */
  5099. y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
  5100. y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
  5101. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
  5102. out = ((x1 * (0xFFFFF - xfract)));
  5103. acc = (((q63_t) out * (0xFFFFF - yfract)));
  5104. /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
  5105. out = ((x2 * (0xFFFFF - yfract)));
  5106. acc += (((q63_t) out * (xfract)));
  5107. /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
  5108. out = ((y1 * (0xFFFFF - xfract)));
  5109. acc += (((q63_t) out * (yfract)));
  5110. /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
  5111. out = ((y2 * (yfract)));
  5112. acc += (((q63_t) out * (xfract)));
  5113. /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
  5114. return ((q7_t)(acc >> 40));
  5115. }
  5116. /**
  5117. * @} end of BilinearInterpolate group
  5118. */
  5119. /* SMMLAR */
  5120. #define multAcc_32x32_keep32_R(a, x, y) \
  5121. a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
  5122. /* SMMLSR */
  5123. #define multSub_32x32_keep32_R(a, x, y) \
  5124. a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
  5125. /* SMMULR */
  5126. #define mult_32x32_keep32_R(a, x, y) \
  5127. a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
  5128. /* SMMLA */
  5129. #define multAcc_32x32_keep32(a, x, y) \
  5130. a += (q31_t) (((q63_t) x * y) >> 32)
  5131. /* SMMLS */
  5132. #define multSub_32x32_keep32(a, x, y) \
  5133. a -= (q31_t) (((q63_t) x * y) >> 32)
  5134. /* SMMUL */
  5135. #define mult_32x32_keep32(a, x, y) \
  5136. a = (q31_t) (((q63_t) x * y ) >> 32)
  5137. #if defined ( __CC_ARM )
  5138. /* Enter low optimization region - place directly above function definition */
  5139. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  5140. #define LOW_OPTIMIZATION_ENTER \
  5141. _Pragma ("push") \
  5142. _Pragma ("O1")
  5143. #else
  5144. #define LOW_OPTIMIZATION_ENTER
  5145. #endif
  5146. /* Exit low optimization region - place directly after end of function definition */
  5147. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  5148. #define LOW_OPTIMIZATION_EXIT \
  5149. _Pragma ("pop")
  5150. #else
  5151. #define LOW_OPTIMIZATION_EXIT
  5152. #endif
  5153. /* Enter low optimization region - place directly above function definition */
  5154. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  5155. /* Exit low optimization region - place directly after end of function definition */
  5156. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  5157. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  5158. #define LOW_OPTIMIZATION_ENTER
  5159. #define LOW_OPTIMIZATION_EXIT
  5160. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  5161. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  5162. #elif defined(__GNUC__)
  5163. #define LOW_OPTIMIZATION_ENTER __attribute__(( optimize("-O1") ))
  5164. #define LOW_OPTIMIZATION_EXIT
  5165. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  5166. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  5167. #elif defined(__ICCARM__)
  5168. /* Enter low optimization region - place directly above function definition */
  5169. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  5170. #define LOW_OPTIMIZATION_ENTER \
  5171. _Pragma ("optimize=low")
  5172. #else
  5173. #define LOW_OPTIMIZATION_ENTER
  5174. #endif
  5175. /* Exit low optimization region - place directly after end of function definition */
  5176. #define LOW_OPTIMIZATION_EXIT
  5177. /* Enter low optimization region - place directly above function definition */
  5178. #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
  5179. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
  5180. _Pragma ("optimize=low")
  5181. #else
  5182. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  5183. #endif
  5184. /* Exit low optimization region - place directly after end of function definition */
  5185. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  5186. #elif defined(__CSMC__)
  5187. #define LOW_OPTIMIZATION_ENTER
  5188. #define LOW_OPTIMIZATION_EXIT
  5189. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  5190. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  5191. #elif defined(__TASKING__)
  5192. #define LOW_OPTIMIZATION_ENTER
  5193. #define LOW_OPTIMIZATION_EXIT
  5194. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  5195. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  5196. #endif
  5197. #ifdef __cplusplus
  5198. }
  5199. #endif
  5200. #if defined ( __GNUC__ )
  5201. #pragma GCC diagnostic pop
  5202. #endif
  5203. #endif /* _ARM_MATH_H */
  5204. /**
  5205. *
  5206. * End of file.
  5207. */