arm_math.h 306 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177
  1. /******************************************************************************
  2. * @file arm_math.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.7.0
  5. * @date 18. March 2019
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2010-2019 Arm Limited or its affiliates. All rights reserved.
  9. *
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the License); you may
  13. * not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  20. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. /**
  25. \mainpage CMSIS DSP Software Library
  26. *
  27. * \section intro Introduction
  28. *
  29. * This user manual describes the CMSIS DSP software library,
  30. * a suite of common signal processing functions for use on Cortex-M and Cortex-A processor
  31. * based devices.
  32. *
  33. * The library is divided into a number of functions each covering a specific category:
  34. * - Basic math functions
  35. * - Fast math functions
  36. * - Complex math functions
  37. * - Filtering functions
  38. * - Matrix functions
  39. * - Transform functions
  40. * - Motor control functions
  41. * - Statistical functions
  42. * - Support functions
  43. * - Interpolation functions
  44. * - Support Vector Machine functions (SVM)
  45. * - Bayes classifier functions
  46. * - Distance functions
  47. *
  48. * The library has generally separate functions for operating on 8-bit integers, 16-bit integers,
  49. * 32-bit integer and 32-bit floating-point values.
  50. *
  51. * \section using Using the Library
  52. *
  53. * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
  54. *
  55. * Here is the list of pre-built libraries :
  56. * - arm_cortexM7lfdp_math.lib (Cortex-M7, Little endian, Double Precision Floating Point Unit)
  57. * - arm_cortexM7bfdp_math.lib (Cortex-M7, Big endian, Double Precision Floating Point Unit)
  58. * - arm_cortexM7lfsp_math.lib (Cortex-M7, Little endian, Single Precision Floating Point Unit)
  59. * - arm_cortexM7bfsp_math.lib (Cortex-M7, Big endian and Single Precision Floating Point Unit on)
  60. * - arm_cortexM7l_math.lib (Cortex-M7, Little endian)
  61. * - arm_cortexM7b_math.lib (Cortex-M7, Big endian)
  62. * - arm_cortexM4lf_math.lib (Cortex-M4, Little endian, Floating Point Unit)
  63. * - arm_cortexM4bf_math.lib (Cortex-M4, Big endian, Floating Point Unit)
  64. * - arm_cortexM4l_math.lib (Cortex-M4, Little endian)
  65. * - arm_cortexM4b_math.lib (Cortex-M4, Big endian)
  66. * - arm_cortexM3l_math.lib (Cortex-M3, Little endian)
  67. * - arm_cortexM3b_math.lib (Cortex-M3, Big endian)
  68. * - arm_cortexM0l_math.lib (Cortex-M0 / Cortex-M0+, Little endian)
  69. * - arm_cortexM0b_math.lib (Cortex-M0 / Cortex-M0+, Big endian)
  70. * - arm_ARMv8MBLl_math.lib (Armv8-M Baseline, Little endian)
  71. * - arm_ARMv8MMLl_math.lib (Armv8-M Mainline, Little endian)
  72. * - arm_ARMv8MMLlfsp_math.lib (Armv8-M Mainline, Little endian, Single Precision Floating Point Unit)
  73. * - arm_ARMv8MMLld_math.lib (Armv8-M Mainline, Little endian, DSP instructions)
  74. * - arm_ARMv8MMLldfsp_math.lib (Armv8-M Mainline, Little endian, DSP instructions, Single Precision Floating Point Unit)
  75. *
  76. * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
  77. * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
  78. * public header file <code> arm_math.h</code> for Cortex-M cores with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
  79. *
  80. *
  81. * \section example Examples
  82. *
  83. * The library ships with a number of examples which demonstrate how to use the library functions.
  84. *
  85. * \section toolchain Toolchain Support
  86. *
  87. * The library is now tested on Fast Models building with cmake.
  88. * Core M0, M7, A5 are tested.
  89. *
  90. *
  91. *
  92. * \section building Building the Library
  93. *
  94. * The library installer contains a project file to rebuild libraries on MDK toolchain in the <code>CMSIS\\DSP\\Projects\\ARM</code> folder.
  95. * - arm_cortexM_math.uvprojx
  96. *
  97. *
  98. * The libraries can be built by opening the arm_cortexM_math.uvprojx project in MDK-ARM, selecting a specific target, and defining the optional preprocessor macros detailed above.
  99. *
  100. * There is also a work in progress cmake build. The README file is giving more details.
  101. *
  102. * \section preprocessor Preprocessor Macros
  103. *
  104. * Each library project have different preprocessor macros.
  105. *
  106. * - ARM_MATH_BIG_ENDIAN:
  107. *
  108. * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
  109. *
  110. * - ARM_MATH_MATRIX_CHECK:
  111. *
  112. * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
  113. *
  114. * - ARM_MATH_ROUNDING:
  115. *
  116. * Define macro ARM_MATH_ROUNDING for rounding on support functions
  117. *
  118. * - ARM_MATH_LOOPUNROLL:
  119. *
  120. * Define macro ARM_MATH_LOOPUNROLL to enable manual loop unrolling in DSP functions
  121. *
  122. * - ARM_MATH_NEON:
  123. *
  124. * Define macro ARM_MATH_NEON to enable Neon versions of the DSP functions.
  125. * It is not enabled by default when Neon is available because performances are
  126. * dependent on the compiler and target architecture.
  127. *
  128. * - ARM_MATH_NEON_EXPERIMENTAL:
  129. *
  130. * Define macro ARM_MATH_NEON_EXPERIMENTAL to enable experimental Neon versions of
  131. * of some DSP functions. Experimental Neon versions currently do not have better
  132. * performances than the scalar versions.
  133. *
  134. * - ARM_MATH_HELIUM:
  135. *
  136. * It implies the flags ARM_MATH_MVEF and ARM_MATH_MVEI and ARM_MATH_FLOAT16.
  137. *
  138. * - ARM_MATH_MVEF:
  139. *
  140. * Select Helium versions of the f32 algorithms.
  141. * It implies ARM_MATH_FLOAT16 and ARM_MATH_MVEI.
  142. *
  143. * - ARM_MATH_MVEI:
  144. *
  145. * Select Helium versions of the int and fixed point algorithms.
  146. *
  147. * - ARM_MATH_FLOAT16:
  148. *
  149. * Float16 implementations of some algorithms (Requires MVE extension).
  150. *
  151. * <hr>
  152. * \section pack CMSIS-DSP in ARM::CMSIS Pack
  153. *
  154. * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories:
  155. * |File/Folder |Content |
  156. * |---------------------------------|------------------------------------------------------------------------|
  157. * |\b CMSIS\\Documentation\\DSP | This documentation |
  158. * |\b CMSIS\\DSP\\DSP_Lib_TestSuite | DSP_Lib test suite |
  159. * |\b CMSIS\\DSP\\Examples | Example projects demonstrating the usage of the library functions |
  160. * |\b CMSIS\\DSP\\Include | DSP_Lib include files |
  161. * |\b CMSIS\\DSP\\Lib | DSP_Lib binaries |
  162. * |\b CMSIS\\DSP\\Projects | Projects to rebuild DSP_Lib binaries |
  163. * |\b CMSIS\\DSP\\Source | DSP_Lib source files |
  164. *
  165. * <hr>
  166. * \section rev Revision History of CMSIS-DSP
  167. * Please refer to \ref ChangeLog_pg.
  168. */
  169. /**
  170. * @defgroup groupMath Basic Math Functions
  171. */
  172. /**
  173. * @defgroup groupFastMath Fast Math Functions
  174. * This set of functions provides a fast approximation to sine, cosine, and square root.
  175. * As compared to most of the other functions in the CMSIS math library, the fast math functions
  176. * operate on individual values and not arrays.
  177. * There are separate functions for Q15, Q31, and floating-point data.
  178. *
  179. */
  180. /**
  181. * @defgroup groupCmplxMath Complex Math Functions
  182. * This set of functions operates on complex data vectors.
  183. * The data in the complex arrays is stored in an interleaved fashion
  184. * (real, imag, real, imag, ...).
  185. * In the API functions, the number of samples in a complex array refers
  186. * to the number of complex values; the array contains twice this number of
  187. * real values.
  188. */
  189. /**
  190. * @defgroup groupFilters Filtering Functions
  191. */
  192. /**
  193. * @defgroup groupMatrix Matrix Functions
  194. *
  195. * This set of functions provides basic matrix math operations.
  196. * The functions operate on matrix data structures. For example,
  197. * the type
  198. * definition for the floating-point matrix structure is shown
  199. * below:
  200. * <pre>
  201. * typedef struct
  202. * {
  203. * uint16_t numRows; // number of rows of the matrix.
  204. * uint16_t numCols; // number of columns of the matrix.
  205. * float32_t *pData; // points to the data of the matrix.
  206. * } arm_matrix_instance_f32;
  207. * </pre>
  208. * There are similar definitions for Q15 and Q31 data types.
  209. *
  210. * The structure specifies the size of the matrix and then points to
  211. * an array of data. The array is of size <code>numRows X numCols</code>
  212. * and the values are arranged in row order. That is, the
  213. * matrix element (i, j) is stored at:
  214. * <pre>
  215. * pData[i*numCols + j]
  216. * </pre>
  217. *
  218. * \par Init Functions
  219. * There is an associated initialization function for each type of matrix
  220. * data structure.
  221. * The initialization function sets the values of the internal structure fields.
  222. * Refer to \ref arm_mat_init_f32(), \ref arm_mat_init_q31() and \ref arm_mat_init_q15()
  223. * for floating-point, Q31 and Q15 types, respectively.
  224. *
  225. * \par
  226. * Use of the initialization function is optional. However, if initialization function is used
  227. * then the instance structure cannot be placed into a const data section.
  228. * To place the instance structure in a const data
  229. * section, manually initialize the data structure. For example:
  230. * <pre>
  231. * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
  232. * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
  233. * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
  234. * </pre>
  235. * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
  236. * specifies the number of columns, and <code>pData</code> points to the
  237. * data array.
  238. *
  239. * \par Size Checking
  240. * By default all of the matrix functions perform size checking on the input and
  241. * output matrices. For example, the matrix addition function verifies that the
  242. * two input matrices and the output matrix all have the same number of rows and
  243. * columns. If the size check fails the functions return:
  244. * <pre>
  245. * ARM_MATH_SIZE_MISMATCH
  246. * </pre>
  247. * Otherwise the functions return
  248. * <pre>
  249. * ARM_MATH_SUCCESS
  250. * </pre>
  251. * There is some overhead associated with this matrix size checking.
  252. * The matrix size checking is enabled via the \#define
  253. * <pre>
  254. * ARM_MATH_MATRIX_CHECK
  255. * </pre>
  256. * within the library project settings. By default this macro is defined
  257. * and size checking is enabled. By changing the project settings and
  258. * undefining this macro size checking is eliminated and the functions
  259. * run a bit faster. With size checking disabled the functions always
  260. * return <code>ARM_MATH_SUCCESS</code>.
  261. */
  262. /**
  263. * @defgroup groupTransforms Transform Functions
  264. */
  265. /**
  266. * @defgroup groupController Controller Functions
  267. */
  268. /**
  269. * @defgroup groupStats Statistics Functions
  270. */
  271. /**
  272. * @defgroup groupSupport Support Functions
  273. */
  274. /**
  275. * @defgroup groupInterpolation Interpolation Functions
  276. * These functions perform 1- and 2-dimensional interpolation of data.
  277. * Linear interpolation is used for 1-dimensional data and
  278. * bilinear interpolation is used for 2-dimensional data.
  279. */
  280. /**
  281. * @defgroup groupExamples Examples
  282. */
  283. /**
  284. * @defgroup groupSVM SVM Functions
  285. * This set of functions is implementing SVM classification on 2 classes.
  286. * The training must be done from scikit-learn. The parameters can be easily
  287. * generated from the scikit-learn object. Some examples are given in
  288. * DSP/Testing/PatternGeneration/SVM.py
  289. *
  290. * If more than 2 classes are needed, the functions in this folder
  291. * will have to be used, as building blocks, to do multi-class classification.
  292. *
  293. * No multi-class classification is provided in this SVM folder.
  294. *
  295. */
  296. /**
  297. * @defgroup groupBayes Bayesian estimators
  298. *
  299. * Implement the naive gaussian Bayes estimator.
  300. * The training must be done from scikit-learn.
  301. *
  302. * The parameters can be easily
  303. * generated from the scikit-learn object. Some examples are given in
  304. * DSP/Testing/PatternGeneration/Bayes.py
  305. */
  306. /**
  307. * @defgroup groupDistance Distance functions
  308. *
  309. * Distance functions for use with clustering algorithms.
  310. * There are distance functions for float vectors and boolean vectors.
  311. *
  312. */
  313. #ifndef _ARM_MATH_H
  314. #define _ARM_MATH_H
  315. #ifdef __cplusplus
  316. extern "C"
  317. {
  318. #endif
  319. /* Compiler specific diagnostic adjustment */
  320. #if defined ( __CC_ARM )
  321. #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
  322. #elif defined ( __GNUC__ )
  323. #pragma GCC diagnostic push
  324. #pragma GCC diagnostic ignored "-Wsign-conversion"
  325. #pragma GCC diagnostic ignored "-Wconversion"
  326. #pragma GCC diagnostic ignored "-Wunused-parameter"
  327. #elif defined ( __ICCARM__ )
  328. #elif defined ( __TI_ARM__ )
  329. #elif defined ( __CSMC__ )
  330. #elif defined ( __TASKING__ )
  331. #elif defined ( _MSC_VER )
  332. #else
  333. #error Unknown compiler
  334. #endif
  335. /* Included for instrinsics definitions */
  336. #if defined (_MSC_VER )
  337. #include <stdint.h>
  338. #define __STATIC_FORCEINLINE static __forceinline
  339. #define __STATIC_INLINE static __inline
  340. #define __ALIGNED(x) __declspec(align(x))
  341. #elif defined (__GNUC_PYTHON__)
  342. #include <stdint.h>
  343. #define __ALIGNED(x) __attribute__((aligned(x)))
  344. #define __STATIC_FORCEINLINE static __attribute__((inline))
  345. #define __STATIC_INLINE static __attribute__((inline))
  346. #pragma GCC diagnostic ignored "-Wunused-function"
  347. #pragma GCC diagnostic ignored "-Wattributes"
  348. #else
  349. #include "cmsis_compiler.h"
  350. #endif
  351. #include <string.h>
  352. #include <math.h>
  353. #include <float.h>
  354. #include <limits.h>
  355. /* evaluate ARM DSP feature */
  356. #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
  357. #define ARM_MATH_DSP 1
  358. #endif
  359. #if defined(ARM_MATH_NEON)
  360. #include <arm_neon.h>
  361. #endif
  362. #if !defined(ARM_MATH_AUTOVECTORIZE)
  363. #if __ARM_FEATURE_MVE
  364. #if !defined(ARM_MATH_MVEI)
  365. #define ARM_MATH_MVEI
  366. #endif
  367. #endif
  368. #if (__ARM_FEATURE_MVE & 2)
  369. #if !defined(ARM_MATH_MVEF)
  370. #define ARM_MATH_MVEF
  371. #endif
  372. #if !defined(ARM_MATH_FLOAT16)
  373. #define ARM_MATH_FLOAT16
  374. #endif
  375. #endif
  376. #endif /*!defined(ARM_MATH_AUTOVECTORIZE)*/
  377. #if defined (ARM_MATH_HELIUM)
  378. #if !defined(ARM_MATH_MVEF)
  379. #define ARM_MATH_MVEF
  380. #endif
  381. #if !defined(ARM_MATH_MVEI)
  382. #define ARM_MATH_MVEI
  383. #endif
  384. #if !defined(ARM_MATH_FLOAT16)
  385. #define ARM_MATH_FLOAT16
  386. #endif
  387. #endif
  388. #if defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) || defined(ARM_MATH_MVEI)
  389. #include <arm_mve.h>
  390. #endif
  391. /**
  392. * @brief 8-bit fractional data type in 1.7 format.
  393. */
  394. typedef int8_t q7_t;
  395. /**
  396. * @brief 16-bit fractional data type in 1.15 format.
  397. */
  398. typedef int16_t q15_t;
  399. /**
  400. * @brief 32-bit fractional data type in 1.31 format.
  401. */
  402. typedef int32_t q31_t;
  403. /**
  404. * @brief 64-bit fractional data type in 1.63 format.
  405. */
  406. typedef int64_t q63_t;
  407. /**
  408. * @brief 16-bit floating-point type definition.
  409. * This is already defined in arm_mve.h
  410. *
  411. * This is not fully supported on ARM AC5.
  412. */
  413. #if !defined( __CC_ARM ) && !(__ARM_FEATURE_MVE & 2)
  414. typedef __fp16 float16_t;
  415. #endif
  416. /**
  417. * @brief 32-bit floating-point type definition.
  418. */
  419. typedef float float32_t;
  420. /**
  421. * @brief 64-bit floating-point type definition.
  422. */
  423. typedef double float64_t;
  424. /**
  425. * @brief vector types
  426. */
  427. #if defined(ARM_MATH_NEON) || defined (ARM_MATH_MVEI)
  428. /**
  429. * @brief 64-bit fractional 128-bit vector data type in 1.63 format
  430. */
  431. typedef int64x2_t q63x2_t;
  432. /**
  433. * @brief 32-bit fractional 128-bit vector data type in 1.31 format.
  434. */
  435. typedef int32x4_t q31x4_t;
  436. /**
  437. * @brief 16-bit fractional 128-bit vector data type with 16-bit alignement in 1.15 format.
  438. */
  439. typedef __ALIGNED(2) int16x8_t q15x8_t;
  440. /**
  441. * @brief 8-bit fractional 128-bit vector data type with 8-bit alignement in 1.7 format.
  442. */
  443. typedef __ALIGNED(1) int8x16_t q7x16_t;
  444. /**
  445. * @brief 32-bit fractional 128-bit vector pair data type in 1.31 format.
  446. */
  447. typedef int32x4x2_t q31x4x2_t;
  448. /**
  449. * @brief 32-bit fractional 128-bit vector quadruplet data type in 1.31 format.
  450. */
  451. typedef int32x4x4_t q31x4x4_t;
  452. /**
  453. * @brief 16-bit fractional 128-bit vector pair data type in 1.15 format.
  454. */
  455. typedef int16x8x2_t q15x8x2_t;
  456. /**
  457. * @brief 16-bit fractional 128-bit vector quadruplet data type in 1.15 format.
  458. */
  459. typedef int16x8x4_t q15x8x4_t;
  460. /**
  461. * @brief 8-bit fractional 128-bit vector pair data type in 1.7 format.
  462. */
  463. typedef int8x16x2_t q7x16x2_t;
  464. /**
  465. * @brief 8-bit fractional 128-bit vector quadruplet data type in 1.7 format.
  466. */
  467. typedef int8x16x4_t q7x16x4_t;
  468. /**
  469. * @brief 32-bit fractional data type in 9.23 format.
  470. */
  471. typedef int32_t q23_t;
  472. /**
  473. * @brief 32-bit fractional 128-bit vector data type in 9.23 format.
  474. */
  475. typedef int32x4_t q23x4_t;
  476. /**
  477. * @brief 64-bit status 128-bit vector data type.
  478. */
  479. typedef int64x2_t status64x2_t;
  480. /**
  481. * @brief 32-bit status 128-bit vector data type.
  482. */
  483. typedef int32x4_t status32x4_t;
  484. /**
  485. * @brief 16-bit status 128-bit vector data type.
  486. */
  487. typedef int16x8_t status16x8_t;
  488. /**
  489. * @brief 8-bit status 128-bit vector data type.
  490. */
  491. typedef int8x16_t status8x16_t;
  492. #endif
  493. #if defined(ARM_MATH_NEON) || defined(ARM_MATH_MVEF) /* floating point vector*/
  494. /**
  495. * @brief 32-bit floating-point 128-bit vector type
  496. */
  497. typedef float32x4_t f32x4_t;
  498. #if defined(ARM_MATH_FLOAT16)
  499. /**
  500. * @brief 16-bit floating-point 128-bit vector data type
  501. */
  502. typedef __ALIGNED(2) float16x8_t f16x8_t;
  503. #endif
  504. /**
  505. * @brief 32-bit floating-point 128-bit vector pair data type
  506. */
  507. typedef float32x4x2_t f32x4x2_t;
  508. /**
  509. * @brief 32-bit floating-point 128-bit vector quadruplet data type
  510. */
  511. typedef float32x4x4_t f32x4x4_t;
  512. #if defined(ARM_MATH_FLOAT16)
  513. /**
  514. * @brief 16-bit floating-point 128-bit vector pair data type
  515. */
  516. typedef float16x8x2_t f16x8x2_t;
  517. /**
  518. * @brief 16-bit floating-point 128-bit vector quadruplet data type
  519. */
  520. typedef float16x8x4_t f16x8x4_t;
  521. #endif
  522. /**
  523. * @brief 32-bit ubiquitous 128-bit vector data type
  524. */
  525. typedef union _any32x4_t
  526. {
  527. float32x4_t f;
  528. int32x4_t i;
  529. } any32x4_t;
  530. #if defined(ARM_MATH_FLOAT16)
  531. /**
  532. * @brief 16-bit ubiquitous 128-bit vector data type
  533. */
  534. typedef union _any16x8_t
  535. {
  536. float16x8_t f;
  537. int16x8_t i;
  538. } any16x8_t;
  539. #endif
  540. #endif
  541. #if defined(ARM_MATH_NEON)
  542. /**
  543. * @brief 32-bit fractional 64-bit vector data type in 1.31 format.
  544. */
  545. typedef int32x2_t q31x2_t;
  546. /**
  547. * @brief 16-bit fractional 64-bit vector data type in 1.15 format.
  548. */
  549. typedef __ALIGNED(2) int16x4_t q15x4_t;
  550. /**
  551. * @brief 8-bit fractional 64-bit vector data type in 1.7 format.
  552. */
  553. typedef __ALIGNED(1) int8x8_t q7x8_t;
  554. /**
  555. * @brief 32-bit float 64-bit vector data type.
  556. */
  557. typedef float32x2_t f32x2_t;
  558. #if defined(ARM_MATH_FLOAT16)
  559. /**
  560. * @brief 16-bit float 64-bit vector data type.
  561. */
  562. typedef __ALIGNED(2) float16x4_t f16x4_t;
  563. #endif
  564. /**
  565. * @brief 32-bit floating-point 128-bit vector triplet data type
  566. */
  567. typedef float32x4x3_t f32x4x3_t;
  568. #if defined(ARM_MATH_FLOAT16)
  569. /**
  570. * @brief 16-bit floating-point 128-bit vector triplet data type
  571. */
  572. typedef float16x8x3_t f16x8x3_t;
  573. #endif
  574. /**
  575. * @brief 32-bit fractional 128-bit vector triplet data type in 1.31 format
  576. */
  577. typedef int32x4x3_t q31x4x3_t;
  578. /**
  579. * @brief 16-bit fractional 128-bit vector triplet data type in 1.15 format
  580. */
  581. typedef int16x8x3_t q15x8x3_t;
  582. /**
  583. * @brief 8-bit fractional 128-bit vector triplet data type in 1.7 format
  584. */
  585. typedef int8x16x3_t q7x16x3_t;
  586. /**
  587. * @brief 32-bit floating-point 64-bit vector pair data type
  588. */
  589. typedef float32x2x2_t f32x2x2_t;
  590. /**
  591. * @brief 32-bit floating-point 64-bit vector triplet data type
  592. */
  593. typedef float32x2x3_t f32x2x3_t;
  594. /**
  595. * @brief 32-bit floating-point 64-bit vector quadruplet data type
  596. */
  597. typedef float32x2x4_t f32x2x4_t;
  598. #if defined(ARM_MATH_FLOAT16)
  599. /**
  600. * @brief 16-bit floating-point 64-bit vector pair data type
  601. */
  602. typedef float16x4x2_t f16x4x2_t;
  603. /**
  604. * @brief 16-bit floating-point 64-bit vector triplet data type
  605. */
  606. typedef float16x4x3_t f16x4x3_t;
  607. /**
  608. * @brief 16-bit floating-point 64-bit vector quadruplet data type
  609. */
  610. typedef float16x4x4_t f16x4x4_t;
  611. #endif
  612. /**
  613. * @brief 32-bit fractional 64-bit vector pair data type in 1.31 format
  614. */
  615. typedef int32x2x2_t q31x2x2_t;
  616. /**
  617. * @brief 32-bit fractional 64-bit vector triplet data type in 1.31 format
  618. */
  619. typedef int32x2x3_t q31x2x3_t;
  620. /**
  621. * @brief 32-bit fractional 64-bit vector quadruplet data type in 1.31 format
  622. */
  623. typedef int32x4x3_t q31x2x4_t;
  624. /**
  625. * @brief 16-bit fractional 64-bit vector pair data type in 1.15 format
  626. */
  627. typedef int16x4x2_t q15x4x2_t;
  628. /**
  629. * @brief 16-bit fractional 64-bit vector triplet data type in 1.15 format
  630. */
  631. typedef int16x4x2_t q15x4x3_t;
  632. /**
  633. * @brief 16-bit fractional 64-bit vector quadruplet data type in 1.15 format
  634. */
  635. typedef int16x4x3_t q15x4x4_t;
  636. /**
  637. * @brief 8-bit fractional 64-bit vector pair data type in 1.7 format
  638. */
  639. typedef int8x8x2_t q7x8x2_t;
  640. /**
  641. * @brief 8-bit fractional 64-bit vector triplet data type in 1.7 format
  642. */
  643. typedef int8x8x3_t q7x8x3_t;
  644. /**
  645. * @brief 8-bit fractional 64-bit vector quadruplet data type in 1.7 format
  646. */
  647. typedef int8x8x4_t q7x8x4_t;
  648. /**
  649. * @brief 32-bit ubiquitous 64-bit vector data type
  650. */
  651. typedef union _any32x2_t
  652. {
  653. float32x2_t f;
  654. int32x2_t i;
  655. } any32x2_t;
  656. #if defined(ARM_MATH_FLOAT16)
  657. /**
  658. * @brief 16-bit ubiquitous 64-bit vector data type
  659. */
  660. typedef union _any16x4_t
  661. {
  662. float16x4_t f;
  663. int16x4_t i;
  664. } any16x4_t;
  665. #endif
  666. /**
  667. * @brief 32-bit status 64-bit vector data type.
  668. */
  669. typedef int32x4_t status32x2_t;
  670. /**
  671. * @brief 16-bit status 64-bit vector data type.
  672. */
  673. typedef int16x8_t status16x4_t;
  674. /**
  675. * @brief 8-bit status 64-bit vector data type.
  676. */
  677. typedef int8x16_t status8x8_t;
  678. #endif
  679. #define F64_MAX ((float64_t)DBL_MAX)
  680. #define F32_MAX ((float32_t)FLT_MAX)
  681. #if !defined( __CC_ARM )
  682. #define F16_MAX ((float16_t)FLT_MAX)
  683. #endif
  684. #define F64_MIN (-DBL_MAX)
  685. #define F32_MIN (-FLT_MAX)
  686. #if !defined( __CC_ARM )
  687. #define F16_MIN (-(float16_t)FLT_MAX)
  688. #endif
  689. #define F64_ABSMAX ((float64_t)DBL_MAX)
  690. #define F32_ABSMAX ((float32_t)FLT_MAX)
  691. #if !defined( __CC_ARM )
  692. #define F16_ABSMAX ((float16_t)FLT_MAX)
  693. #endif
  694. #define F64_ABSMIN ((float64_t)0.0)
  695. #define F32_ABSMIN ((float32_t)0.0)
  696. #if !defined( __CC_ARM )
  697. #define F16_ABSMIN ((float16_t)0.0)
  698. #endif
  699. #define Q31_MAX ((q31_t)(0x7FFFFFFFL))
  700. #define Q15_MAX ((q15_t)(0x7FFF))
  701. #define Q7_MAX ((q7_t)(0x7F))
  702. #define Q31_MIN ((q31_t)(0x80000000L))
  703. #define Q15_MIN ((q15_t)(0x8000))
  704. #define Q7_MIN ((q7_t)(0x80))
  705. #define Q31_ABSMAX ((q31_t)(0x7FFFFFFFL))
  706. #define Q15_ABSMAX ((q15_t)(0x7FFF))
  707. #define Q7_ABSMAX ((q7_t)(0x7F))
  708. #define Q31_ABSMIN ((q31_t)0)
  709. #define Q15_ABSMIN ((q15_t)0)
  710. #define Q7_ABSMIN ((q7_t)0)
  711. /**
  712. * @brief Macros required for reciprocal calculation in Normalized LMS
  713. */
  714. #define DELTA_Q31 ((q31_t)(0x100))
  715. #define DELTA_Q15 ((q15_t)0x5)
  716. #define INDEX_MASK 0x0000003F
  717. #ifndef PI
  718. #define PI 3.14159265358979f
  719. #endif
  720. /**
  721. * @brief Macros required for SINE and COSINE Fast math approximations
  722. */
  723. #define FAST_MATH_TABLE_SIZE 512
  724. #define FAST_MATH_Q31_SHIFT (32 - 10)
  725. #define FAST_MATH_Q15_SHIFT (16 - 10)
  726. #define CONTROLLER_Q31_SHIFT (32 - 9)
  727. #define TABLE_SPACING_Q31 0x400000
  728. #define TABLE_SPACING_Q15 0x80
  729. /**
  730. * @brief Macros required for SINE and COSINE Controller functions
  731. */
  732. /* 1.31(q31) Fixed value of 2/360 */
  733. /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
  734. #define INPUT_SPACING 0xB60B61
  735. /**
  736. * @brief Macros for complex numbers
  737. */
  738. /* Dimension C vector space */
  739. #define CMPLX_DIM 2
  740. /**
  741. * @brief Error status returned by some functions in the library.
  742. */
  743. typedef enum
  744. {
  745. ARM_MATH_SUCCESS = 0, /**< No error */
  746. ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
  747. ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
  748. ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation */
  749. ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
  750. ARM_MATH_SINGULAR = -5, /**< Input matrix is singular and cannot be inverted */
  751. ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
  752. } arm_status;
  753. /**
  754. @brief definition to read/write two 16 bit values.
  755. @deprecated
  756. */
  757. #if defined ( __CC_ARM )
  758. #define __SIMD32_TYPE int32_t __packed
  759. #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
  760. #define __SIMD32_TYPE int32_t
  761. #elif defined ( __GNUC__ )
  762. #define __SIMD32_TYPE int32_t
  763. #elif defined ( __ICCARM__ )
  764. #define __SIMD32_TYPE int32_t __packed
  765. #elif defined ( __TI_ARM__ )
  766. #define __SIMD32_TYPE int32_t
  767. #elif defined ( __CSMC__ )
  768. #define __SIMD32_TYPE int32_t
  769. #elif defined ( __TASKING__ )
  770. #define __SIMD32_TYPE __un(aligned) int32_t
  771. #elif defined(_MSC_VER )
  772. #define __SIMD32_TYPE int32_t
  773. #else
  774. #error Unknown compiler
  775. #endif
  776. #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
  777. #define __SIMD32_CONST(addr) ( (__SIMD32_TYPE * ) (addr))
  778. #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE * ) (addr))
  779. #define __SIMD64(addr) (*( int64_t **) & (addr))
  780. #define STEP(x) (x) <= 0 ? 0 : 1
  781. #define SQ(x) ((x) * (x))
  782. /* SIMD replacement */
  783. /**
  784. @brief Read 2 Q15 from Q15 pointer.
  785. @param[in] pQ15 points to input value
  786. @return Q31 value
  787. */
  788. __STATIC_FORCEINLINE q31_t read_q15x2 (
  789. q15_t * pQ15)
  790. {
  791. q31_t val;
  792. #ifdef __ARM_FEATURE_UNALIGNED
  793. memcpy (&val, pQ15, 4);
  794. #else
  795. val = (pQ15[1] << 16) | (pQ15[0] & 0x0FFFF) ;
  796. #endif
  797. return (val);
  798. }
  799. /**
  800. @brief Read 2 Q15 from Q15 pointer and increment pointer afterwards.
  801. @param[in] pQ15 points to input value
  802. @return Q31 value
  803. */
  804. __STATIC_FORCEINLINE q31_t read_q15x2_ia (
  805. q15_t ** pQ15)
  806. {
  807. q31_t val;
  808. #ifdef __ARM_FEATURE_UNALIGNED
  809. memcpy (&val, *pQ15, 4);
  810. #else
  811. val = ((*pQ15)[1] << 16) | ((*pQ15)[0] & 0x0FFFF);
  812. #endif
  813. *pQ15 += 2;
  814. return (val);
  815. }
  816. /**
  817. @brief Read 2 Q15 from Q15 pointer and decrement pointer afterwards.
  818. @param[in] pQ15 points to input value
  819. @return Q31 value
  820. */
  821. __STATIC_FORCEINLINE q31_t read_q15x2_da (
  822. q15_t ** pQ15)
  823. {
  824. q31_t val;
  825. #ifdef __ARM_FEATURE_UNALIGNED
  826. memcpy (&val, *pQ15, 4);
  827. #else
  828. val = ((*pQ15)[1] << 16) | ((*pQ15)[0] & 0x0FFFF);
  829. #endif
  830. *pQ15 -= 2;
  831. return (val);
  832. }
  833. /**
  834. @brief Write 2 Q15 to Q15 pointer and increment pointer afterwards.
  835. @param[in] pQ15 points to input value
  836. @param[in] value Q31 value
  837. @return none
  838. */
  839. __STATIC_FORCEINLINE void write_q15x2_ia (
  840. q15_t ** pQ15,
  841. q31_t value)
  842. {
  843. q31_t val = value;
  844. #ifdef __ARM_FEATURE_UNALIGNED
  845. memcpy (*pQ15, &val, 4);
  846. #else
  847. (*pQ15)[0] = (val & 0x0FFFF);
  848. (*pQ15)[1] = (val >> 16) & 0x0FFFF;
  849. #endif
  850. *pQ15 += 2;
  851. }
  852. /**
  853. @brief Write 2 Q15 to Q15 pointer.
  854. @param[in] pQ15 points to input value
  855. @param[in] value Q31 value
  856. @return none
  857. */
  858. __STATIC_FORCEINLINE void write_q15x2 (
  859. q15_t * pQ15,
  860. q31_t value)
  861. {
  862. q31_t val = value;
  863. #ifdef __ARM_FEATURE_UNALIGNED
  864. memcpy (pQ15, &val, 4);
  865. #else
  866. pQ15[0] = val & 0x0FFFF;
  867. pQ15[1] = val >> 16;
  868. #endif
  869. }
  870. /**
  871. @brief Read 4 Q7 from Q7 pointer and increment pointer afterwards.
  872. @param[in] pQ7 points to input value
  873. @return Q31 value
  874. */
  875. __STATIC_FORCEINLINE q31_t read_q7x4_ia (
  876. q7_t ** pQ7)
  877. {
  878. q31_t val;
  879. #ifdef __ARM_FEATURE_UNALIGNED
  880. memcpy (&val, *pQ7, 4);
  881. #else
  882. val =(((*pQ7)[3] & 0x0FF) << 24) | (((*pQ7)[2] & 0x0FF) << 16) | (((*pQ7)[1] & 0x0FF) << 8) | ((*pQ7)[0] & 0x0FF);
  883. #endif
  884. *pQ7 += 4;
  885. return (val);
  886. }
  887. /**
  888. @brief Read 4 Q7 from Q7 pointer and decrement pointer afterwards.
  889. @param[in] pQ7 points to input value
  890. @return Q31 value
  891. */
  892. __STATIC_FORCEINLINE q31_t read_q7x4_da (
  893. q7_t ** pQ7)
  894. {
  895. q31_t val;
  896. #ifdef __ARM_FEATURE_UNALIGNED
  897. memcpy (&val, *pQ7, 4);
  898. #else
  899. val = ((((*pQ7)[3]) & 0x0FF) << 24) | ((((*pQ7)[2]) & 0x0FF) << 16) | ((((*pQ7)[1]) & 0x0FF) << 8) | ((*pQ7)[0] & 0x0FF);
  900. #endif
  901. *pQ7 -= 4;
  902. return (val);
  903. }
  904. /**
  905. @brief Write 4 Q7 to Q7 pointer and increment pointer afterwards.
  906. @param[in] pQ7 points to input value
  907. @param[in] value Q31 value
  908. @return none
  909. */
  910. __STATIC_FORCEINLINE void write_q7x4_ia (
  911. q7_t ** pQ7,
  912. q31_t value)
  913. {
  914. q31_t val = value;
  915. #ifdef __ARM_FEATURE_UNALIGNED
  916. memcpy (*pQ7, &val, 4);
  917. #else
  918. (*pQ7)[0] = val & 0x0FF;
  919. (*pQ7)[1] = (val >> 8) & 0x0FF;
  920. (*pQ7)[2] = (val >> 16) & 0x0FF;
  921. (*pQ7)[3] = (val >> 24) & 0x0FF;
  922. #endif
  923. *pQ7 += 4;
  924. }
  925. /*
  926. Normally those kind of definitions are in a compiler file
  927. in Core or Core_A.
  928. But for MSVC compiler it is a bit special. The goal is very specific
  929. to CMSIS-DSP and only to allow the use of this library from other
  930. systems like Python or Matlab.
  931. MSVC is not going to be used to cross-compile to ARM. So, having a MSVC
  932. compiler file in Core or Core_A would not make sense.
  933. */
  934. #if defined ( _MSC_VER ) || defined(__GNUC_PYTHON__)
  935. __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t data)
  936. {
  937. if (data == 0U) { return 32U; }
  938. uint32_t count = 0U;
  939. uint32_t mask = 0x80000000U;
  940. while ((data & mask) == 0U)
  941. {
  942. count += 1U;
  943. mask = mask >> 1U;
  944. }
  945. return count;
  946. }
  947. __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
  948. {
  949. if ((sat >= 1U) && (sat <= 32U))
  950. {
  951. const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
  952. const int32_t min = -1 - max ;
  953. if (val > max)
  954. {
  955. return max;
  956. }
  957. else if (val < min)
  958. {
  959. return min;
  960. }
  961. }
  962. return val;
  963. }
  964. __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
  965. {
  966. if (sat <= 31U)
  967. {
  968. const uint32_t max = ((1U << sat) - 1U);
  969. if (val > (int32_t)max)
  970. {
  971. return max;
  972. }
  973. else if (val < 0)
  974. {
  975. return 0U;
  976. }
  977. }
  978. return (uint32_t)val;
  979. }
  980. #endif
  981. #ifndef ARM_MATH_DSP
  982. /**
  983. * @brief definition to pack two 16 bit values.
  984. */
  985. #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
  986. (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
  987. #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
  988. (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
  989. #endif
  990. /**
  991. * @brief definition to pack four 8 bit values.
  992. */
  993. #ifndef ARM_MATH_BIG_ENDIAN
  994. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
  995. (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
  996. (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
  997. (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
  998. #else
  999. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
  1000. (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
  1001. (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
  1002. (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
  1003. #endif
  1004. /**
  1005. * @brief Clips Q63 to Q31 values.
  1006. */
  1007. __STATIC_FORCEINLINE q31_t clip_q63_to_q31(
  1008. q63_t x)
  1009. {
  1010. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  1011. ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
  1012. }
  1013. /**
  1014. * @brief Clips Q63 to Q15 values.
  1015. */
  1016. __STATIC_FORCEINLINE q15_t clip_q63_to_q15(
  1017. q63_t x)
  1018. {
  1019. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  1020. ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
  1021. }
  1022. /**
  1023. * @brief Clips Q31 to Q7 values.
  1024. */
  1025. __STATIC_FORCEINLINE q7_t clip_q31_to_q7(
  1026. q31_t x)
  1027. {
  1028. return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
  1029. ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
  1030. }
  1031. /**
  1032. * @brief Clips Q31 to Q15 values.
  1033. */
  1034. __STATIC_FORCEINLINE q15_t clip_q31_to_q15(
  1035. q31_t x)
  1036. {
  1037. return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
  1038. ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
  1039. }
  1040. /**
  1041. * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
  1042. */
  1043. __STATIC_FORCEINLINE q63_t mult32x64(
  1044. q63_t x,
  1045. q31_t y)
  1046. {
  1047. return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
  1048. (((q63_t) (x >> 32) * y) ) );
  1049. }
  1050. /**
  1051. * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
  1052. */
  1053. __STATIC_FORCEINLINE uint32_t arm_recip_q31(
  1054. q31_t in,
  1055. q31_t * dst,
  1056. const q31_t * pRecipTable)
  1057. {
  1058. q31_t out;
  1059. uint32_t tempVal;
  1060. uint32_t index, i;
  1061. uint32_t signBits;
  1062. if (in > 0)
  1063. {
  1064. signBits = ((uint32_t) (__CLZ( in) - 1));
  1065. }
  1066. else
  1067. {
  1068. signBits = ((uint32_t) (__CLZ(-in) - 1));
  1069. }
  1070. /* Convert input sample to 1.31 format */
  1071. in = (in << signBits);
  1072. /* calculation of index for initial approximated Val */
  1073. index = (uint32_t)(in >> 24);
  1074. index = (index & INDEX_MASK);
  1075. /* 1.31 with exp 1 */
  1076. out = pRecipTable[index];
  1077. /* calculation of reciprocal value */
  1078. /* running approximation for two iterations */
  1079. for (i = 0U; i < 2U; i++)
  1080. {
  1081. tempVal = (uint32_t) (((q63_t) in * out) >> 31);
  1082. tempVal = 0x7FFFFFFFu - tempVal;
  1083. /* 1.31 with exp 1 */
  1084. /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */
  1085. out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30);
  1086. }
  1087. /* write output */
  1088. *dst = out;
  1089. /* return num of signbits of out = 1/in value */
  1090. return (signBits + 1U);
  1091. }
  1092. /**
  1093. * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
  1094. */
  1095. __STATIC_FORCEINLINE uint32_t arm_recip_q15(
  1096. q15_t in,
  1097. q15_t * dst,
  1098. const q15_t * pRecipTable)
  1099. {
  1100. q15_t out = 0;
  1101. uint32_t tempVal = 0;
  1102. uint32_t index = 0, i = 0;
  1103. uint32_t signBits = 0;
  1104. if (in > 0)
  1105. {
  1106. signBits = ((uint32_t)(__CLZ( in) - 17));
  1107. }
  1108. else
  1109. {
  1110. signBits = ((uint32_t)(__CLZ(-in) - 17));
  1111. }
  1112. /* Convert input sample to 1.15 format */
  1113. in = (in << signBits);
  1114. /* calculation of index for initial approximated Val */
  1115. index = (uint32_t)(in >> 8);
  1116. index = (index & INDEX_MASK);
  1117. /* 1.15 with exp 1 */
  1118. out = pRecipTable[index];
  1119. /* calculation of reciprocal value */
  1120. /* running approximation for two iterations */
  1121. for (i = 0U; i < 2U; i++)
  1122. {
  1123. tempVal = (uint32_t) (((q31_t) in * out) >> 15);
  1124. tempVal = 0x7FFFu - tempVal;
  1125. /* 1.15 with exp 1 */
  1126. out = (q15_t) (((q31_t) out * tempVal) >> 14);
  1127. /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */
  1128. }
  1129. /* write output */
  1130. *dst = out;
  1131. /* return num of signbits of out = 1/in value */
  1132. return (signBits + 1);
  1133. }
  1134. /**
  1135. * @brief Integer exponentiation
  1136. * @param[in] x value
  1137. * @param[in] nb integer exponent >= 1
  1138. * @return x^nb
  1139. *
  1140. */
  1141. __STATIC_INLINE float32_t arm_exponent_f32(float32_t x, int32_t nb)
  1142. {
  1143. float32_t r = x;
  1144. nb --;
  1145. while(nb > 0)
  1146. {
  1147. r = r * x;
  1148. nb--;
  1149. }
  1150. return(r);
  1151. }
  1152. /**
  1153. * @brief 64-bit to 32-bit unsigned normalization
  1154. * @param[in] in is input unsigned long long value
  1155. * @param[out] normalized is the 32-bit normalized value
  1156. * @param[out] norm is norm scale
  1157. */
  1158. __STATIC_INLINE void arm_norm_64_to_32u(uint64_t in, int32_t * normalized, int32_t *norm)
  1159. {
  1160. int32_t n1;
  1161. int32_t hi = (int32_t) (in >> 32);
  1162. int32_t lo = (int32_t) ((in << 32) >> 32);
  1163. n1 = __CLZ(hi) - 32;
  1164. if (!n1)
  1165. {
  1166. /*
  1167. * input fits in 32-bit
  1168. */
  1169. n1 = __CLZ(lo);
  1170. if (!n1)
  1171. {
  1172. /*
  1173. * MSB set, need to scale down by 1
  1174. */
  1175. *norm = -1;
  1176. *normalized = (((uint32_t) lo) >> 1);
  1177. } else
  1178. {
  1179. if (n1 == 32)
  1180. {
  1181. /*
  1182. * input is zero
  1183. */
  1184. *norm = 0;
  1185. *normalized = 0;
  1186. } else
  1187. {
  1188. /*
  1189. * 32-bit normalization
  1190. */
  1191. *norm = n1 - 1;
  1192. *normalized = lo << *norm;
  1193. }
  1194. }
  1195. } else
  1196. {
  1197. /*
  1198. * input fits in 64-bit
  1199. */
  1200. n1 = 1 - n1;
  1201. *norm = -n1;
  1202. /*
  1203. * 64 bit normalization
  1204. */
  1205. *normalized = (((uint32_t) lo) >> n1) | (hi << (32 - n1));
  1206. }
  1207. }
  1208. __STATIC_INLINE q31_t arm_div_q63_to_q31(q63_t num, q31_t den)
  1209. {
  1210. q31_t result;
  1211. uint64_t absNum;
  1212. int32_t normalized;
  1213. int32_t norm;
  1214. /*
  1215. * if sum fits in 32bits
  1216. * avoid costly 64-bit division
  1217. */
  1218. absNum = num > 0 ? num : -num;
  1219. arm_norm_64_to_32u(absNum, &normalized, &norm);
  1220. if (norm > 0)
  1221. /*
  1222. * 32-bit division
  1223. */
  1224. result = (q31_t) num / den;
  1225. else
  1226. /*
  1227. * 64-bit division
  1228. */
  1229. result = (q31_t) (num / den);
  1230. return result;
  1231. }
  1232. /*
  1233. * @brief C custom defined intrinsic functions
  1234. */
  1235. #if !defined (ARM_MATH_DSP)
  1236. /*
  1237. * @brief C custom defined QADD8
  1238. */
  1239. __STATIC_FORCEINLINE uint32_t __QADD8(
  1240. uint32_t x,
  1241. uint32_t y)
  1242. {
  1243. q31_t r, s, t, u;
  1244. r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
  1245. s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
  1246. t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
  1247. u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
  1248. return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
  1249. }
  1250. /*
  1251. * @brief C custom defined QSUB8
  1252. */
  1253. __STATIC_FORCEINLINE uint32_t __QSUB8(
  1254. uint32_t x,
  1255. uint32_t y)
  1256. {
  1257. q31_t r, s, t, u;
  1258. r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
  1259. s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
  1260. t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
  1261. u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
  1262. return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
  1263. }
  1264. /*
  1265. * @brief C custom defined QADD16
  1266. */
  1267. __STATIC_FORCEINLINE uint32_t __QADD16(
  1268. uint32_t x,
  1269. uint32_t y)
  1270. {
  1271. /* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */
  1272. q31_t r = 0, s = 0;
  1273. r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  1274. s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  1275. return ((uint32_t)((s << 16) | (r )));
  1276. }
  1277. /*
  1278. * @brief C custom defined SHADD16
  1279. */
  1280. __STATIC_FORCEINLINE uint32_t __SHADD16(
  1281. uint32_t x,
  1282. uint32_t y)
  1283. {
  1284. q31_t r, s;
  1285. r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1286. s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1287. return ((uint32_t)((s << 16) | (r )));
  1288. }
  1289. /*
  1290. * @brief C custom defined QSUB16
  1291. */
  1292. __STATIC_FORCEINLINE uint32_t __QSUB16(
  1293. uint32_t x,
  1294. uint32_t y)
  1295. {
  1296. q31_t r, s;
  1297. r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  1298. s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  1299. return ((uint32_t)((s << 16) | (r )));
  1300. }
  1301. /*
  1302. * @brief C custom defined SHSUB16
  1303. */
  1304. __STATIC_FORCEINLINE uint32_t __SHSUB16(
  1305. uint32_t x,
  1306. uint32_t y)
  1307. {
  1308. q31_t r, s;
  1309. r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1310. s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1311. return ((uint32_t)((s << 16) | (r )));
  1312. }
  1313. /*
  1314. * @brief C custom defined QASX
  1315. */
  1316. __STATIC_FORCEINLINE uint32_t __QASX(
  1317. uint32_t x,
  1318. uint32_t y)
  1319. {
  1320. q31_t r, s;
  1321. r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  1322. s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  1323. return ((uint32_t)((s << 16) | (r )));
  1324. }
  1325. /*
  1326. * @brief C custom defined SHASX
  1327. */
  1328. __STATIC_FORCEINLINE uint32_t __SHASX(
  1329. uint32_t x,
  1330. uint32_t y)
  1331. {
  1332. q31_t r, s;
  1333. r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1334. s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1335. return ((uint32_t)((s << 16) | (r )));
  1336. }
  1337. /*
  1338. * @brief C custom defined QSAX
  1339. */
  1340. __STATIC_FORCEINLINE uint32_t __QSAX(
  1341. uint32_t x,
  1342. uint32_t y)
  1343. {
  1344. q31_t r, s;
  1345. r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
  1346. s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
  1347. return ((uint32_t)((s << 16) | (r )));
  1348. }
  1349. /*
  1350. * @brief C custom defined SHSAX
  1351. */
  1352. __STATIC_FORCEINLINE uint32_t __SHSAX(
  1353. uint32_t x,
  1354. uint32_t y)
  1355. {
  1356. q31_t r, s;
  1357. r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1358. s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
  1359. return ((uint32_t)((s << 16) | (r )));
  1360. }
  1361. /*
  1362. * @brief C custom defined SMUSDX
  1363. */
  1364. __STATIC_FORCEINLINE uint32_t __SMUSDX(
  1365. uint32_t x,
  1366. uint32_t y)
  1367. {
  1368. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
  1369. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
  1370. }
  1371. /*
  1372. * @brief C custom defined SMUADX
  1373. */
  1374. __STATIC_FORCEINLINE uint32_t __SMUADX(
  1375. uint32_t x,
  1376. uint32_t y)
  1377. {
  1378. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  1379. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
  1380. }
  1381. /*
  1382. * @brief C custom defined QADD
  1383. */
  1384. __STATIC_FORCEINLINE int32_t __QADD(
  1385. int32_t x,
  1386. int32_t y)
  1387. {
  1388. return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y)));
  1389. }
  1390. /*
  1391. * @brief C custom defined QSUB
  1392. */
  1393. __STATIC_FORCEINLINE int32_t __QSUB(
  1394. int32_t x,
  1395. int32_t y)
  1396. {
  1397. return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y)));
  1398. }
  1399. /*
  1400. * @brief C custom defined SMLAD
  1401. */
  1402. __STATIC_FORCEINLINE uint32_t __SMLAD(
  1403. uint32_t x,
  1404. uint32_t y,
  1405. uint32_t sum)
  1406. {
  1407. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  1408. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
  1409. ( ((q31_t)sum ) ) ));
  1410. }
  1411. /*
  1412. * @brief C custom defined SMLADX
  1413. */
  1414. __STATIC_FORCEINLINE uint32_t __SMLADX(
  1415. uint32_t x,
  1416. uint32_t y,
  1417. uint32_t sum)
  1418. {
  1419. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  1420. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  1421. ( ((q31_t)sum ) ) ));
  1422. }
  1423. /*
  1424. * @brief C custom defined SMLSDX
  1425. */
  1426. __STATIC_FORCEINLINE uint32_t __SMLSDX(
  1427. uint32_t x,
  1428. uint32_t y,
  1429. uint32_t sum)
  1430. {
  1431. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
  1432. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  1433. ( ((q31_t)sum ) ) ));
  1434. }
  1435. /*
  1436. * @brief C custom defined SMLALD
  1437. */
  1438. __STATIC_FORCEINLINE uint64_t __SMLALD(
  1439. uint32_t x,
  1440. uint32_t y,
  1441. uint64_t sum)
  1442. {
  1443. /* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */
  1444. return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  1445. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
  1446. ( ((q63_t)sum ) ) ));
  1447. }
  1448. /*
  1449. * @brief C custom defined SMLALDX
  1450. */
  1451. __STATIC_FORCEINLINE uint64_t __SMLALDX(
  1452. uint32_t x,
  1453. uint32_t y,
  1454. uint64_t sum)
  1455. {
  1456. /* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */
  1457. return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
  1458. ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
  1459. ( ((q63_t)sum ) ) ));
  1460. }
  1461. /*
  1462. * @brief C custom defined SMUAD
  1463. */
  1464. __STATIC_FORCEINLINE uint32_t __SMUAD(
  1465. uint32_t x,
  1466. uint32_t y)
  1467. {
  1468. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
  1469. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
  1470. }
  1471. /*
  1472. * @brief C custom defined SMUSD
  1473. */
  1474. __STATIC_FORCEINLINE uint32_t __SMUSD(
  1475. uint32_t x,
  1476. uint32_t y)
  1477. {
  1478. return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) -
  1479. ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
  1480. }
  1481. /*
  1482. * @brief C custom defined SXTB16
  1483. */
  1484. __STATIC_FORCEINLINE uint32_t __SXTB16(
  1485. uint32_t x)
  1486. {
  1487. return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) |
  1488. ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) ));
  1489. }
  1490. /*
  1491. * @brief C custom defined SMMLA
  1492. */
  1493. __STATIC_FORCEINLINE int32_t __SMMLA(
  1494. int32_t x,
  1495. int32_t y,
  1496. int32_t sum)
  1497. {
  1498. return (sum + (int32_t) (((int64_t) x * y) >> 32));
  1499. }
  1500. #endif /* !defined (ARM_MATH_DSP) */
  1501. /**
  1502. * @brief Instance structure for the Q7 FIR filter.
  1503. */
  1504. typedef struct
  1505. {
  1506. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  1507. q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  1508. const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  1509. } arm_fir_instance_q7;
  1510. /**
  1511. * @brief Instance structure for the Q15 FIR filter.
  1512. */
  1513. typedef struct
  1514. {
  1515. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  1516. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  1517. const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  1518. } arm_fir_instance_q15;
  1519. /**
  1520. * @brief Instance structure for the Q31 FIR filter.
  1521. */
  1522. typedef struct
  1523. {
  1524. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  1525. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  1526. const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  1527. } arm_fir_instance_q31;
  1528. /**
  1529. * @brief Instance structure for the floating-point FIR filter.
  1530. */
  1531. typedef struct
  1532. {
  1533. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  1534. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  1535. const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  1536. } arm_fir_instance_f32;
  1537. /**
  1538. * @brief Processing function for the Q7 FIR filter.
  1539. * @param[in] S points to an instance of the Q7 FIR filter structure.
  1540. * @param[in] pSrc points to the block of input data.
  1541. * @param[out] pDst points to the block of output data.
  1542. * @param[in] blockSize number of samples to process.
  1543. */
  1544. void arm_fir_q7(
  1545. const arm_fir_instance_q7 * S,
  1546. const q7_t * pSrc,
  1547. q7_t * pDst,
  1548. uint32_t blockSize);
  1549. /**
  1550. * @brief Initialization function for the Q7 FIR filter.
  1551. * @param[in,out] S points to an instance of the Q7 FIR structure.
  1552. * @param[in] numTaps Number of filter coefficients in the filter.
  1553. * @param[in] pCoeffs points to the filter coefficients.
  1554. * @param[in] pState points to the state buffer.
  1555. * @param[in] blockSize number of samples that are processed.
  1556. */
  1557. void arm_fir_init_q7(
  1558. arm_fir_instance_q7 * S,
  1559. uint16_t numTaps,
  1560. const q7_t * pCoeffs,
  1561. q7_t * pState,
  1562. uint32_t blockSize);
  1563. /**
  1564. * @brief Processing function for the Q15 FIR filter.
  1565. * @param[in] S points to an instance of the Q15 FIR structure.
  1566. * @param[in] pSrc points to the block of input data.
  1567. * @param[out] pDst points to the block of output data.
  1568. * @param[in] blockSize number of samples to process.
  1569. */
  1570. void arm_fir_q15(
  1571. const arm_fir_instance_q15 * S,
  1572. const q15_t * pSrc,
  1573. q15_t * pDst,
  1574. uint32_t blockSize);
  1575. /**
  1576. * @brief Processing function for the fast Q15 FIR filter (fast version).
  1577. * @param[in] S points to an instance of the Q15 FIR filter structure.
  1578. * @param[in] pSrc points to the block of input data.
  1579. * @param[out] pDst points to the block of output data.
  1580. * @param[in] blockSize number of samples to process.
  1581. */
  1582. void arm_fir_fast_q15(
  1583. const arm_fir_instance_q15 * S,
  1584. const q15_t * pSrc,
  1585. q15_t * pDst,
  1586. uint32_t blockSize);
  1587. /**
  1588. * @brief Initialization function for the Q15 FIR filter.
  1589. * @param[in,out] S points to an instance of the Q15 FIR filter structure.
  1590. * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
  1591. * @param[in] pCoeffs points to the filter coefficients.
  1592. * @param[in] pState points to the state buffer.
  1593. * @param[in] blockSize number of samples that are processed at a time.
  1594. * @return The function returns either
  1595. * <code>ARM_MATH_SUCCESS</code> if initialization was successful or
  1596. * <code>ARM_MATH_ARGUMENT_ERROR</code> if <code>numTaps</code> is not a supported value.
  1597. */
  1598. arm_status arm_fir_init_q15(
  1599. arm_fir_instance_q15 * S,
  1600. uint16_t numTaps,
  1601. const q15_t * pCoeffs,
  1602. q15_t * pState,
  1603. uint32_t blockSize);
  1604. /**
  1605. * @brief Processing function for the Q31 FIR filter.
  1606. * @param[in] S points to an instance of the Q31 FIR filter structure.
  1607. * @param[in] pSrc points to the block of input data.
  1608. * @param[out] pDst points to the block of output data.
  1609. * @param[in] blockSize number of samples to process.
  1610. */
  1611. void arm_fir_q31(
  1612. const arm_fir_instance_q31 * S,
  1613. const q31_t * pSrc,
  1614. q31_t * pDst,
  1615. uint32_t blockSize);
  1616. /**
  1617. * @brief Processing function for the fast Q31 FIR filter (fast version).
  1618. * @param[in] S points to an instance of the Q31 FIR filter structure.
  1619. * @param[in] pSrc points to the block of input data.
  1620. * @param[out] pDst points to the block of output data.
  1621. * @param[in] blockSize number of samples to process.
  1622. */
  1623. void arm_fir_fast_q31(
  1624. const arm_fir_instance_q31 * S,
  1625. const q31_t * pSrc,
  1626. q31_t * pDst,
  1627. uint32_t blockSize);
  1628. /**
  1629. * @brief Initialization function for the Q31 FIR filter.
  1630. * @param[in,out] S points to an instance of the Q31 FIR structure.
  1631. * @param[in] numTaps Number of filter coefficients in the filter.
  1632. * @param[in] pCoeffs points to the filter coefficients.
  1633. * @param[in] pState points to the state buffer.
  1634. * @param[in] blockSize number of samples that are processed at a time.
  1635. */
  1636. void arm_fir_init_q31(
  1637. arm_fir_instance_q31 * S,
  1638. uint16_t numTaps,
  1639. const q31_t * pCoeffs,
  1640. q31_t * pState,
  1641. uint32_t blockSize);
  1642. /**
  1643. * @brief Processing function for the floating-point FIR filter.
  1644. * @param[in] S points to an instance of the floating-point FIR structure.
  1645. * @param[in] pSrc points to the block of input data.
  1646. * @param[out] pDst points to the block of output data.
  1647. * @param[in] blockSize number of samples to process.
  1648. */
  1649. void arm_fir_f32(
  1650. const arm_fir_instance_f32 * S,
  1651. const float32_t * pSrc,
  1652. float32_t * pDst,
  1653. uint32_t blockSize);
  1654. /**
  1655. * @brief Initialization function for the floating-point FIR filter.
  1656. * @param[in,out] S points to an instance of the floating-point FIR filter structure.
  1657. * @param[in] numTaps Number of filter coefficients in the filter.
  1658. * @param[in] pCoeffs points to the filter coefficients.
  1659. * @param[in] pState points to the state buffer.
  1660. * @param[in] blockSize number of samples that are processed at a time.
  1661. */
  1662. void arm_fir_init_f32(
  1663. arm_fir_instance_f32 * S,
  1664. uint16_t numTaps,
  1665. const float32_t * pCoeffs,
  1666. float32_t * pState,
  1667. uint32_t blockSize);
  1668. /**
  1669. * @brief Instance structure for the Q15 Biquad cascade filter.
  1670. */
  1671. typedef struct
  1672. {
  1673. int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1674. q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1675. const q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1676. int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1677. } arm_biquad_casd_df1_inst_q15;
  1678. /**
  1679. * @brief Instance structure for the Q31 Biquad cascade filter.
  1680. */
  1681. typedef struct
  1682. {
  1683. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1684. q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1685. const q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1686. uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1687. } arm_biquad_casd_df1_inst_q31;
  1688. /**
  1689. * @brief Instance structure for the floating-point Biquad cascade filter.
  1690. */
  1691. typedef struct
  1692. {
  1693. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1694. float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1695. const float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1696. } arm_biquad_casd_df1_inst_f32;
  1697. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  1698. /**
  1699. * @brief Instance structure for the modified Biquad coefs required by vectorized code.
  1700. */
  1701. typedef struct
  1702. {
  1703. float32_t coeffs[8][4]; /**< Points to the array of modified coefficients. The array is of length 32. There is one per stage */
  1704. } arm_biquad_mod_coef_f32;
  1705. #endif
  1706. /**
  1707. * @brief Processing function for the Q15 Biquad cascade filter.
  1708. * @param[in] S points to an instance of the Q15 Biquad cascade structure.
  1709. * @param[in] pSrc points to the block of input data.
  1710. * @param[out] pDst points to the block of output data.
  1711. * @param[in] blockSize number of samples to process.
  1712. */
  1713. void arm_biquad_cascade_df1_q15(
  1714. const arm_biquad_casd_df1_inst_q15 * S,
  1715. const q15_t * pSrc,
  1716. q15_t * pDst,
  1717. uint32_t blockSize);
  1718. /**
  1719. * @brief Initialization function for the Q15 Biquad cascade filter.
  1720. * @param[in,out] S points to an instance of the Q15 Biquad cascade structure.
  1721. * @param[in] numStages number of 2nd order stages in the filter.
  1722. * @param[in] pCoeffs points to the filter coefficients.
  1723. * @param[in] pState points to the state buffer.
  1724. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1725. */
  1726. void arm_biquad_cascade_df1_init_q15(
  1727. arm_biquad_casd_df1_inst_q15 * S,
  1728. uint8_t numStages,
  1729. const q15_t * pCoeffs,
  1730. q15_t * pState,
  1731. int8_t postShift);
  1732. /**
  1733. * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1734. * @param[in] S points to an instance of the Q15 Biquad cascade structure.
  1735. * @param[in] pSrc points to the block of input data.
  1736. * @param[out] pDst points to the block of output data.
  1737. * @param[in] blockSize number of samples to process.
  1738. */
  1739. void arm_biquad_cascade_df1_fast_q15(
  1740. const arm_biquad_casd_df1_inst_q15 * S,
  1741. const q15_t * pSrc,
  1742. q15_t * pDst,
  1743. uint32_t blockSize);
  1744. /**
  1745. * @brief Processing function for the Q31 Biquad cascade filter
  1746. * @param[in] S points to an instance of the Q31 Biquad cascade structure.
  1747. * @param[in] pSrc points to the block of input data.
  1748. * @param[out] pDst points to the block of output data.
  1749. * @param[in] blockSize number of samples to process.
  1750. */
  1751. void arm_biquad_cascade_df1_q31(
  1752. const arm_biquad_casd_df1_inst_q31 * S,
  1753. const q31_t * pSrc,
  1754. q31_t * pDst,
  1755. uint32_t blockSize);
  1756. /**
  1757. * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1758. * @param[in] S points to an instance of the Q31 Biquad cascade structure.
  1759. * @param[in] pSrc points to the block of input data.
  1760. * @param[out] pDst points to the block of output data.
  1761. * @param[in] blockSize number of samples to process.
  1762. */
  1763. void arm_biquad_cascade_df1_fast_q31(
  1764. const arm_biquad_casd_df1_inst_q31 * S,
  1765. const q31_t * pSrc,
  1766. q31_t * pDst,
  1767. uint32_t blockSize);
  1768. /**
  1769. * @brief Initialization function for the Q31 Biquad cascade filter.
  1770. * @param[in,out] S points to an instance of the Q31 Biquad cascade structure.
  1771. * @param[in] numStages number of 2nd order stages in the filter.
  1772. * @param[in] pCoeffs points to the filter coefficients.
  1773. * @param[in] pState points to the state buffer.
  1774. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1775. */
  1776. void arm_biquad_cascade_df1_init_q31(
  1777. arm_biquad_casd_df1_inst_q31 * S,
  1778. uint8_t numStages,
  1779. const q31_t * pCoeffs,
  1780. q31_t * pState,
  1781. int8_t postShift);
  1782. /**
  1783. * @brief Processing function for the floating-point Biquad cascade filter.
  1784. * @param[in] S points to an instance of the floating-point Biquad cascade structure.
  1785. * @param[in] pSrc points to the block of input data.
  1786. * @param[out] pDst points to the block of output data.
  1787. * @param[in] blockSize number of samples to process.
  1788. */
  1789. void arm_biquad_cascade_df1_f32(
  1790. const arm_biquad_casd_df1_inst_f32 * S,
  1791. const float32_t * pSrc,
  1792. float32_t * pDst,
  1793. uint32_t blockSize);
  1794. /**
  1795. * @brief Initialization function for the floating-point Biquad cascade filter.
  1796. * @param[in,out] S points to an instance of the floating-point Biquad cascade structure.
  1797. * @param[in] numStages number of 2nd order stages in the filter.
  1798. * @param[in] pCoeffs points to the filter coefficients.
  1799. * @param[in] pCoeffsMod points to the modified filter coefficients (only MVE version).
  1800. * @param[in] pState points to the state buffer.
  1801. */
  1802. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  1803. void arm_biquad_cascade_df1_mve_init_f32(
  1804. arm_biquad_casd_df1_inst_f32 * S,
  1805. uint8_t numStages,
  1806. const float32_t * pCoeffs,
  1807. arm_biquad_mod_coef_f32 * pCoeffsMod,
  1808. float32_t * pState);
  1809. #endif
  1810. void arm_biquad_cascade_df1_init_f32(
  1811. arm_biquad_casd_df1_inst_f32 * S,
  1812. uint8_t numStages,
  1813. const float32_t * pCoeffs,
  1814. float32_t * pState);
  1815. /**
  1816. * @brief Compute the logical bitwise AND of two fixed-point vectors.
  1817. * @param[in] pSrcA points to input vector A
  1818. * @param[in] pSrcB points to input vector B
  1819. * @param[out] pDst points to output vector
  1820. * @param[in] blockSize number of samples in each vector
  1821. * @return none
  1822. */
  1823. void arm_and_u16(
  1824. const uint16_t * pSrcA,
  1825. const uint16_t * pSrcB,
  1826. uint16_t * pDst,
  1827. uint32_t blockSize);
  1828. /**
  1829. * @brief Compute the logical bitwise AND of two fixed-point vectors.
  1830. * @param[in] pSrcA points to input vector A
  1831. * @param[in] pSrcB points to input vector B
  1832. * @param[out] pDst points to output vector
  1833. * @param[in] blockSize number of samples in each vector
  1834. * @return none
  1835. */
  1836. void arm_and_u32(
  1837. const uint32_t * pSrcA,
  1838. const uint32_t * pSrcB,
  1839. uint32_t * pDst,
  1840. uint32_t blockSize);
  1841. /**
  1842. * @brief Compute the logical bitwise AND of two fixed-point vectors.
  1843. * @param[in] pSrcA points to input vector A
  1844. * @param[in] pSrcB points to input vector B
  1845. * @param[out] pDst points to output vector
  1846. * @param[in] blockSize number of samples in each vector
  1847. * @return none
  1848. */
  1849. void arm_and_u8(
  1850. const uint8_t * pSrcA,
  1851. const uint8_t * pSrcB,
  1852. uint8_t * pDst,
  1853. uint32_t blockSize);
  1854. /**
  1855. * @brief Compute the logical bitwise OR of two fixed-point vectors.
  1856. * @param[in] pSrcA points to input vector A
  1857. * @param[in] pSrcB points to input vector B
  1858. * @param[out] pDst points to output vector
  1859. * @param[in] blockSize number of samples in each vector
  1860. * @return none
  1861. */
  1862. void arm_or_u16(
  1863. const uint16_t * pSrcA,
  1864. const uint16_t * pSrcB,
  1865. uint16_t * pDst,
  1866. uint32_t blockSize);
  1867. /**
  1868. * @brief Compute the logical bitwise OR of two fixed-point vectors.
  1869. * @param[in] pSrcA points to input vector A
  1870. * @param[in] pSrcB points to input vector B
  1871. * @param[out] pDst points to output vector
  1872. * @param[in] blockSize number of samples in each vector
  1873. * @return none
  1874. */
  1875. void arm_or_u32(
  1876. const uint32_t * pSrcA,
  1877. const uint32_t * pSrcB,
  1878. uint32_t * pDst,
  1879. uint32_t blockSize);
  1880. /**
  1881. * @brief Compute the logical bitwise OR of two fixed-point vectors.
  1882. * @param[in] pSrcA points to input vector A
  1883. * @param[in] pSrcB points to input vector B
  1884. * @param[out] pDst points to output vector
  1885. * @param[in] blockSize number of samples in each vector
  1886. * @return none
  1887. */
  1888. void arm_or_u8(
  1889. const uint8_t * pSrcA,
  1890. const uint8_t * pSrcB,
  1891. uint8_t * pDst,
  1892. uint32_t blockSize);
  1893. /**
  1894. * @brief Compute the logical bitwise NOT of a fixed-point vector.
  1895. * @param[in] pSrc points to input vector
  1896. * @param[out] pDst points to output vector
  1897. * @param[in] blockSize number of samples in each vector
  1898. * @return none
  1899. */
  1900. void arm_not_u16(
  1901. const uint16_t * pSrc,
  1902. uint16_t * pDst,
  1903. uint32_t blockSize);
  1904. /**
  1905. * @brief Compute the logical bitwise NOT of a fixed-point vector.
  1906. * @param[in] pSrc points to input vector
  1907. * @param[out] pDst points to output vector
  1908. * @param[in] blockSize number of samples in each vector
  1909. * @return none
  1910. */
  1911. void arm_not_u32(
  1912. const uint32_t * pSrc,
  1913. uint32_t * pDst,
  1914. uint32_t blockSize);
  1915. /**
  1916. * @brief Compute the logical bitwise NOT of a fixed-point vector.
  1917. * @param[in] pSrc points to input vector
  1918. * @param[out] pDst points to output vector
  1919. * @param[in] blockSize number of samples in each vector
  1920. * @return none
  1921. */
  1922. void arm_not_u8(
  1923. const uint8_t * pSrc,
  1924. uint8_t * pDst,
  1925. uint32_t blockSize);
  1926. /**
  1927. * @brief Compute the logical bitwise XOR of two fixed-point vectors.
  1928. * @param[in] pSrcA points to input vector A
  1929. * @param[in] pSrcB points to input vector B
  1930. * @param[out] pDst points to output vector
  1931. * @param[in] blockSize number of samples in each vector
  1932. * @return none
  1933. */
  1934. void arm_xor_u16(
  1935. const uint16_t * pSrcA,
  1936. const uint16_t * pSrcB,
  1937. uint16_t * pDst,
  1938. uint32_t blockSize);
  1939. /**
  1940. * @brief Compute the logical bitwise XOR of two fixed-point vectors.
  1941. * @param[in] pSrcA points to input vector A
  1942. * @param[in] pSrcB points to input vector B
  1943. * @param[out] pDst points to output vector
  1944. * @param[in] blockSize number of samples in each vector
  1945. * @return none
  1946. */
  1947. void arm_xor_u32(
  1948. const uint32_t * pSrcA,
  1949. const uint32_t * pSrcB,
  1950. uint32_t * pDst,
  1951. uint32_t blockSize);
  1952. /**
  1953. * @brief Compute the logical bitwise XOR of two fixed-point vectors.
  1954. * @param[in] pSrcA points to input vector A
  1955. * @param[in] pSrcB points to input vector B
  1956. * @param[out] pDst points to output vector
  1957. * @param[in] blockSize number of samples in each vector
  1958. * @return none
  1959. */
  1960. void arm_xor_u8(
  1961. const uint8_t * pSrcA,
  1962. const uint8_t * pSrcB,
  1963. uint8_t * pDst,
  1964. uint32_t blockSize);
  1965. /**
  1966. * @brief Struct for specifying sorting algorithm
  1967. */
  1968. typedef enum
  1969. {
  1970. ARM_SORT_BITONIC = 0,
  1971. /**< Bitonic sort */
  1972. ARM_SORT_BUBBLE = 1,
  1973. /**< Bubble sort */
  1974. ARM_SORT_HEAP = 2,
  1975. /**< Heap sort */
  1976. ARM_SORT_INSERTION = 3,
  1977. /**< Insertion sort */
  1978. ARM_SORT_QUICK = 4,
  1979. /**< Quick sort */
  1980. ARM_SORT_SELECTION = 5
  1981. /**< Selection sort */
  1982. } arm_sort_alg;
  1983. /**
  1984. * @brief Struct for specifying sorting algorithm
  1985. */
  1986. typedef enum
  1987. {
  1988. ARM_SORT_DESCENDING = 0,
  1989. /**< Descending order (9 to 0) */
  1990. ARM_SORT_ASCENDING = 1
  1991. /**< Ascending order (0 to 9) */
  1992. } arm_sort_dir;
  1993. /**
  1994. * @brief Instance structure for the sorting algorithms.
  1995. */
  1996. typedef struct
  1997. {
  1998. arm_sort_alg alg; /**< Sorting algorithm selected */
  1999. arm_sort_dir dir; /**< Sorting order (direction) */
  2000. } arm_sort_instance_f32;
  2001. /**
  2002. * @param[in] S points to an instance of the sorting structure.
  2003. * @param[in] pSrc points to the block of input data.
  2004. * @param[out] pDst points to the block of output data.
  2005. * @param[in] blockSize number of samples to process.
  2006. */
  2007. void arm_sort_f32(
  2008. const arm_sort_instance_f32 * S,
  2009. float32_t * pSrc,
  2010. float32_t * pDst,
  2011. uint32_t blockSize);
  2012. /**
  2013. * @param[in,out] S points to an instance of the sorting structure.
  2014. * @param[in] alg Selected algorithm.
  2015. * @param[in] dir Sorting order.
  2016. */
  2017. void arm_sort_init_f32(
  2018. arm_sort_instance_f32 * S,
  2019. arm_sort_alg alg,
  2020. arm_sort_dir dir);
  2021. /**
  2022. * @brief Instance structure for the sorting algorithms.
  2023. */
  2024. typedef struct
  2025. {
  2026. arm_sort_dir dir; /**< Sorting order (direction) */
  2027. float32_t * buffer; /**< Working buffer */
  2028. } arm_merge_sort_instance_f32;
  2029. /**
  2030. * @param[in] S points to an instance of the sorting structure.
  2031. * @param[in,out] pSrc points to the block of input data.
  2032. * @param[out] pDst points to the block of output data
  2033. * @param[in] blockSize number of samples to process.
  2034. */
  2035. void arm_merge_sort_f32(
  2036. const arm_merge_sort_instance_f32 * S,
  2037. float32_t *pSrc,
  2038. float32_t *pDst,
  2039. uint32_t blockSize);
  2040. /**
  2041. * @param[in,out] S points to an instance of the sorting structure.
  2042. * @param[in] dir Sorting order.
  2043. * @param[in] buffer Working buffer.
  2044. */
  2045. void arm_merge_sort_init_f32(
  2046. arm_merge_sort_instance_f32 * S,
  2047. arm_sort_dir dir,
  2048. float32_t * buffer);
  2049. /**
  2050. * @brief Struct for specifying cubic spline type
  2051. */
  2052. typedef enum
  2053. {
  2054. ARM_SPLINE_NATURAL = 0, /**< Natural spline */
  2055. ARM_SPLINE_PARABOLIC_RUNOUT = 1 /**< Parabolic runout spline */
  2056. } arm_spline_type;
  2057. /**
  2058. * @brief Instance structure for the floating-point cubic spline interpolation.
  2059. */
  2060. typedef struct
  2061. {
  2062. arm_spline_type type; /**< Type (boundary conditions) */
  2063. const float32_t * x; /**< x values */
  2064. const float32_t * y; /**< y values */
  2065. uint32_t n_x; /**< Number of known data points */
  2066. float32_t * coeffs; /**< Coefficients buffer (b,c, and d) */
  2067. } arm_spline_instance_f32;
  2068. /**
  2069. * @brief Processing function for the floating-point cubic spline interpolation.
  2070. * @param[in] S points to an instance of the floating-point spline structure.
  2071. * @param[in] xq points to the x values ot the interpolated data points.
  2072. * @param[out] pDst points to the block of output data.
  2073. * @param[in] blockSize number of samples of output data.
  2074. */
  2075. void arm_spline_f32(
  2076. arm_spline_instance_f32 * S,
  2077. const float32_t * xq,
  2078. float32_t * pDst,
  2079. uint32_t blockSize);
  2080. /**
  2081. * @brief Initialization function for the floating-point cubic spline interpolation.
  2082. * @param[in,out] S points to an instance of the floating-point spline structure.
  2083. * @param[in] type type of cubic spline interpolation (boundary conditions)
  2084. * @param[in] x points to the x values of the known data points.
  2085. * @param[in] y points to the y values of the known data points.
  2086. * @param[in] n number of known data points.
  2087. * @param[in] coeffs coefficients array for b, c, and d
  2088. * @param[in] tempBuffer buffer array for internal computations
  2089. */
  2090. void arm_spline_init_f32(
  2091. arm_spline_instance_f32 * S,
  2092. arm_spline_type type,
  2093. const float32_t * x,
  2094. const float32_t * y,
  2095. uint32_t n,
  2096. float32_t * coeffs,
  2097. float32_t * tempBuffer);
  2098. /**
  2099. * @brief Instance structure for the floating-point matrix structure.
  2100. */
  2101. typedef struct
  2102. {
  2103. uint16_t numRows; /**< number of rows of the matrix. */
  2104. uint16_t numCols; /**< number of columns of the matrix. */
  2105. float32_t *pData; /**< points to the data of the matrix. */
  2106. } arm_matrix_instance_f32;
  2107. /**
  2108. * @brief Instance structure for the floating-point matrix structure.
  2109. */
  2110. typedef struct
  2111. {
  2112. uint16_t numRows; /**< number of rows of the matrix. */
  2113. uint16_t numCols; /**< number of columns of the matrix. */
  2114. float64_t *pData; /**< points to the data of the matrix. */
  2115. } arm_matrix_instance_f64;
  2116. /**
  2117. * @brief Instance structure for the Q15 matrix structure.
  2118. */
  2119. typedef struct
  2120. {
  2121. uint16_t numRows; /**< number of rows of the matrix. */
  2122. uint16_t numCols; /**< number of columns of the matrix. */
  2123. q15_t *pData; /**< points to the data of the matrix. */
  2124. } arm_matrix_instance_q15;
  2125. /**
  2126. * @brief Instance structure for the Q31 matrix structure.
  2127. */
  2128. typedef struct
  2129. {
  2130. uint16_t numRows; /**< number of rows of the matrix. */
  2131. uint16_t numCols; /**< number of columns of the matrix. */
  2132. q31_t *pData; /**< points to the data of the matrix. */
  2133. } arm_matrix_instance_q31;
  2134. /**
  2135. * @brief Floating-point matrix addition.
  2136. * @param[in] pSrcA points to the first input matrix structure
  2137. * @param[in] pSrcB points to the second input matrix structure
  2138. * @param[out] pDst points to output matrix structure
  2139. * @return The function returns either
  2140. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2141. */
  2142. arm_status arm_mat_add_f32(
  2143. const arm_matrix_instance_f32 * pSrcA,
  2144. const arm_matrix_instance_f32 * pSrcB,
  2145. arm_matrix_instance_f32 * pDst);
  2146. /**
  2147. * @brief Q15 matrix addition.
  2148. * @param[in] pSrcA points to the first input matrix structure
  2149. * @param[in] pSrcB points to the second input matrix structure
  2150. * @param[out] pDst points to output matrix structure
  2151. * @return The function returns either
  2152. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2153. */
  2154. arm_status arm_mat_add_q15(
  2155. const arm_matrix_instance_q15 * pSrcA,
  2156. const arm_matrix_instance_q15 * pSrcB,
  2157. arm_matrix_instance_q15 * pDst);
  2158. /**
  2159. * @brief Q31 matrix addition.
  2160. * @param[in] pSrcA points to the first input matrix structure
  2161. * @param[in] pSrcB points to the second input matrix structure
  2162. * @param[out] pDst points to output matrix structure
  2163. * @return The function returns either
  2164. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2165. */
  2166. arm_status arm_mat_add_q31(
  2167. const arm_matrix_instance_q31 * pSrcA,
  2168. const arm_matrix_instance_q31 * pSrcB,
  2169. arm_matrix_instance_q31 * pDst);
  2170. /**
  2171. * @brief Floating-point, complex, matrix multiplication.
  2172. * @param[in] pSrcA points to the first input matrix structure
  2173. * @param[in] pSrcB points to the second input matrix structure
  2174. * @param[out] pDst points to output matrix structure
  2175. * @return The function returns either
  2176. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2177. */
  2178. arm_status arm_mat_cmplx_mult_f32(
  2179. const arm_matrix_instance_f32 * pSrcA,
  2180. const arm_matrix_instance_f32 * pSrcB,
  2181. arm_matrix_instance_f32 * pDst);
  2182. /**
  2183. * @brief Q15, complex, matrix multiplication.
  2184. * @param[in] pSrcA points to the first input matrix structure
  2185. * @param[in] pSrcB points to the second input matrix structure
  2186. * @param[out] pDst points to output matrix structure
  2187. * @return The function returns either
  2188. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2189. */
  2190. arm_status arm_mat_cmplx_mult_q15(
  2191. const arm_matrix_instance_q15 * pSrcA,
  2192. const arm_matrix_instance_q15 * pSrcB,
  2193. arm_matrix_instance_q15 * pDst,
  2194. q15_t * pScratch);
  2195. /**
  2196. * @brief Q31, complex, matrix multiplication.
  2197. * @param[in] pSrcA points to the first input matrix structure
  2198. * @param[in] pSrcB points to the second input matrix structure
  2199. * @param[out] pDst points to output matrix structure
  2200. * @return The function returns either
  2201. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2202. */
  2203. arm_status arm_mat_cmplx_mult_q31(
  2204. const arm_matrix_instance_q31 * pSrcA,
  2205. const arm_matrix_instance_q31 * pSrcB,
  2206. arm_matrix_instance_q31 * pDst);
  2207. /**
  2208. * @brief Floating-point matrix transpose.
  2209. * @param[in] pSrc points to the input matrix
  2210. * @param[out] pDst points to the output matrix
  2211. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  2212. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2213. */
  2214. arm_status arm_mat_trans_f32(
  2215. const arm_matrix_instance_f32 * pSrc,
  2216. arm_matrix_instance_f32 * pDst);
  2217. /**
  2218. * @brief Q15 matrix transpose.
  2219. * @param[in] pSrc points to the input matrix
  2220. * @param[out] pDst points to the output matrix
  2221. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  2222. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2223. */
  2224. arm_status arm_mat_trans_q15(
  2225. const arm_matrix_instance_q15 * pSrc,
  2226. arm_matrix_instance_q15 * pDst);
  2227. /**
  2228. * @brief Q31 matrix transpose.
  2229. * @param[in] pSrc points to the input matrix
  2230. * @param[out] pDst points to the output matrix
  2231. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  2232. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2233. */
  2234. arm_status arm_mat_trans_q31(
  2235. const arm_matrix_instance_q31 * pSrc,
  2236. arm_matrix_instance_q31 * pDst);
  2237. /**
  2238. * @brief Floating-point matrix multiplication
  2239. * @param[in] pSrcA points to the first input matrix structure
  2240. * @param[in] pSrcB points to the second input matrix structure
  2241. * @param[out] pDst points to output matrix structure
  2242. * @return The function returns either
  2243. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2244. */
  2245. arm_status arm_mat_mult_f32(
  2246. const arm_matrix_instance_f32 * pSrcA,
  2247. const arm_matrix_instance_f32 * pSrcB,
  2248. arm_matrix_instance_f32 * pDst);
  2249. /**
  2250. * @brief Q15 matrix multiplication
  2251. * @param[in] pSrcA points to the first input matrix structure
  2252. * @param[in] pSrcB points to the second input matrix structure
  2253. * @param[out] pDst points to output matrix structure
  2254. * @param[in] pState points to the array for storing intermediate results
  2255. * @return The function returns either
  2256. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2257. */
  2258. arm_status arm_mat_mult_q15(
  2259. const arm_matrix_instance_q15 * pSrcA,
  2260. const arm_matrix_instance_q15 * pSrcB,
  2261. arm_matrix_instance_q15 * pDst,
  2262. q15_t * pState);
  2263. /**
  2264. * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  2265. * @param[in] pSrcA points to the first input matrix structure
  2266. * @param[in] pSrcB points to the second input matrix structure
  2267. * @param[out] pDst points to output matrix structure
  2268. * @param[in] pState points to the array for storing intermediate results
  2269. * @return The function returns either
  2270. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2271. */
  2272. arm_status arm_mat_mult_fast_q15(
  2273. const arm_matrix_instance_q15 * pSrcA,
  2274. const arm_matrix_instance_q15 * pSrcB,
  2275. arm_matrix_instance_q15 * pDst,
  2276. q15_t * pState);
  2277. /**
  2278. * @brief Q31 matrix multiplication
  2279. * @param[in] pSrcA points to the first input matrix structure
  2280. * @param[in] pSrcB points to the second input matrix structure
  2281. * @param[out] pDst points to output matrix structure
  2282. * @return The function returns either
  2283. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2284. */
  2285. arm_status arm_mat_mult_q31(
  2286. const arm_matrix_instance_q31 * pSrcA,
  2287. const arm_matrix_instance_q31 * pSrcB,
  2288. arm_matrix_instance_q31 * pDst);
  2289. /**
  2290. * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  2291. * @param[in] pSrcA points to the first input matrix structure
  2292. * @param[in] pSrcB points to the second input matrix structure
  2293. * @param[out] pDst points to output matrix structure
  2294. * @return The function returns either
  2295. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2296. */
  2297. arm_status arm_mat_mult_fast_q31(
  2298. const arm_matrix_instance_q31 * pSrcA,
  2299. const arm_matrix_instance_q31 * pSrcB,
  2300. arm_matrix_instance_q31 * pDst);
  2301. /**
  2302. * @brief Floating-point matrix subtraction
  2303. * @param[in] pSrcA points to the first input matrix structure
  2304. * @param[in] pSrcB points to the second input matrix structure
  2305. * @param[out] pDst points to output matrix structure
  2306. * @return The function returns either
  2307. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2308. */
  2309. arm_status arm_mat_sub_f32(
  2310. const arm_matrix_instance_f32 * pSrcA,
  2311. const arm_matrix_instance_f32 * pSrcB,
  2312. arm_matrix_instance_f32 * pDst);
  2313. /**
  2314. * @brief Q15 matrix subtraction
  2315. * @param[in] pSrcA points to the first input matrix structure
  2316. * @param[in] pSrcB points to the second input matrix structure
  2317. * @param[out] pDst points to output matrix structure
  2318. * @return The function returns either
  2319. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2320. */
  2321. arm_status arm_mat_sub_q15(
  2322. const arm_matrix_instance_q15 * pSrcA,
  2323. const arm_matrix_instance_q15 * pSrcB,
  2324. arm_matrix_instance_q15 * pDst);
  2325. /**
  2326. * @brief Q31 matrix subtraction
  2327. * @param[in] pSrcA points to the first input matrix structure
  2328. * @param[in] pSrcB points to the second input matrix structure
  2329. * @param[out] pDst points to output matrix structure
  2330. * @return The function returns either
  2331. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2332. */
  2333. arm_status arm_mat_sub_q31(
  2334. const arm_matrix_instance_q31 * pSrcA,
  2335. const arm_matrix_instance_q31 * pSrcB,
  2336. arm_matrix_instance_q31 * pDst);
  2337. /**
  2338. * @brief Floating-point matrix scaling.
  2339. * @param[in] pSrc points to the input matrix
  2340. * @param[in] scale scale factor
  2341. * @param[out] pDst points to the output matrix
  2342. * @return The function returns either
  2343. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2344. */
  2345. arm_status arm_mat_scale_f32(
  2346. const arm_matrix_instance_f32 * pSrc,
  2347. float32_t scale,
  2348. arm_matrix_instance_f32 * pDst);
  2349. /**
  2350. * @brief Q15 matrix scaling.
  2351. * @param[in] pSrc points to input matrix
  2352. * @param[in] scaleFract fractional portion of the scale factor
  2353. * @param[in] shift number of bits to shift the result by
  2354. * @param[out] pDst points to output matrix
  2355. * @return The function returns either
  2356. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2357. */
  2358. arm_status arm_mat_scale_q15(
  2359. const arm_matrix_instance_q15 * pSrc,
  2360. q15_t scaleFract,
  2361. int32_t shift,
  2362. arm_matrix_instance_q15 * pDst);
  2363. /**
  2364. * @brief Q31 matrix scaling.
  2365. * @param[in] pSrc points to input matrix
  2366. * @param[in] scaleFract fractional portion of the scale factor
  2367. * @param[in] shift number of bits to shift the result by
  2368. * @param[out] pDst points to output matrix structure
  2369. * @return The function returns either
  2370. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  2371. */
  2372. arm_status arm_mat_scale_q31(
  2373. const arm_matrix_instance_q31 * pSrc,
  2374. q31_t scaleFract,
  2375. int32_t shift,
  2376. arm_matrix_instance_q31 * pDst);
  2377. /**
  2378. * @brief Q31 matrix initialization.
  2379. * @param[in,out] S points to an instance of the floating-point matrix structure.
  2380. * @param[in] nRows number of rows in the matrix.
  2381. * @param[in] nColumns number of columns in the matrix.
  2382. * @param[in] pData points to the matrix data array.
  2383. */
  2384. void arm_mat_init_q31(
  2385. arm_matrix_instance_q31 * S,
  2386. uint16_t nRows,
  2387. uint16_t nColumns,
  2388. q31_t * pData);
  2389. /**
  2390. * @brief Q15 matrix initialization.
  2391. * @param[in,out] S points to an instance of the floating-point matrix structure.
  2392. * @param[in] nRows number of rows in the matrix.
  2393. * @param[in] nColumns number of columns in the matrix.
  2394. * @param[in] pData points to the matrix data array.
  2395. */
  2396. void arm_mat_init_q15(
  2397. arm_matrix_instance_q15 * S,
  2398. uint16_t nRows,
  2399. uint16_t nColumns,
  2400. q15_t * pData);
  2401. /**
  2402. * @brief Floating-point matrix initialization.
  2403. * @param[in,out] S points to an instance of the floating-point matrix structure.
  2404. * @param[in] nRows number of rows in the matrix.
  2405. * @param[in] nColumns number of columns in the matrix.
  2406. * @param[in] pData points to the matrix data array.
  2407. */
  2408. void arm_mat_init_f32(
  2409. arm_matrix_instance_f32 * S,
  2410. uint16_t nRows,
  2411. uint16_t nColumns,
  2412. float32_t * pData);
  2413. /**
  2414. * @brief Instance structure for the Q15 PID Control.
  2415. */
  2416. typedef struct
  2417. {
  2418. q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  2419. #if !defined (ARM_MATH_DSP)
  2420. q15_t A1;
  2421. q15_t A2;
  2422. #else
  2423. q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
  2424. #endif
  2425. q15_t state[3]; /**< The state array of length 3. */
  2426. q15_t Kp; /**< The proportional gain. */
  2427. q15_t Ki; /**< The integral gain. */
  2428. q15_t Kd; /**< The derivative gain. */
  2429. } arm_pid_instance_q15;
  2430. /**
  2431. * @brief Instance structure for the Q31 PID Control.
  2432. */
  2433. typedef struct
  2434. {
  2435. q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  2436. q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  2437. q31_t A2; /**< The derived gain, A2 = Kd . */
  2438. q31_t state[3]; /**< The state array of length 3. */
  2439. q31_t Kp; /**< The proportional gain. */
  2440. q31_t Ki; /**< The integral gain. */
  2441. q31_t Kd; /**< The derivative gain. */
  2442. } arm_pid_instance_q31;
  2443. /**
  2444. * @brief Instance structure for the floating-point PID Control.
  2445. */
  2446. typedef struct
  2447. {
  2448. float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  2449. float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  2450. float32_t A2; /**< The derived gain, A2 = Kd . */
  2451. float32_t state[3]; /**< The state array of length 3. */
  2452. float32_t Kp; /**< The proportional gain. */
  2453. float32_t Ki; /**< The integral gain. */
  2454. float32_t Kd; /**< The derivative gain. */
  2455. } arm_pid_instance_f32;
  2456. /**
  2457. * @brief Initialization function for the floating-point PID Control.
  2458. * @param[in,out] S points to an instance of the PID structure.
  2459. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  2460. */
  2461. void arm_pid_init_f32(
  2462. arm_pid_instance_f32 * S,
  2463. int32_t resetStateFlag);
  2464. /**
  2465. * @brief Reset function for the floating-point PID Control.
  2466. * @param[in,out] S is an instance of the floating-point PID Control structure
  2467. */
  2468. void arm_pid_reset_f32(
  2469. arm_pid_instance_f32 * S);
  2470. /**
  2471. * @brief Initialization function for the Q31 PID Control.
  2472. * @param[in,out] S points to an instance of the Q15 PID structure.
  2473. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  2474. */
  2475. void arm_pid_init_q31(
  2476. arm_pid_instance_q31 * S,
  2477. int32_t resetStateFlag);
  2478. /**
  2479. * @brief Reset function for the Q31 PID Control.
  2480. * @param[in,out] S points to an instance of the Q31 PID Control structure
  2481. */
  2482. void arm_pid_reset_q31(
  2483. arm_pid_instance_q31 * S);
  2484. /**
  2485. * @brief Initialization function for the Q15 PID Control.
  2486. * @param[in,out] S points to an instance of the Q15 PID structure.
  2487. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  2488. */
  2489. void arm_pid_init_q15(
  2490. arm_pid_instance_q15 * S,
  2491. int32_t resetStateFlag);
  2492. /**
  2493. * @brief Reset function for the Q15 PID Control.
  2494. * @param[in,out] S points to an instance of the q15 PID Control structure
  2495. */
  2496. void arm_pid_reset_q15(
  2497. arm_pid_instance_q15 * S);
  2498. /**
  2499. * @brief Instance structure for the floating-point Linear Interpolate function.
  2500. */
  2501. typedef struct
  2502. {
  2503. uint32_t nValues; /**< nValues */
  2504. float32_t x1; /**< x1 */
  2505. float32_t xSpacing; /**< xSpacing */
  2506. float32_t *pYData; /**< pointer to the table of Y values */
  2507. } arm_linear_interp_instance_f32;
  2508. /**
  2509. * @brief Instance structure for the floating-point bilinear interpolation function.
  2510. */
  2511. typedef struct
  2512. {
  2513. uint16_t numRows; /**< number of rows in the data table. */
  2514. uint16_t numCols; /**< number of columns in the data table. */
  2515. float32_t *pData; /**< points to the data table. */
  2516. } arm_bilinear_interp_instance_f32;
  2517. /**
  2518. * @brief Instance structure for the Q31 bilinear interpolation function.
  2519. */
  2520. typedef struct
  2521. {
  2522. uint16_t numRows; /**< number of rows in the data table. */
  2523. uint16_t numCols; /**< number of columns in the data table. */
  2524. q31_t *pData; /**< points to the data table. */
  2525. } arm_bilinear_interp_instance_q31;
  2526. /**
  2527. * @brief Instance structure for the Q15 bilinear interpolation function.
  2528. */
  2529. typedef struct
  2530. {
  2531. uint16_t numRows; /**< number of rows in the data table. */
  2532. uint16_t numCols; /**< number of columns in the data table. */
  2533. q15_t *pData; /**< points to the data table. */
  2534. } arm_bilinear_interp_instance_q15;
  2535. /**
  2536. * @brief Instance structure for the Q15 bilinear interpolation function.
  2537. */
  2538. typedef struct
  2539. {
  2540. uint16_t numRows; /**< number of rows in the data table. */
  2541. uint16_t numCols; /**< number of columns in the data table. */
  2542. q7_t *pData; /**< points to the data table. */
  2543. } arm_bilinear_interp_instance_q7;
  2544. /**
  2545. * @brief Q7 vector multiplication.
  2546. * @param[in] pSrcA points to the first input vector
  2547. * @param[in] pSrcB points to the second input vector
  2548. * @param[out] pDst points to the output vector
  2549. * @param[in] blockSize number of samples in each vector
  2550. */
  2551. void arm_mult_q7(
  2552. const q7_t * pSrcA,
  2553. const q7_t * pSrcB,
  2554. q7_t * pDst,
  2555. uint32_t blockSize);
  2556. /**
  2557. * @brief Q15 vector multiplication.
  2558. * @param[in] pSrcA points to the first input vector
  2559. * @param[in] pSrcB points to the second input vector
  2560. * @param[out] pDst points to the output vector
  2561. * @param[in] blockSize number of samples in each vector
  2562. */
  2563. void arm_mult_q15(
  2564. const q15_t * pSrcA,
  2565. const q15_t * pSrcB,
  2566. q15_t * pDst,
  2567. uint32_t blockSize);
  2568. /**
  2569. * @brief Q31 vector multiplication.
  2570. * @param[in] pSrcA points to the first input vector
  2571. * @param[in] pSrcB points to the second input vector
  2572. * @param[out] pDst points to the output vector
  2573. * @param[in] blockSize number of samples in each vector
  2574. */
  2575. void arm_mult_q31(
  2576. const q31_t * pSrcA,
  2577. const q31_t * pSrcB,
  2578. q31_t * pDst,
  2579. uint32_t blockSize);
  2580. /**
  2581. * @brief Floating-point vector multiplication.
  2582. * @param[in] pSrcA points to the first input vector
  2583. * @param[in] pSrcB points to the second input vector
  2584. * @param[out] pDst points to the output vector
  2585. * @param[in] blockSize number of samples in each vector
  2586. */
  2587. void arm_mult_f32(
  2588. const float32_t * pSrcA,
  2589. const float32_t * pSrcB,
  2590. float32_t * pDst,
  2591. uint32_t blockSize);
  2592. #if !defined( __CC_ARM )
  2593. /**
  2594. * @brief Floating-point vector multiplication.
  2595. * @param[in] pSrcA points to the first input vector
  2596. * @param[in] pSrcB points to the second input vector
  2597. * @param[out] pDst points to the output vector
  2598. * @param[in] blockSize number of samples in each vector
  2599. */
  2600. void arm_mult_f16(
  2601. const float16_t * pSrcA,
  2602. const float16_t * pSrcB,
  2603. float16_t * pDst,
  2604. uint32_t blockSize);
  2605. #endif
  2606. /**
  2607. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  2608. */
  2609. typedef struct
  2610. {
  2611. uint16_t fftLen; /**< length of the FFT. */
  2612. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2613. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2614. const q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
  2615. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2616. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2617. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2618. } arm_cfft_radix2_instance_q15;
  2619. /* Deprecated */
  2620. arm_status arm_cfft_radix2_init_q15(
  2621. arm_cfft_radix2_instance_q15 * S,
  2622. uint16_t fftLen,
  2623. uint8_t ifftFlag,
  2624. uint8_t bitReverseFlag);
  2625. /* Deprecated */
  2626. void arm_cfft_radix2_q15(
  2627. const arm_cfft_radix2_instance_q15 * S,
  2628. q15_t * pSrc);
  2629. /**
  2630. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  2631. */
  2632. typedef struct
  2633. {
  2634. uint16_t fftLen; /**< length of the FFT. */
  2635. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2636. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2637. const q15_t *pTwiddle; /**< points to the twiddle factor table. */
  2638. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2639. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2640. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2641. } arm_cfft_radix4_instance_q15;
  2642. /* Deprecated */
  2643. arm_status arm_cfft_radix4_init_q15(
  2644. arm_cfft_radix4_instance_q15 * S,
  2645. uint16_t fftLen,
  2646. uint8_t ifftFlag,
  2647. uint8_t bitReverseFlag);
  2648. /* Deprecated */
  2649. void arm_cfft_radix4_q15(
  2650. const arm_cfft_radix4_instance_q15 * S,
  2651. q15_t * pSrc);
  2652. /**
  2653. * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
  2654. */
  2655. typedef struct
  2656. {
  2657. uint16_t fftLen; /**< length of the FFT. */
  2658. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2659. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2660. const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  2661. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2662. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2663. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2664. } arm_cfft_radix2_instance_q31;
  2665. /* Deprecated */
  2666. arm_status arm_cfft_radix2_init_q31(
  2667. arm_cfft_radix2_instance_q31 * S,
  2668. uint16_t fftLen,
  2669. uint8_t ifftFlag,
  2670. uint8_t bitReverseFlag);
  2671. /* Deprecated */
  2672. void arm_cfft_radix2_q31(
  2673. const arm_cfft_radix2_instance_q31 * S,
  2674. q31_t * pSrc);
  2675. /**
  2676. * @brief Instance structure for the Q31 CFFT/CIFFT function.
  2677. */
  2678. typedef struct
  2679. {
  2680. uint16_t fftLen; /**< length of the FFT. */
  2681. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2682. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2683. const q31_t *pTwiddle; /**< points to the twiddle factor table. */
  2684. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2685. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2686. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2687. } arm_cfft_radix4_instance_q31;
  2688. /* Deprecated */
  2689. void arm_cfft_radix4_q31(
  2690. const arm_cfft_radix4_instance_q31 * S,
  2691. q31_t * pSrc);
  2692. /* Deprecated */
  2693. arm_status arm_cfft_radix4_init_q31(
  2694. arm_cfft_radix4_instance_q31 * S,
  2695. uint16_t fftLen,
  2696. uint8_t ifftFlag,
  2697. uint8_t bitReverseFlag);
  2698. /**
  2699. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  2700. */
  2701. typedef struct
  2702. {
  2703. uint16_t fftLen; /**< length of the FFT. */
  2704. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2705. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2706. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  2707. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2708. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2709. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2710. float32_t onebyfftLen; /**< value of 1/fftLen. */
  2711. } arm_cfft_radix2_instance_f32;
  2712. /**
  2713. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  2714. */
  2715. #if !defined( __CC_ARM )
  2716. typedef struct
  2717. {
  2718. uint16_t fftLen; /**< length of the FFT. */
  2719. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2720. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2721. const float16_t *pTwiddle; /**< points to the Twiddle factor table. */
  2722. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2723. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2724. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2725. float16_t onebyfftLen; /**< value of 1/fftLen. */
  2726. } arm_cfft_radix2_instance_f16;
  2727. #endif
  2728. /* Deprecated */
  2729. arm_status arm_cfft_radix2_init_f32(
  2730. arm_cfft_radix2_instance_f32 * S,
  2731. uint16_t fftLen,
  2732. uint8_t ifftFlag,
  2733. uint8_t bitReverseFlag);
  2734. /* Deprecated */
  2735. void arm_cfft_radix2_f32(
  2736. const arm_cfft_radix2_instance_f32 * S,
  2737. float32_t * pSrc);
  2738. /**
  2739. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  2740. */
  2741. typedef struct
  2742. {
  2743. uint16_t fftLen; /**< length of the FFT. */
  2744. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2745. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2746. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  2747. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2748. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2749. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2750. float32_t onebyfftLen; /**< value of 1/fftLen. */
  2751. } arm_cfft_radix4_instance_f32;
  2752. /**
  2753. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  2754. */
  2755. #if !defined( __CC_ARM )
  2756. typedef struct
  2757. {
  2758. uint16_t fftLen; /**< length of the FFT. */
  2759. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  2760. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  2761. const float16_t *pTwiddle; /**< points to the Twiddle factor table. */
  2762. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2763. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2764. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  2765. float16_t onebyfftLen; /**< value of 1/fftLen. */
  2766. } arm_cfft_radix4_instance_f16;
  2767. #endif
  2768. /* Deprecated */
  2769. arm_status arm_cfft_radix4_init_f32(
  2770. arm_cfft_radix4_instance_f32 * S,
  2771. uint16_t fftLen,
  2772. uint8_t ifftFlag,
  2773. uint8_t bitReverseFlag);
  2774. /* Deprecated */
  2775. void arm_cfft_radix4_f32(
  2776. const arm_cfft_radix4_instance_f32 * S,
  2777. float32_t * pSrc);
  2778. /**
  2779. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  2780. */
  2781. typedef struct
  2782. {
  2783. uint16_t fftLen; /**< length of the FFT. */
  2784. const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
  2785. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2786. uint16_t bitRevLength; /**< bit reversal table length. */
  2787. #if defined(ARM_MATH_MVEI)
  2788. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  2789. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  2790. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  2791. const q15_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  2792. const q15_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  2793. const q15_t *rearranged_twiddle_stride3;
  2794. #endif
  2795. } arm_cfft_instance_q15;
  2796. arm_status arm_cfft_init_q15(
  2797. arm_cfft_instance_q15 * S,
  2798. uint16_t fftLen);
  2799. void arm_cfft_q15(
  2800. const arm_cfft_instance_q15 * S,
  2801. q15_t * p1,
  2802. uint8_t ifftFlag,
  2803. uint8_t bitReverseFlag);
  2804. /**
  2805. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  2806. */
  2807. typedef struct
  2808. {
  2809. uint16_t fftLen; /**< length of the FFT. */
  2810. const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  2811. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2812. uint16_t bitRevLength; /**< bit reversal table length. */
  2813. #if defined(ARM_MATH_MVEI)
  2814. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  2815. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  2816. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  2817. const q31_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  2818. const q31_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  2819. const q31_t *rearranged_twiddle_stride3;
  2820. #endif
  2821. } arm_cfft_instance_q31;
  2822. arm_status arm_cfft_init_q31(
  2823. arm_cfft_instance_q31 * S,
  2824. uint16_t fftLen);
  2825. void arm_cfft_q31(
  2826. const arm_cfft_instance_q31 * S,
  2827. q31_t * p1,
  2828. uint8_t ifftFlag,
  2829. uint8_t bitReverseFlag);
  2830. /**
  2831. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  2832. */
  2833. typedef struct
  2834. {
  2835. uint16_t fftLen; /**< length of the FFT. */
  2836. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  2837. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2838. uint16_t bitRevLength; /**< bit reversal table length. */
  2839. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  2840. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  2841. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  2842. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  2843. const float32_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  2844. const float32_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  2845. const float32_t *rearranged_twiddle_stride3;
  2846. #endif
  2847. } arm_cfft_instance_f32;
  2848. /**
  2849. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  2850. */
  2851. #if !defined( __CC_ARM )
  2852. typedef struct
  2853. {
  2854. uint16_t fftLen; /**< length of the FFT. */
  2855. const float16_t *pTwiddle; /**< points to the Twiddle factor table. */
  2856. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2857. uint16_t bitRevLength; /**< bit reversal table length. */
  2858. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  2859. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  2860. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  2861. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  2862. const float16_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  2863. const float16_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  2864. const float16_t *rearranged_twiddle_stride3;
  2865. #endif
  2866. } arm_cfft_instance_f16;
  2867. #endif
  2868. arm_status arm_cfft_init_f32(
  2869. arm_cfft_instance_f32 * S,
  2870. uint16_t fftLen);
  2871. void arm_cfft_f32(
  2872. const arm_cfft_instance_f32 * S,
  2873. float32_t * p1,
  2874. uint8_t ifftFlag,
  2875. uint8_t bitReverseFlag);
  2876. #if !defined( __CC_ARM )
  2877. arm_status arm_cfft_init_f16(
  2878. arm_cfft_instance_f16 * S,
  2879. uint16_t fftLen);
  2880. void arm_cfft_f16(
  2881. const arm_cfft_instance_f16 * S,
  2882. float16_t * p1,
  2883. uint8_t ifftFlag,
  2884. uint8_t bitReverseFlag);
  2885. #endif
  2886. /**
  2887. * @brief Instance structure for the Double Precision Floating-point CFFT/CIFFT function.
  2888. */
  2889. typedef struct
  2890. {
  2891. uint16_t fftLen; /**< length of the FFT. */
  2892. const float64_t *pTwiddle; /**< points to the Twiddle factor table. */
  2893. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  2894. uint16_t bitRevLength; /**< bit reversal table length. */
  2895. } arm_cfft_instance_f64;
  2896. arm_status arm_cfft_init_f64(
  2897. arm_cfft_instance_f64 * S,
  2898. uint16_t fftLen);
  2899. void arm_cfft_f64(
  2900. const arm_cfft_instance_f64 * S,
  2901. float64_t * p1,
  2902. uint8_t ifftFlag,
  2903. uint8_t bitReverseFlag);
  2904. /**
  2905. * @brief Instance structure for the Q15 RFFT/RIFFT function.
  2906. */
  2907. typedef struct
  2908. {
  2909. uint32_t fftLenReal; /**< length of the real FFT. */
  2910. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  2911. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  2912. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2913. const q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  2914. const q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  2915. #if defined(ARM_MATH_MVEI)
  2916. arm_cfft_instance_q15 cfftInst;
  2917. #else
  2918. const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  2919. #endif
  2920. } arm_rfft_instance_q15;
  2921. arm_status arm_rfft_init_q15(
  2922. arm_rfft_instance_q15 * S,
  2923. uint32_t fftLenReal,
  2924. uint32_t ifftFlagR,
  2925. uint32_t bitReverseFlag);
  2926. void arm_rfft_q15(
  2927. const arm_rfft_instance_q15 * S,
  2928. q15_t * pSrc,
  2929. q15_t * pDst);
  2930. /**
  2931. * @brief Instance structure for the Q31 RFFT/RIFFT function.
  2932. */
  2933. typedef struct
  2934. {
  2935. uint32_t fftLenReal; /**< length of the real FFT. */
  2936. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  2937. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  2938. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2939. const q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  2940. const q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  2941. #if defined(ARM_MATH_MVEI)
  2942. arm_cfft_instance_q31 cfftInst;
  2943. #else
  2944. const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  2945. #endif
  2946. } arm_rfft_instance_q31;
  2947. arm_status arm_rfft_init_q31(
  2948. arm_rfft_instance_q31 * S,
  2949. uint32_t fftLenReal,
  2950. uint32_t ifftFlagR,
  2951. uint32_t bitReverseFlag);
  2952. void arm_rfft_q31(
  2953. const arm_rfft_instance_q31 * S,
  2954. q31_t * pSrc,
  2955. q31_t * pDst);
  2956. /**
  2957. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  2958. */
  2959. typedef struct
  2960. {
  2961. uint32_t fftLenReal; /**< length of the real FFT. */
  2962. uint16_t fftLenBy2; /**< length of the complex FFT. */
  2963. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  2964. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  2965. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  2966. const float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  2967. const float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  2968. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  2969. } arm_rfft_instance_f32;
  2970. arm_status arm_rfft_init_f32(
  2971. arm_rfft_instance_f32 * S,
  2972. arm_cfft_radix4_instance_f32 * S_CFFT,
  2973. uint32_t fftLenReal,
  2974. uint32_t ifftFlagR,
  2975. uint32_t bitReverseFlag);
  2976. void arm_rfft_f32(
  2977. const arm_rfft_instance_f32 * S,
  2978. float32_t * pSrc,
  2979. float32_t * pDst);
  2980. /**
  2981. * @brief Instance structure for the Double Precision Floating-point RFFT/RIFFT function.
  2982. */
  2983. typedef struct
  2984. {
  2985. arm_cfft_instance_f64 Sint; /**< Internal CFFT structure. */
  2986. uint16_t fftLenRFFT; /**< length of the real sequence */
  2987. const float64_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  2988. } arm_rfft_fast_instance_f64 ;
  2989. arm_status arm_rfft_fast_init_f64 (
  2990. arm_rfft_fast_instance_f64 * S,
  2991. uint16_t fftLen);
  2992. void arm_rfft_fast_f64(
  2993. arm_rfft_fast_instance_f64 * S,
  2994. float64_t * p, float64_t * pOut,
  2995. uint8_t ifftFlag);
  2996. /**
  2997. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  2998. */
  2999. typedef struct
  3000. {
  3001. arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
  3002. uint16_t fftLenRFFT; /**< length of the real sequence */
  3003. const float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  3004. } arm_rfft_fast_instance_f32 ;
  3005. arm_status arm_rfft_fast_init_f32 (
  3006. arm_rfft_fast_instance_f32 * S,
  3007. uint16_t fftLen);
  3008. void arm_rfft_fast_f32(
  3009. const arm_rfft_fast_instance_f32 * S,
  3010. float32_t * p, float32_t * pOut,
  3011. uint8_t ifftFlag);
  3012. /**
  3013. * @brief Instance structure for the floating-point DCT4/IDCT4 function.
  3014. */
  3015. typedef struct
  3016. {
  3017. uint16_t N; /**< length of the DCT4. */
  3018. uint16_t Nby2; /**< half of the length of the DCT4. */
  3019. float32_t normalize; /**< normalizing factor. */
  3020. const float32_t *pTwiddle; /**< points to the twiddle factor table. */
  3021. const float32_t *pCosFactor; /**< points to the cosFactor table. */
  3022. arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
  3023. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  3024. } arm_dct4_instance_f32;
  3025. /**
  3026. * @brief Initialization function for the floating-point DCT4/IDCT4.
  3027. * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure.
  3028. * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
  3029. * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
  3030. * @param[in] N length of the DCT4.
  3031. * @param[in] Nby2 half of the length of the DCT4.
  3032. * @param[in] normalize normalizing factor.
  3033. * @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.
  3034. */
  3035. arm_status arm_dct4_init_f32(
  3036. arm_dct4_instance_f32 * S,
  3037. arm_rfft_instance_f32 * S_RFFT,
  3038. arm_cfft_radix4_instance_f32 * S_CFFT,
  3039. uint16_t N,
  3040. uint16_t Nby2,
  3041. float32_t normalize);
  3042. /**
  3043. * @brief Processing function for the floating-point DCT4/IDCT4.
  3044. * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure.
  3045. * @param[in] pState points to state buffer.
  3046. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  3047. */
  3048. void arm_dct4_f32(
  3049. const arm_dct4_instance_f32 * S,
  3050. float32_t * pState,
  3051. float32_t * pInlineBuffer);
  3052. /**
  3053. * @brief Instance structure for the Q31 DCT4/IDCT4 function.
  3054. */
  3055. typedef struct
  3056. {
  3057. uint16_t N; /**< length of the DCT4. */
  3058. uint16_t Nby2; /**< half of the length of the DCT4. */
  3059. q31_t normalize; /**< normalizing factor. */
  3060. const q31_t *pTwiddle; /**< points to the twiddle factor table. */
  3061. const q31_t *pCosFactor; /**< points to the cosFactor table. */
  3062. arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
  3063. arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  3064. } arm_dct4_instance_q31;
  3065. /**
  3066. * @brief Initialization function for the Q31 DCT4/IDCT4.
  3067. * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure.
  3068. * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure
  3069. * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure
  3070. * @param[in] N length of the DCT4.
  3071. * @param[in] Nby2 half of the length of the DCT4.
  3072. * @param[in] normalize normalizing factor.
  3073. * @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.
  3074. */
  3075. arm_status arm_dct4_init_q31(
  3076. arm_dct4_instance_q31 * S,
  3077. arm_rfft_instance_q31 * S_RFFT,
  3078. arm_cfft_radix4_instance_q31 * S_CFFT,
  3079. uint16_t N,
  3080. uint16_t Nby2,
  3081. q31_t normalize);
  3082. /**
  3083. * @brief Processing function for the Q31 DCT4/IDCT4.
  3084. * @param[in] S points to an instance of the Q31 DCT4 structure.
  3085. * @param[in] pState points to state buffer.
  3086. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  3087. */
  3088. void arm_dct4_q31(
  3089. const arm_dct4_instance_q31 * S,
  3090. q31_t * pState,
  3091. q31_t * pInlineBuffer);
  3092. /**
  3093. * @brief Instance structure for the Q15 DCT4/IDCT4 function.
  3094. */
  3095. typedef struct
  3096. {
  3097. uint16_t N; /**< length of the DCT4. */
  3098. uint16_t Nby2; /**< half of the length of the DCT4. */
  3099. q15_t normalize; /**< normalizing factor. */
  3100. const q15_t *pTwiddle; /**< points to the twiddle factor table. */
  3101. const q15_t *pCosFactor; /**< points to the cosFactor table. */
  3102. arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
  3103. arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  3104. } arm_dct4_instance_q15;
  3105. /**
  3106. * @brief Initialization function for the Q15 DCT4/IDCT4.
  3107. * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure.
  3108. * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
  3109. * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
  3110. * @param[in] N length of the DCT4.
  3111. * @param[in] Nby2 half of the length of the DCT4.
  3112. * @param[in] normalize normalizing factor.
  3113. * @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.
  3114. */
  3115. arm_status arm_dct4_init_q15(
  3116. arm_dct4_instance_q15 * S,
  3117. arm_rfft_instance_q15 * S_RFFT,
  3118. arm_cfft_radix4_instance_q15 * S_CFFT,
  3119. uint16_t N,
  3120. uint16_t Nby2,
  3121. q15_t normalize);
  3122. /**
  3123. * @brief Processing function for the Q15 DCT4/IDCT4.
  3124. * @param[in] S points to an instance of the Q15 DCT4 structure.
  3125. * @param[in] pState points to state buffer.
  3126. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  3127. */
  3128. void arm_dct4_q15(
  3129. const arm_dct4_instance_q15 * S,
  3130. q15_t * pState,
  3131. q15_t * pInlineBuffer);
  3132. /**
  3133. * @brief Floating-point vector addition.
  3134. * @param[in] pSrcA points to the first input vector
  3135. * @param[in] pSrcB points to the second input vector
  3136. * @param[out] pDst points to the output vector
  3137. * @param[in] blockSize number of samples in each vector
  3138. */
  3139. void arm_add_f32(
  3140. const float32_t * pSrcA,
  3141. const float32_t * pSrcB,
  3142. float32_t * pDst,
  3143. uint32_t blockSize);
  3144. #if !defined( __CC_ARM )
  3145. /**
  3146. * @brief Floating-point vector addition.
  3147. * @param[in] pSrcA points to the first input vector
  3148. * @param[in] pSrcB points to the second input vector
  3149. * @param[out] pDst points to the output vector
  3150. * @param[in] blockSize number of samples in each vector
  3151. */
  3152. void arm_add_f16(
  3153. const float16_t * pSrcA,
  3154. const float16_t * pSrcB,
  3155. float16_t * pDst,
  3156. uint32_t blockSize);
  3157. #endif
  3158. /**
  3159. * @brief Q7 vector addition.
  3160. * @param[in] pSrcA points to the first input vector
  3161. * @param[in] pSrcB points to the second input vector
  3162. * @param[out] pDst points to the output vector
  3163. * @param[in] blockSize number of samples in each vector
  3164. */
  3165. void arm_add_q7(
  3166. const q7_t * pSrcA,
  3167. const q7_t * pSrcB,
  3168. q7_t * pDst,
  3169. uint32_t blockSize);
  3170. /**
  3171. * @brief Q15 vector addition.
  3172. * @param[in] pSrcA points to the first input vector
  3173. * @param[in] pSrcB points to the second input vector
  3174. * @param[out] pDst points to the output vector
  3175. * @param[in] blockSize number of samples in each vector
  3176. */
  3177. void arm_add_q15(
  3178. const q15_t * pSrcA,
  3179. const q15_t * pSrcB,
  3180. q15_t * pDst,
  3181. uint32_t blockSize);
  3182. /**
  3183. * @brief Q31 vector addition.
  3184. * @param[in] pSrcA points to the first input vector
  3185. * @param[in] pSrcB points to the second input vector
  3186. * @param[out] pDst points to the output vector
  3187. * @param[in] blockSize number of samples in each vector
  3188. */
  3189. void arm_add_q31(
  3190. const q31_t * pSrcA,
  3191. const q31_t * pSrcB,
  3192. q31_t * pDst,
  3193. uint32_t blockSize);
  3194. /**
  3195. * @brief Floating-point vector subtraction.
  3196. * @param[in] pSrcA points to the first input vector
  3197. * @param[in] pSrcB points to the second input vector
  3198. * @param[out] pDst points to the output vector
  3199. * @param[in] blockSize number of samples in each vector
  3200. */
  3201. void arm_sub_f32(
  3202. const float32_t * pSrcA,
  3203. const float32_t * pSrcB,
  3204. float32_t * pDst,
  3205. uint32_t blockSize);
  3206. #if !defined( __CC_ARM )
  3207. /**
  3208. * @brief Floating-point vector subtraction.
  3209. * @param[in] pSrcA points to the first input vector
  3210. * @param[in] pSrcB points to the second input vector
  3211. * @param[out] pDst points to the output vector
  3212. * @param[in] blockSize number of samples in each vector
  3213. */
  3214. void arm_sub_f16(
  3215. const float16_t * pSrcA,
  3216. const float16_t * pSrcB,
  3217. float16_t * pDst,
  3218. uint32_t blockSize);
  3219. #endif
  3220. /**
  3221. * @brief Q7 vector subtraction.
  3222. * @param[in] pSrcA points to the first input vector
  3223. * @param[in] pSrcB points to the second input vector
  3224. * @param[out] pDst points to the output vector
  3225. * @param[in] blockSize number of samples in each vector
  3226. */
  3227. void arm_sub_q7(
  3228. const q7_t * pSrcA,
  3229. const q7_t * pSrcB,
  3230. q7_t * pDst,
  3231. uint32_t blockSize);
  3232. /**
  3233. * @brief Q15 vector subtraction.
  3234. * @param[in] pSrcA points to the first input vector
  3235. * @param[in] pSrcB points to the second input vector
  3236. * @param[out] pDst points to the output vector
  3237. * @param[in] blockSize number of samples in each vector
  3238. */
  3239. void arm_sub_q15(
  3240. const q15_t * pSrcA,
  3241. const q15_t * pSrcB,
  3242. q15_t * pDst,
  3243. uint32_t blockSize);
  3244. /**
  3245. * @brief Q31 vector subtraction.
  3246. * @param[in] pSrcA points to the first input vector
  3247. * @param[in] pSrcB points to the second input vector
  3248. * @param[out] pDst points to the output vector
  3249. * @param[in] blockSize number of samples in each vector
  3250. */
  3251. void arm_sub_q31(
  3252. const q31_t * pSrcA,
  3253. const q31_t * pSrcB,
  3254. q31_t * pDst,
  3255. uint32_t blockSize);
  3256. /**
  3257. * @brief Multiplies a floating-point vector by a scalar.
  3258. * @param[in] pSrc points to the input vector
  3259. * @param[in] scale scale factor to be applied
  3260. * @param[out] pDst points to the output vector
  3261. * @param[in] blockSize number of samples in the vector
  3262. */
  3263. void arm_scale_f32(
  3264. const float32_t * pSrc,
  3265. float32_t scale,
  3266. float32_t * pDst,
  3267. uint32_t blockSize);
  3268. #if !defined( __CC_ARM )
  3269. /**
  3270. * @brief Multiplies a floating-point vector by a scalar.
  3271. * @param[in] pSrc points to the input vector
  3272. * @param[in] scale scale factor to be applied
  3273. * @param[out] pDst points to the output vector
  3274. * @param[in] blockSize number of samples in the vector
  3275. */
  3276. void arm_scale_f16(
  3277. const float16_t * pSrc,
  3278. float16_t scale,
  3279. float16_t * pDst,
  3280. uint32_t blockSize);
  3281. #endif
  3282. /**
  3283. * @brief Multiplies a Q7 vector by a scalar.
  3284. * @param[in] pSrc points to the input vector
  3285. * @param[in] scaleFract fractional portion of the scale value
  3286. * @param[in] shift number of bits to shift the result by
  3287. * @param[out] pDst points to the output vector
  3288. * @param[in] blockSize number of samples in the vector
  3289. */
  3290. void arm_scale_q7(
  3291. const q7_t * pSrc,
  3292. q7_t scaleFract,
  3293. int8_t shift,
  3294. q7_t * pDst,
  3295. uint32_t blockSize);
  3296. /**
  3297. * @brief Multiplies a Q15 vector by a scalar.
  3298. * @param[in] pSrc points to the input vector
  3299. * @param[in] scaleFract fractional portion of the scale value
  3300. * @param[in] shift number of bits to shift the result by
  3301. * @param[out] pDst points to the output vector
  3302. * @param[in] blockSize number of samples in the vector
  3303. */
  3304. void arm_scale_q15(
  3305. const q15_t * pSrc,
  3306. q15_t scaleFract,
  3307. int8_t shift,
  3308. q15_t * pDst,
  3309. uint32_t blockSize);
  3310. /**
  3311. * @brief Multiplies a Q31 vector by a scalar.
  3312. * @param[in] pSrc points to the input vector
  3313. * @param[in] scaleFract fractional portion of the scale value
  3314. * @param[in] shift number of bits to shift the result by
  3315. * @param[out] pDst points to the output vector
  3316. * @param[in] blockSize number of samples in the vector
  3317. */
  3318. void arm_scale_q31(
  3319. const q31_t * pSrc,
  3320. q31_t scaleFract,
  3321. int8_t shift,
  3322. q31_t * pDst,
  3323. uint32_t blockSize);
  3324. /**
  3325. * @brief Q7 vector absolute value.
  3326. * @param[in] pSrc points to the input buffer
  3327. * @param[out] pDst points to the output buffer
  3328. * @param[in] blockSize number of samples in each vector
  3329. */
  3330. void arm_abs_q7(
  3331. const q7_t * pSrc,
  3332. q7_t * pDst,
  3333. uint32_t blockSize);
  3334. /**
  3335. * @brief Floating-point vector absolute value.
  3336. * @param[in] pSrc points to the input buffer
  3337. * @param[out] pDst points to the output buffer
  3338. * @param[in] blockSize number of samples in each vector
  3339. */
  3340. void arm_abs_f32(
  3341. const float32_t * pSrc,
  3342. float32_t * pDst,
  3343. uint32_t blockSize);
  3344. #if !defined( __CC_ARM )
  3345. /**
  3346. * @brief Floating-point vector absolute value.
  3347. * @param[in] pSrc points to the input buffer
  3348. * @param[out] pDst points to the output buffer
  3349. * @param[in] blockSize number of samples in each vector
  3350. */
  3351. void arm_abs_f16(
  3352. const float16_t * pSrc,
  3353. float16_t * pDst,
  3354. uint32_t blockSize);
  3355. #endif
  3356. /**
  3357. * @brief Q15 vector absolute value.
  3358. * @param[in] pSrc points to the input buffer
  3359. * @param[out] pDst points to the output buffer
  3360. * @param[in] blockSize number of samples in each vector
  3361. */
  3362. void arm_abs_q15(
  3363. const q15_t * pSrc,
  3364. q15_t * pDst,
  3365. uint32_t blockSize);
  3366. /**
  3367. * @brief Q31 vector absolute value.
  3368. * @param[in] pSrc points to the input buffer
  3369. * @param[out] pDst points to the output buffer
  3370. * @param[in] blockSize number of samples in each vector
  3371. */
  3372. void arm_abs_q31(
  3373. const q31_t * pSrc,
  3374. q31_t * pDst,
  3375. uint32_t blockSize);
  3376. /**
  3377. * @brief Dot product of floating-point vectors.
  3378. * @param[in] pSrcA points to the first input vector
  3379. * @param[in] pSrcB points to the second input vector
  3380. * @param[in] blockSize number of samples in each vector
  3381. * @param[out] result output result returned here
  3382. */
  3383. void arm_dot_prod_f32(
  3384. const float32_t * pSrcA,
  3385. const float32_t * pSrcB,
  3386. uint32_t blockSize,
  3387. float32_t * result);
  3388. #if !defined( __CC_ARM )
  3389. /**
  3390. * @brief Dot product of floating-point vectors.
  3391. * @param[in] pSrcA points to the first input vector
  3392. * @param[in] pSrcB points to the second input vector
  3393. * @param[in] blockSize number of samples in each vector
  3394. * @param[out] result output result returned here
  3395. */
  3396. void arm_dot_prod_f16(
  3397. const float16_t * pSrcA,
  3398. const float16_t * pSrcB,
  3399. uint32_t blockSize,
  3400. float16_t * result);
  3401. #endif
  3402. /**
  3403. * @brief Dot product of Q7 vectors.
  3404. * @param[in] pSrcA points to the first input vector
  3405. * @param[in] pSrcB points to the second input vector
  3406. * @param[in] blockSize number of samples in each vector
  3407. * @param[out] result output result returned here
  3408. */
  3409. void arm_dot_prod_q7(
  3410. const q7_t * pSrcA,
  3411. const q7_t * pSrcB,
  3412. uint32_t blockSize,
  3413. q31_t * result);
  3414. /**
  3415. * @brief Dot product of Q15 vectors.
  3416. * @param[in] pSrcA points to the first input vector
  3417. * @param[in] pSrcB points to the second input vector
  3418. * @param[in] blockSize number of samples in each vector
  3419. * @param[out] result output result returned here
  3420. */
  3421. void arm_dot_prod_q15(
  3422. const q15_t * pSrcA,
  3423. const q15_t * pSrcB,
  3424. uint32_t blockSize,
  3425. q63_t * result);
  3426. /**
  3427. * @brief Dot product of Q31 vectors.
  3428. * @param[in] pSrcA points to the first input vector
  3429. * @param[in] pSrcB points to the second input vector
  3430. * @param[in] blockSize number of samples in each vector
  3431. * @param[out] result output result returned here
  3432. */
  3433. void arm_dot_prod_q31(
  3434. const q31_t * pSrcA,
  3435. const q31_t * pSrcB,
  3436. uint32_t blockSize,
  3437. q63_t * result);
  3438. /**
  3439. * @brief Shifts the elements of a Q7 vector a specified number of bits.
  3440. * @param[in] pSrc points to the input vector
  3441. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  3442. * @param[out] pDst points to the output vector
  3443. * @param[in] blockSize number of samples in the vector
  3444. */
  3445. void arm_shift_q7(
  3446. const q7_t * pSrc,
  3447. int8_t shiftBits,
  3448. q7_t * pDst,
  3449. uint32_t blockSize);
  3450. /**
  3451. * @brief Shifts the elements of a Q15 vector a specified number of bits.
  3452. * @param[in] pSrc points to the input vector
  3453. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  3454. * @param[out] pDst points to the output vector
  3455. * @param[in] blockSize number of samples in the vector
  3456. */
  3457. void arm_shift_q15(
  3458. const q15_t * pSrc,
  3459. int8_t shiftBits,
  3460. q15_t * pDst,
  3461. uint32_t blockSize);
  3462. /**
  3463. * @brief Shifts the elements of a Q31 vector a specified number of bits.
  3464. * @param[in] pSrc points to the input vector
  3465. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  3466. * @param[out] pDst points to the output vector
  3467. * @param[in] blockSize number of samples in the vector
  3468. */
  3469. void arm_shift_q31(
  3470. const q31_t * pSrc,
  3471. int8_t shiftBits,
  3472. q31_t * pDst,
  3473. uint32_t blockSize);
  3474. /**
  3475. * @brief Adds a constant offset to a floating-point vector.
  3476. * @param[in] pSrc points to the input vector
  3477. * @param[in] offset is the offset to be added
  3478. * @param[out] pDst points to the output vector
  3479. * @param[in] blockSize number of samples in the vector
  3480. */
  3481. void arm_offset_f32(
  3482. const float32_t * pSrc,
  3483. float32_t offset,
  3484. float32_t * pDst,
  3485. uint32_t blockSize);
  3486. #if !defined( __CC_ARM )
  3487. /**
  3488. * @brief Adds a constant offset to a floating-point vector.
  3489. * @param[in] pSrc points to the input vector
  3490. * @param[in] offset is the offset to be added
  3491. * @param[out] pDst points to the output vector
  3492. * @param[in] blockSize number of samples in the vector
  3493. */
  3494. void arm_offset_f16(
  3495. const float16_t * pSrc,
  3496. float16_t offset,
  3497. float16_t * pDst,
  3498. uint32_t blockSize);
  3499. #endif
  3500. /**
  3501. * @brief Adds a constant offset to a Q7 vector.
  3502. * @param[in] pSrc points to the input vector
  3503. * @param[in] offset is the offset to be added
  3504. * @param[out] pDst points to the output vector
  3505. * @param[in] blockSize number of samples in the vector
  3506. */
  3507. void arm_offset_q7(
  3508. const q7_t * pSrc,
  3509. q7_t offset,
  3510. q7_t * pDst,
  3511. uint32_t blockSize);
  3512. /**
  3513. * @brief Adds a constant offset to a Q15 vector.
  3514. * @param[in] pSrc points to the input vector
  3515. * @param[in] offset is the offset to be added
  3516. * @param[out] pDst points to the output vector
  3517. * @param[in] blockSize number of samples in the vector
  3518. */
  3519. void arm_offset_q15(
  3520. const q15_t * pSrc,
  3521. q15_t offset,
  3522. q15_t * pDst,
  3523. uint32_t blockSize);
  3524. /**
  3525. * @brief Adds a constant offset to a Q31 vector.
  3526. * @param[in] pSrc points to the input vector
  3527. * @param[in] offset is the offset to be added
  3528. * @param[out] pDst points to the output vector
  3529. * @param[in] blockSize number of samples in the vector
  3530. */
  3531. void arm_offset_q31(
  3532. const q31_t * pSrc,
  3533. q31_t offset,
  3534. q31_t * pDst,
  3535. uint32_t blockSize);
  3536. /**
  3537. * @brief Negates the elements of a floating-point vector.
  3538. * @param[in] pSrc points to the input vector
  3539. * @param[out] pDst points to the output vector
  3540. * @param[in] blockSize number of samples in the vector
  3541. */
  3542. void arm_negate_f32(
  3543. const float32_t * pSrc,
  3544. float32_t * pDst,
  3545. uint32_t blockSize);
  3546. #if !defined( __CC_ARM )
  3547. /**
  3548. * @brief Negates the elements of a floating-point vector.
  3549. * @param[in] pSrc points to the input vector
  3550. * @param[out] pDst points to the output vector
  3551. * @param[in] blockSize number of samples in the vector
  3552. */
  3553. void arm_negate_f16(
  3554. const float16_t * pSrc,
  3555. float16_t * pDst,
  3556. uint32_t blockSize);
  3557. #endif
  3558. /**
  3559. * @brief Negates the elements of a Q7 vector.
  3560. * @param[in] pSrc points to the input vector
  3561. * @param[out] pDst points to the output vector
  3562. * @param[in] blockSize number of samples in the vector
  3563. */
  3564. void arm_negate_q7(
  3565. const q7_t * pSrc,
  3566. q7_t * pDst,
  3567. uint32_t blockSize);
  3568. /**
  3569. * @brief Negates the elements of a Q15 vector.
  3570. * @param[in] pSrc points to the input vector
  3571. * @param[out] pDst points to the output vector
  3572. * @param[in] blockSize number of samples in the vector
  3573. */
  3574. void arm_negate_q15(
  3575. const q15_t * pSrc,
  3576. q15_t * pDst,
  3577. uint32_t blockSize);
  3578. /**
  3579. * @brief Negates the elements of a Q31 vector.
  3580. * @param[in] pSrc points to the input vector
  3581. * @param[out] pDst points to the output vector
  3582. * @param[in] blockSize number of samples in the vector
  3583. */
  3584. void arm_negate_q31(
  3585. const q31_t * pSrc,
  3586. q31_t * pDst,
  3587. uint32_t blockSize);
  3588. /**
  3589. * @brief Copies the elements of a floating-point vector.
  3590. * @param[in] pSrc input pointer
  3591. * @param[out] pDst output pointer
  3592. * @param[in] blockSize number of samples to process
  3593. */
  3594. void arm_copy_f32(
  3595. const float32_t * pSrc,
  3596. float32_t * pDst,
  3597. uint32_t blockSize);
  3598. /**
  3599. * @brief Copies the elements of a Q7 vector.
  3600. * @param[in] pSrc input pointer
  3601. * @param[out] pDst output pointer
  3602. * @param[in] blockSize number of samples to process
  3603. */
  3604. void arm_copy_q7(
  3605. const q7_t * pSrc,
  3606. q7_t * pDst,
  3607. uint32_t blockSize);
  3608. /**
  3609. * @brief Copies the elements of a Q15 vector.
  3610. * @param[in] pSrc input pointer
  3611. * @param[out] pDst output pointer
  3612. * @param[in] blockSize number of samples to process
  3613. */
  3614. void arm_copy_q15(
  3615. const q15_t * pSrc,
  3616. q15_t * pDst,
  3617. uint32_t blockSize);
  3618. /**
  3619. * @brief Copies the elements of a Q31 vector.
  3620. * @param[in] pSrc input pointer
  3621. * @param[out] pDst output pointer
  3622. * @param[in] blockSize number of samples to process
  3623. */
  3624. void arm_copy_q31(
  3625. const q31_t * pSrc,
  3626. q31_t * pDst,
  3627. uint32_t blockSize);
  3628. /**
  3629. * @brief Fills a constant value into a floating-point vector.
  3630. * @param[in] value input value to be filled
  3631. * @param[out] pDst output pointer
  3632. * @param[in] blockSize number of samples to process
  3633. */
  3634. void arm_fill_f32(
  3635. float32_t value,
  3636. float32_t * pDst,
  3637. uint32_t blockSize);
  3638. /**
  3639. * @brief Fills a constant value into a Q7 vector.
  3640. * @param[in] value input value to be filled
  3641. * @param[out] pDst output pointer
  3642. * @param[in] blockSize number of samples to process
  3643. */
  3644. void arm_fill_q7(
  3645. q7_t value,
  3646. q7_t * pDst,
  3647. uint32_t blockSize);
  3648. /**
  3649. * @brief Fills a constant value into a Q15 vector.
  3650. * @param[in] value input value to be filled
  3651. * @param[out] pDst output pointer
  3652. * @param[in] blockSize number of samples to process
  3653. */
  3654. void arm_fill_q15(
  3655. q15_t value,
  3656. q15_t * pDst,
  3657. uint32_t blockSize);
  3658. /**
  3659. * @brief Fills a constant value into a Q31 vector.
  3660. * @param[in] value input value to be filled
  3661. * @param[out] pDst output pointer
  3662. * @param[in] blockSize number of samples to process
  3663. */
  3664. void arm_fill_q31(
  3665. q31_t value,
  3666. q31_t * pDst,
  3667. uint32_t blockSize);
  3668. /**
  3669. * @brief Convolution of floating-point sequences.
  3670. * @param[in] pSrcA points to the first input sequence.
  3671. * @param[in] srcALen length of the first input sequence.
  3672. * @param[in] pSrcB points to the second input sequence.
  3673. * @param[in] srcBLen length of the second input sequence.
  3674. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  3675. */
  3676. void arm_conv_f32(
  3677. const float32_t * pSrcA,
  3678. uint32_t srcALen,
  3679. const float32_t * pSrcB,
  3680. uint32_t srcBLen,
  3681. float32_t * pDst);
  3682. /**
  3683. * @brief Convolution of Q15 sequences.
  3684. * @param[in] pSrcA points to the first input sequence.
  3685. * @param[in] srcALen length of the first input sequence.
  3686. * @param[in] pSrcB points to the second input sequence.
  3687. * @param[in] srcBLen length of the second input sequence.
  3688. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  3689. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3690. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  3691. */
  3692. void arm_conv_opt_q15(
  3693. const q15_t * pSrcA,
  3694. uint32_t srcALen,
  3695. const q15_t * pSrcB,
  3696. uint32_t srcBLen,
  3697. q15_t * pDst,
  3698. q15_t * pScratch1,
  3699. q15_t * pScratch2);
  3700. /**
  3701. * @brief Convolution of Q15 sequences.
  3702. * @param[in] pSrcA points to the first input sequence.
  3703. * @param[in] srcALen length of the first input sequence.
  3704. * @param[in] pSrcB points to the second input sequence.
  3705. * @param[in] srcBLen length of the second input sequence.
  3706. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  3707. */
  3708. void arm_conv_q15(
  3709. const q15_t * pSrcA,
  3710. uint32_t srcALen,
  3711. const q15_t * pSrcB,
  3712. uint32_t srcBLen,
  3713. q15_t * pDst);
  3714. /**
  3715. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  3716. * @param[in] pSrcA points to the first input sequence.
  3717. * @param[in] srcALen length of the first input sequence.
  3718. * @param[in] pSrcB points to the second input sequence.
  3719. * @param[in] srcBLen length of the second input sequence.
  3720. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  3721. */
  3722. void arm_conv_fast_q15(
  3723. const q15_t * pSrcA,
  3724. uint32_t srcALen,
  3725. const q15_t * pSrcB,
  3726. uint32_t srcBLen,
  3727. q15_t * pDst);
  3728. /**
  3729. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  3730. * @param[in] pSrcA points to the first input sequence.
  3731. * @param[in] srcALen length of the first input sequence.
  3732. * @param[in] pSrcB points to the second input sequence.
  3733. * @param[in] srcBLen length of the second input sequence.
  3734. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  3735. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3736. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  3737. */
  3738. void arm_conv_fast_opt_q15(
  3739. const q15_t * pSrcA,
  3740. uint32_t srcALen,
  3741. const q15_t * pSrcB,
  3742. uint32_t srcBLen,
  3743. q15_t * pDst,
  3744. q15_t * pScratch1,
  3745. q15_t * pScratch2);
  3746. /**
  3747. * @brief Convolution of Q31 sequences.
  3748. * @param[in] pSrcA points to the first input sequence.
  3749. * @param[in] srcALen length of the first input sequence.
  3750. * @param[in] pSrcB points to the second input sequence.
  3751. * @param[in] srcBLen length of the second input sequence.
  3752. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  3753. */
  3754. void arm_conv_q31(
  3755. const q31_t * pSrcA,
  3756. uint32_t srcALen,
  3757. const q31_t * pSrcB,
  3758. uint32_t srcBLen,
  3759. q31_t * pDst);
  3760. /**
  3761. * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  3762. * @param[in] pSrcA points to the first input sequence.
  3763. * @param[in] srcALen length of the first input sequence.
  3764. * @param[in] pSrcB points to the second input sequence.
  3765. * @param[in] srcBLen length of the second input sequence.
  3766. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  3767. */
  3768. void arm_conv_fast_q31(
  3769. const q31_t * pSrcA,
  3770. uint32_t srcALen,
  3771. const q31_t * pSrcB,
  3772. uint32_t srcBLen,
  3773. q31_t * pDst);
  3774. /**
  3775. * @brief Convolution of Q7 sequences.
  3776. * @param[in] pSrcA points to the first input sequence.
  3777. * @param[in] srcALen length of the first input sequence.
  3778. * @param[in] pSrcB points to the second input sequence.
  3779. * @param[in] srcBLen length of the second input sequence.
  3780. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  3781. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3782. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  3783. */
  3784. void arm_conv_opt_q7(
  3785. const q7_t * pSrcA,
  3786. uint32_t srcALen,
  3787. const q7_t * pSrcB,
  3788. uint32_t srcBLen,
  3789. q7_t * pDst,
  3790. q15_t * pScratch1,
  3791. q15_t * pScratch2);
  3792. /**
  3793. * @brief Convolution of Q7 sequences.
  3794. * @param[in] pSrcA points to the first input sequence.
  3795. * @param[in] srcALen length of the first input sequence.
  3796. * @param[in] pSrcB points to the second input sequence.
  3797. * @param[in] srcBLen length of the second input sequence.
  3798. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
  3799. */
  3800. void arm_conv_q7(
  3801. const q7_t * pSrcA,
  3802. uint32_t srcALen,
  3803. const q7_t * pSrcB,
  3804. uint32_t srcBLen,
  3805. q7_t * pDst);
  3806. /**
  3807. * @brief Partial convolution of floating-point sequences.
  3808. * @param[in] pSrcA points to the first input sequence.
  3809. * @param[in] srcALen length of the first input sequence.
  3810. * @param[in] pSrcB points to the second input sequence.
  3811. * @param[in] srcBLen length of the second input sequence.
  3812. * @param[out] pDst points to the block of output data
  3813. * @param[in] firstIndex is the first output sample to start with.
  3814. * @param[in] numPoints is the number of output points to be computed.
  3815. * @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].
  3816. */
  3817. arm_status arm_conv_partial_f32(
  3818. const float32_t * pSrcA,
  3819. uint32_t srcALen,
  3820. const float32_t * pSrcB,
  3821. uint32_t srcBLen,
  3822. float32_t * pDst,
  3823. uint32_t firstIndex,
  3824. uint32_t numPoints);
  3825. /**
  3826. * @brief Partial convolution of Q15 sequences.
  3827. * @param[in] pSrcA points to the first input sequence.
  3828. * @param[in] srcALen length of the first input sequence.
  3829. * @param[in] pSrcB points to the second input sequence.
  3830. * @param[in] srcBLen length of the second input sequence.
  3831. * @param[out] pDst points to the block of output data
  3832. * @param[in] firstIndex is the first output sample to start with.
  3833. * @param[in] numPoints is the number of output points to be computed.
  3834. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3835. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  3836. * @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].
  3837. */
  3838. arm_status arm_conv_partial_opt_q15(
  3839. const q15_t * pSrcA,
  3840. uint32_t srcALen,
  3841. const q15_t * pSrcB,
  3842. uint32_t srcBLen,
  3843. q15_t * pDst,
  3844. uint32_t firstIndex,
  3845. uint32_t numPoints,
  3846. q15_t * pScratch1,
  3847. q15_t * pScratch2);
  3848. /**
  3849. * @brief Partial convolution of Q15 sequences.
  3850. * @param[in] pSrcA points to the first input sequence.
  3851. * @param[in] srcALen length of the first input sequence.
  3852. * @param[in] pSrcB points to the second input sequence.
  3853. * @param[in] srcBLen length of the second input sequence.
  3854. * @param[out] pDst points to the block of output data
  3855. * @param[in] firstIndex is the first output sample to start with.
  3856. * @param[in] numPoints is the number of output points to be computed.
  3857. * @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].
  3858. */
  3859. arm_status arm_conv_partial_q15(
  3860. const q15_t * pSrcA,
  3861. uint32_t srcALen,
  3862. const q15_t * pSrcB,
  3863. uint32_t srcBLen,
  3864. q15_t * pDst,
  3865. uint32_t firstIndex,
  3866. uint32_t numPoints);
  3867. /**
  3868. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  3869. * @param[in] pSrcA points to the first input sequence.
  3870. * @param[in] srcALen length of the first input sequence.
  3871. * @param[in] pSrcB points to the second input sequence.
  3872. * @param[in] srcBLen length of the second input sequence.
  3873. * @param[out] pDst points to the block of output data
  3874. * @param[in] firstIndex is the first output sample to start with.
  3875. * @param[in] numPoints is the number of output points to be computed.
  3876. * @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].
  3877. */
  3878. arm_status arm_conv_partial_fast_q15(
  3879. const q15_t * pSrcA,
  3880. uint32_t srcALen,
  3881. const q15_t * pSrcB,
  3882. uint32_t srcBLen,
  3883. q15_t * pDst,
  3884. uint32_t firstIndex,
  3885. uint32_t numPoints);
  3886. /**
  3887. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  3888. * @param[in] pSrcA points to the first input sequence.
  3889. * @param[in] srcALen length of the first input sequence.
  3890. * @param[in] pSrcB points to the second input sequence.
  3891. * @param[in] srcBLen length of the second input sequence.
  3892. * @param[out] pDst points to the block of output data
  3893. * @param[in] firstIndex is the first output sample to start with.
  3894. * @param[in] numPoints is the number of output points to be computed.
  3895. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3896. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  3897. * @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].
  3898. */
  3899. arm_status arm_conv_partial_fast_opt_q15(
  3900. const q15_t * pSrcA,
  3901. uint32_t srcALen,
  3902. const q15_t * pSrcB,
  3903. uint32_t srcBLen,
  3904. q15_t * pDst,
  3905. uint32_t firstIndex,
  3906. uint32_t numPoints,
  3907. q15_t * pScratch1,
  3908. q15_t * pScratch2);
  3909. /**
  3910. * @brief Partial convolution of Q31 sequences.
  3911. * @param[in] pSrcA points to the first input sequence.
  3912. * @param[in] srcALen length of the first input sequence.
  3913. * @param[in] pSrcB points to the second input sequence.
  3914. * @param[in] srcBLen length of the second input sequence.
  3915. * @param[out] pDst points to the block of output data
  3916. * @param[in] firstIndex is the first output sample to start with.
  3917. * @param[in] numPoints is the number of output points to be computed.
  3918. * @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].
  3919. */
  3920. arm_status arm_conv_partial_q31(
  3921. const q31_t * pSrcA,
  3922. uint32_t srcALen,
  3923. const q31_t * pSrcB,
  3924. uint32_t srcBLen,
  3925. q31_t * pDst,
  3926. uint32_t firstIndex,
  3927. uint32_t numPoints);
  3928. /**
  3929. * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  3930. * @param[in] pSrcA points to the first input sequence.
  3931. * @param[in] srcALen length of the first input sequence.
  3932. * @param[in] pSrcB points to the second input sequence.
  3933. * @param[in] srcBLen length of the second input sequence.
  3934. * @param[out] pDst points to the block of output data
  3935. * @param[in] firstIndex is the first output sample to start with.
  3936. * @param[in] numPoints is the number of output points to be computed.
  3937. * @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].
  3938. */
  3939. arm_status arm_conv_partial_fast_q31(
  3940. const q31_t * pSrcA,
  3941. uint32_t srcALen,
  3942. const q31_t * pSrcB,
  3943. uint32_t srcBLen,
  3944. q31_t * pDst,
  3945. uint32_t firstIndex,
  3946. uint32_t numPoints);
  3947. /**
  3948. * @brief Partial convolution of Q7 sequences
  3949. * @param[in] pSrcA points to the first input sequence.
  3950. * @param[in] srcALen length of the first input sequence.
  3951. * @param[in] pSrcB points to the second input sequence.
  3952. * @param[in] srcBLen length of the second input sequence.
  3953. * @param[out] pDst points to the block of output data
  3954. * @param[in] firstIndex is the first output sample to start with.
  3955. * @param[in] numPoints is the number of output points to be computed.
  3956. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3957. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  3958. * @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].
  3959. */
  3960. arm_status arm_conv_partial_opt_q7(
  3961. const q7_t * pSrcA,
  3962. uint32_t srcALen,
  3963. const q7_t * pSrcB,
  3964. uint32_t srcBLen,
  3965. q7_t * pDst,
  3966. uint32_t firstIndex,
  3967. uint32_t numPoints,
  3968. q15_t * pScratch1,
  3969. q15_t * pScratch2);
  3970. /**
  3971. * @brief Partial convolution of Q7 sequences.
  3972. * @param[in] pSrcA points to the first input sequence.
  3973. * @param[in] srcALen length of the first input sequence.
  3974. * @param[in] pSrcB points to the second input sequence.
  3975. * @param[in] srcBLen length of the second input sequence.
  3976. * @param[out] pDst points to the block of output data
  3977. * @param[in] firstIndex is the first output sample to start with.
  3978. * @param[in] numPoints is the number of output points to be computed.
  3979. * @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].
  3980. */
  3981. arm_status arm_conv_partial_q7(
  3982. const q7_t * pSrcA,
  3983. uint32_t srcALen,
  3984. const q7_t * pSrcB,
  3985. uint32_t srcBLen,
  3986. q7_t * pDst,
  3987. uint32_t firstIndex,
  3988. uint32_t numPoints);
  3989. /**
  3990. * @brief Instance structure for the Q15 FIR decimator.
  3991. */
  3992. typedef struct
  3993. {
  3994. uint8_t M; /**< decimation factor. */
  3995. uint16_t numTaps; /**< number of coefficients in the filter. */
  3996. const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3997. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3998. } arm_fir_decimate_instance_q15;
  3999. /**
  4000. * @brief Instance structure for the Q31 FIR decimator.
  4001. */
  4002. typedef struct
  4003. {
  4004. uint8_t M; /**< decimation factor. */
  4005. uint16_t numTaps; /**< number of coefficients in the filter. */
  4006. const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  4007. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4008. } arm_fir_decimate_instance_q31;
  4009. /**
  4010. @brief Instance structure for floating-point FIR decimator.
  4011. */
  4012. typedef struct
  4013. {
  4014. uint8_t M; /**< decimation factor. */
  4015. uint16_t numTaps; /**< number of coefficients in the filter. */
  4016. const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  4017. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4018. } arm_fir_decimate_instance_f32;
  4019. /**
  4020. @brief Processing function for floating-point FIR decimator.
  4021. @param[in] S points to an instance of the floating-point FIR decimator structure
  4022. @param[in] pSrc points to the block of input data
  4023. @param[out] pDst points to the block of output data
  4024. @param[in] blockSize number of samples to process
  4025. */
  4026. void arm_fir_decimate_f32(
  4027. const arm_fir_decimate_instance_f32 * S,
  4028. const float32_t * pSrc,
  4029. float32_t * pDst,
  4030. uint32_t blockSize);
  4031. /**
  4032. @brief Initialization function for the floating-point FIR decimator.
  4033. @param[in,out] S points to an instance of the floating-point FIR decimator structure
  4034. @param[in] numTaps number of coefficients in the filter
  4035. @param[in] M decimation factor
  4036. @param[in] pCoeffs points to the filter coefficients
  4037. @param[in] pState points to the state buffer
  4038. @param[in] blockSize number of input samples to process per call
  4039. @return execution status
  4040. - \ref ARM_MATH_SUCCESS : Operation successful
  4041. - \ref ARM_MATH_LENGTH_ERROR : <code>blockSize</code> is not a multiple of <code>M</code>
  4042. */
  4043. arm_status arm_fir_decimate_init_f32(
  4044. arm_fir_decimate_instance_f32 * S,
  4045. uint16_t numTaps,
  4046. uint8_t M,
  4047. const float32_t * pCoeffs,
  4048. float32_t * pState,
  4049. uint32_t blockSize);
  4050. /**
  4051. * @brief Processing function for the Q15 FIR decimator.
  4052. * @param[in] S points to an instance of the Q15 FIR decimator structure.
  4053. * @param[in] pSrc points to the block of input data.
  4054. * @param[out] pDst points to the block of output data
  4055. * @param[in] blockSize number of input samples to process per call.
  4056. */
  4057. void arm_fir_decimate_q15(
  4058. const arm_fir_decimate_instance_q15 * S,
  4059. const q15_t * pSrc,
  4060. q15_t * pDst,
  4061. uint32_t blockSize);
  4062. /**
  4063. * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  4064. * @param[in] S points to an instance of the Q15 FIR decimator structure.
  4065. * @param[in] pSrc points to the block of input data.
  4066. * @param[out] pDst points to the block of output data
  4067. * @param[in] blockSize number of input samples to process per call.
  4068. */
  4069. void arm_fir_decimate_fast_q15(
  4070. const arm_fir_decimate_instance_q15 * S,
  4071. const q15_t * pSrc,
  4072. q15_t * pDst,
  4073. uint32_t blockSize);
  4074. /**
  4075. * @brief Initialization function for the Q15 FIR decimator.
  4076. * @param[in,out] S points to an instance of the Q15 FIR decimator structure.
  4077. * @param[in] numTaps number of coefficients in the filter.
  4078. * @param[in] M decimation factor.
  4079. * @param[in] pCoeffs points to the filter coefficients.
  4080. * @param[in] pState points to the state buffer.
  4081. * @param[in] blockSize number of input samples to process per call.
  4082. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  4083. * <code>blockSize</code> is not a multiple of <code>M</code>.
  4084. */
  4085. arm_status arm_fir_decimate_init_q15(
  4086. arm_fir_decimate_instance_q15 * S,
  4087. uint16_t numTaps,
  4088. uint8_t M,
  4089. const q15_t * pCoeffs,
  4090. q15_t * pState,
  4091. uint32_t blockSize);
  4092. /**
  4093. * @brief Processing function for the Q31 FIR decimator.
  4094. * @param[in] S points to an instance of the Q31 FIR decimator structure.
  4095. * @param[in] pSrc points to the block of input data.
  4096. * @param[out] pDst points to the block of output data
  4097. * @param[in] blockSize number of input samples to process per call.
  4098. */
  4099. void arm_fir_decimate_q31(
  4100. const arm_fir_decimate_instance_q31 * S,
  4101. const q31_t * pSrc,
  4102. q31_t * pDst,
  4103. uint32_t blockSize);
  4104. /**
  4105. * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  4106. * @param[in] S points to an instance of the Q31 FIR decimator structure.
  4107. * @param[in] pSrc points to the block of input data.
  4108. * @param[out] pDst points to the block of output data
  4109. * @param[in] blockSize number of input samples to process per call.
  4110. */
  4111. void arm_fir_decimate_fast_q31(
  4112. const arm_fir_decimate_instance_q31 * S,
  4113. const q31_t * pSrc,
  4114. q31_t * pDst,
  4115. uint32_t blockSize);
  4116. /**
  4117. * @brief Initialization function for the Q31 FIR decimator.
  4118. * @param[in,out] S points to an instance of the Q31 FIR decimator structure.
  4119. * @param[in] numTaps number of coefficients in the filter.
  4120. * @param[in] M decimation factor.
  4121. * @param[in] pCoeffs points to the filter coefficients.
  4122. * @param[in] pState points to the state buffer.
  4123. * @param[in] blockSize number of input samples to process per call.
  4124. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  4125. * <code>blockSize</code> is not a multiple of <code>M</code>.
  4126. */
  4127. arm_status arm_fir_decimate_init_q31(
  4128. arm_fir_decimate_instance_q31 * S,
  4129. uint16_t numTaps,
  4130. uint8_t M,
  4131. const q31_t * pCoeffs,
  4132. q31_t * pState,
  4133. uint32_t blockSize);
  4134. /**
  4135. * @brief Instance structure for the Q15 FIR interpolator.
  4136. */
  4137. typedef struct
  4138. {
  4139. uint8_t L; /**< upsample factor. */
  4140. uint16_t phaseLength; /**< length of each polyphase filter component. */
  4141. const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  4142. q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  4143. } arm_fir_interpolate_instance_q15;
  4144. /**
  4145. * @brief Instance structure for the Q31 FIR interpolator.
  4146. */
  4147. typedef struct
  4148. {
  4149. uint8_t L; /**< upsample factor. */
  4150. uint16_t phaseLength; /**< length of each polyphase filter component. */
  4151. const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  4152. q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  4153. } arm_fir_interpolate_instance_q31;
  4154. /**
  4155. * @brief Instance structure for the floating-point FIR interpolator.
  4156. */
  4157. typedef struct
  4158. {
  4159. uint8_t L; /**< upsample factor. */
  4160. uint16_t phaseLength; /**< length of each polyphase filter component. */
  4161. const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  4162. float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
  4163. } arm_fir_interpolate_instance_f32;
  4164. /**
  4165. * @brief Processing function for the Q15 FIR interpolator.
  4166. * @param[in] S points to an instance of the Q15 FIR interpolator structure.
  4167. * @param[in] pSrc points to the block of input data.
  4168. * @param[out] pDst points to the block of output data.
  4169. * @param[in] blockSize number of input samples to process per call.
  4170. */
  4171. void arm_fir_interpolate_q15(
  4172. const arm_fir_interpolate_instance_q15 * S,
  4173. const q15_t * pSrc,
  4174. q15_t * pDst,
  4175. uint32_t blockSize);
  4176. /**
  4177. * @brief Initialization function for the Q15 FIR interpolator.
  4178. * @param[in,out] S points to an instance of the Q15 FIR interpolator structure.
  4179. * @param[in] L upsample factor.
  4180. * @param[in] numTaps number of filter coefficients in the filter.
  4181. * @param[in] pCoeffs points to the filter coefficient buffer.
  4182. * @param[in] pState points to the state buffer.
  4183. * @param[in] blockSize number of input samples to process per call.
  4184. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  4185. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  4186. */
  4187. arm_status arm_fir_interpolate_init_q15(
  4188. arm_fir_interpolate_instance_q15 * S,
  4189. uint8_t L,
  4190. uint16_t numTaps,
  4191. const q15_t * pCoeffs,
  4192. q15_t * pState,
  4193. uint32_t blockSize);
  4194. /**
  4195. * @brief Processing function for the Q31 FIR interpolator.
  4196. * @param[in] S points to an instance of the Q15 FIR interpolator structure.
  4197. * @param[in] pSrc points to the block of input data.
  4198. * @param[out] pDst points to the block of output data.
  4199. * @param[in] blockSize number of input samples to process per call.
  4200. */
  4201. void arm_fir_interpolate_q31(
  4202. const arm_fir_interpolate_instance_q31 * S,
  4203. const q31_t * pSrc,
  4204. q31_t * pDst,
  4205. uint32_t blockSize);
  4206. /**
  4207. * @brief Initialization function for the Q31 FIR interpolator.
  4208. * @param[in,out] S points to an instance of the Q31 FIR interpolator structure.
  4209. * @param[in] L upsample factor.
  4210. * @param[in] numTaps number of filter coefficients in the filter.
  4211. * @param[in] pCoeffs points to the filter coefficient buffer.
  4212. * @param[in] pState points to the state buffer.
  4213. * @param[in] blockSize number of input samples to process per call.
  4214. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  4215. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  4216. */
  4217. arm_status arm_fir_interpolate_init_q31(
  4218. arm_fir_interpolate_instance_q31 * S,
  4219. uint8_t L,
  4220. uint16_t numTaps,
  4221. const q31_t * pCoeffs,
  4222. q31_t * pState,
  4223. uint32_t blockSize);
  4224. /**
  4225. * @brief Processing function for the floating-point FIR interpolator.
  4226. * @param[in] S points to an instance of the floating-point FIR interpolator structure.
  4227. * @param[in] pSrc points to the block of input data.
  4228. * @param[out] pDst points to the block of output data.
  4229. * @param[in] blockSize number of input samples to process per call.
  4230. */
  4231. void arm_fir_interpolate_f32(
  4232. const arm_fir_interpolate_instance_f32 * S,
  4233. const float32_t * pSrc,
  4234. float32_t * pDst,
  4235. uint32_t blockSize);
  4236. /**
  4237. * @brief Initialization function for the floating-point FIR interpolator.
  4238. * @param[in,out] S points to an instance of the floating-point FIR interpolator structure.
  4239. * @param[in] L upsample factor.
  4240. * @param[in] numTaps number of filter coefficients in the filter.
  4241. * @param[in] pCoeffs points to the filter coefficient buffer.
  4242. * @param[in] pState points to the state buffer.
  4243. * @param[in] blockSize number of input samples to process per call.
  4244. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  4245. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  4246. */
  4247. arm_status arm_fir_interpolate_init_f32(
  4248. arm_fir_interpolate_instance_f32 * S,
  4249. uint8_t L,
  4250. uint16_t numTaps,
  4251. const float32_t * pCoeffs,
  4252. float32_t * pState,
  4253. uint32_t blockSize);
  4254. /**
  4255. * @brief Instance structure for the high precision Q31 Biquad cascade filter.
  4256. */
  4257. typedef struct
  4258. {
  4259. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  4260. q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  4261. const q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  4262. uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
  4263. } arm_biquad_cas_df1_32x64_ins_q31;
  4264. /**
  4265. * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure.
  4266. * @param[in] pSrc points to the block of input data.
  4267. * @param[out] pDst points to the block of output data
  4268. * @param[in] blockSize number of samples to process.
  4269. */
  4270. void arm_biquad_cas_df1_32x64_q31(
  4271. const arm_biquad_cas_df1_32x64_ins_q31 * S,
  4272. const q31_t * pSrc,
  4273. q31_t * pDst,
  4274. uint32_t blockSize);
  4275. /**
  4276. * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure.
  4277. * @param[in] numStages number of 2nd order stages in the filter.
  4278. * @param[in] pCoeffs points to the filter coefficients.
  4279. * @param[in] pState points to the state buffer.
  4280. * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
  4281. */
  4282. void arm_biquad_cas_df1_32x64_init_q31(
  4283. arm_biquad_cas_df1_32x64_ins_q31 * S,
  4284. uint8_t numStages,
  4285. const q31_t * pCoeffs,
  4286. q63_t * pState,
  4287. uint8_t postShift);
  4288. /**
  4289. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  4290. */
  4291. typedef struct
  4292. {
  4293. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  4294. float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  4295. const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  4296. } arm_biquad_cascade_df2T_instance_f32;
  4297. /**
  4298. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  4299. */
  4300. typedef struct
  4301. {
  4302. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  4303. float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  4304. const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  4305. } arm_biquad_cascade_stereo_df2T_instance_f32;
  4306. /**
  4307. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  4308. */
  4309. typedef struct
  4310. {
  4311. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  4312. float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  4313. const float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  4314. } arm_biquad_cascade_df2T_instance_f64;
  4315. /**
  4316. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  4317. * @param[in] S points to an instance of the filter data structure.
  4318. * @param[in] pSrc points to the block of input data.
  4319. * @param[out] pDst points to the block of output data
  4320. * @param[in] blockSize number of samples to process.
  4321. */
  4322. void arm_biquad_cascade_df2T_f32(
  4323. const arm_biquad_cascade_df2T_instance_f32 * S,
  4324. const float32_t * pSrc,
  4325. float32_t * pDst,
  4326. uint32_t blockSize);
  4327. /**
  4328. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
  4329. * @param[in] S points to an instance of the filter data structure.
  4330. * @param[in] pSrc points to the block of input data.
  4331. * @param[out] pDst points to the block of output data
  4332. * @param[in] blockSize number of samples to process.
  4333. */
  4334. void arm_biquad_cascade_stereo_df2T_f32(
  4335. const arm_biquad_cascade_stereo_df2T_instance_f32 * S,
  4336. const float32_t * pSrc,
  4337. float32_t * pDst,
  4338. uint32_t blockSize);
  4339. /**
  4340. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  4341. * @param[in] S points to an instance of the filter data structure.
  4342. * @param[in] pSrc points to the block of input data.
  4343. * @param[out] pDst points to the block of output data
  4344. * @param[in] blockSize number of samples to process.
  4345. */
  4346. void arm_biquad_cascade_df2T_f64(
  4347. const arm_biquad_cascade_df2T_instance_f64 * S,
  4348. const float64_t * pSrc,
  4349. float64_t * pDst,
  4350. uint32_t blockSize);
  4351. #if defined(ARM_MATH_NEON)
  4352. void arm_biquad_cascade_df2T_compute_coefs_f32(
  4353. arm_biquad_cascade_df2T_instance_f32 * S,
  4354. uint8_t numStages,
  4355. float32_t * pCoeffs);
  4356. #endif
  4357. /**
  4358. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  4359. * @param[in,out] S points to an instance of the filter data structure.
  4360. * @param[in] numStages number of 2nd order stages in the filter.
  4361. * @param[in] pCoeffs points to the filter coefficients.
  4362. * @param[in] pState points to the state buffer.
  4363. */
  4364. void arm_biquad_cascade_df2T_init_f32(
  4365. arm_biquad_cascade_df2T_instance_f32 * S,
  4366. uint8_t numStages,
  4367. const float32_t * pCoeffs,
  4368. float32_t * pState);
  4369. /**
  4370. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  4371. * @param[in,out] S points to an instance of the filter data structure.
  4372. * @param[in] numStages number of 2nd order stages in the filter.
  4373. * @param[in] pCoeffs points to the filter coefficients.
  4374. * @param[in] pState points to the state buffer.
  4375. */
  4376. void arm_biquad_cascade_stereo_df2T_init_f32(
  4377. arm_biquad_cascade_stereo_df2T_instance_f32 * S,
  4378. uint8_t numStages,
  4379. const float32_t * pCoeffs,
  4380. float32_t * pState);
  4381. /**
  4382. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  4383. * @param[in,out] S points to an instance of the filter data structure.
  4384. * @param[in] numStages number of 2nd order stages in the filter.
  4385. * @param[in] pCoeffs points to the filter coefficients.
  4386. * @param[in] pState points to the state buffer.
  4387. */
  4388. void arm_biquad_cascade_df2T_init_f64(
  4389. arm_biquad_cascade_df2T_instance_f64 * S,
  4390. uint8_t numStages,
  4391. const float64_t * pCoeffs,
  4392. float64_t * pState);
  4393. /**
  4394. * @brief Instance structure for the Q15 FIR lattice filter.
  4395. */
  4396. typedef struct
  4397. {
  4398. uint16_t numStages; /**< number of filter stages. */
  4399. q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
  4400. const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  4401. } arm_fir_lattice_instance_q15;
  4402. /**
  4403. * @brief Instance structure for the Q31 FIR lattice filter.
  4404. */
  4405. typedef struct
  4406. {
  4407. uint16_t numStages; /**< number of filter stages. */
  4408. q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
  4409. const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  4410. } arm_fir_lattice_instance_q31;
  4411. /**
  4412. * @brief Instance structure for the floating-point FIR lattice filter.
  4413. */
  4414. typedef struct
  4415. {
  4416. uint16_t numStages; /**< number of filter stages. */
  4417. float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
  4418. const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  4419. } arm_fir_lattice_instance_f32;
  4420. /**
  4421. * @brief Initialization function for the Q15 FIR lattice filter.
  4422. * @param[in] S points to an instance of the Q15 FIR lattice structure.
  4423. * @param[in] numStages number of filter stages.
  4424. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  4425. * @param[in] pState points to the state buffer. The array is of length numStages.
  4426. */
  4427. void arm_fir_lattice_init_q15(
  4428. arm_fir_lattice_instance_q15 * S,
  4429. uint16_t numStages,
  4430. const q15_t * pCoeffs,
  4431. q15_t * pState);
  4432. /**
  4433. * @brief Processing function for the Q15 FIR lattice filter.
  4434. * @param[in] S points to an instance of the Q15 FIR lattice structure.
  4435. * @param[in] pSrc points to the block of input data.
  4436. * @param[out] pDst points to the block of output data.
  4437. * @param[in] blockSize number of samples to process.
  4438. */
  4439. void arm_fir_lattice_q15(
  4440. const arm_fir_lattice_instance_q15 * S,
  4441. const q15_t * pSrc,
  4442. q15_t * pDst,
  4443. uint32_t blockSize);
  4444. /**
  4445. * @brief Initialization function for the Q31 FIR lattice filter.
  4446. * @param[in] S points to an instance of the Q31 FIR lattice structure.
  4447. * @param[in] numStages number of filter stages.
  4448. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  4449. * @param[in] pState points to the state buffer. The array is of length numStages.
  4450. */
  4451. void arm_fir_lattice_init_q31(
  4452. arm_fir_lattice_instance_q31 * S,
  4453. uint16_t numStages,
  4454. const q31_t * pCoeffs,
  4455. q31_t * pState);
  4456. /**
  4457. * @brief Processing function for the Q31 FIR lattice filter.
  4458. * @param[in] S points to an instance of the Q31 FIR lattice structure.
  4459. * @param[in] pSrc points to the block of input data.
  4460. * @param[out] pDst points to the block of output data
  4461. * @param[in] blockSize number of samples to process.
  4462. */
  4463. void arm_fir_lattice_q31(
  4464. const arm_fir_lattice_instance_q31 * S,
  4465. const q31_t * pSrc,
  4466. q31_t * pDst,
  4467. uint32_t blockSize);
  4468. /**
  4469. * @brief Initialization function for the floating-point FIR lattice filter.
  4470. * @param[in] S points to an instance of the floating-point FIR lattice structure.
  4471. * @param[in] numStages number of filter stages.
  4472. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
  4473. * @param[in] pState points to the state buffer. The array is of length numStages.
  4474. */
  4475. void arm_fir_lattice_init_f32(
  4476. arm_fir_lattice_instance_f32 * S,
  4477. uint16_t numStages,
  4478. const float32_t * pCoeffs,
  4479. float32_t * pState);
  4480. /**
  4481. * @brief Processing function for the floating-point FIR lattice filter.
  4482. * @param[in] S points to an instance of the floating-point FIR lattice structure.
  4483. * @param[in] pSrc points to the block of input data.
  4484. * @param[out] pDst points to the block of output data
  4485. * @param[in] blockSize number of samples to process.
  4486. */
  4487. void arm_fir_lattice_f32(
  4488. const arm_fir_lattice_instance_f32 * S,
  4489. const float32_t * pSrc,
  4490. float32_t * pDst,
  4491. uint32_t blockSize);
  4492. /**
  4493. * @brief Instance structure for the Q15 IIR lattice filter.
  4494. */
  4495. typedef struct
  4496. {
  4497. uint16_t numStages; /**< number of stages in the filter. */
  4498. q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  4499. q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  4500. q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  4501. } arm_iir_lattice_instance_q15;
  4502. /**
  4503. * @brief Instance structure for the Q31 IIR lattice filter.
  4504. */
  4505. typedef struct
  4506. {
  4507. uint16_t numStages; /**< number of stages in the filter. */
  4508. q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  4509. q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  4510. q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  4511. } arm_iir_lattice_instance_q31;
  4512. /**
  4513. * @brief Instance structure for the floating-point IIR lattice filter.
  4514. */
  4515. typedef struct
  4516. {
  4517. uint16_t numStages; /**< number of stages in the filter. */
  4518. float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  4519. float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  4520. float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  4521. } arm_iir_lattice_instance_f32;
  4522. /**
  4523. * @brief Processing function for the floating-point IIR lattice filter.
  4524. * @param[in] S points to an instance of the floating-point IIR lattice structure.
  4525. * @param[in] pSrc points to the block of input data.
  4526. * @param[out] pDst points to the block of output data.
  4527. * @param[in] blockSize number of samples to process.
  4528. */
  4529. void arm_iir_lattice_f32(
  4530. const arm_iir_lattice_instance_f32 * S,
  4531. const float32_t * pSrc,
  4532. float32_t * pDst,
  4533. uint32_t blockSize);
  4534. /**
  4535. * @brief Initialization function for the floating-point IIR lattice filter.
  4536. * @param[in] S points to an instance of the floating-point IIR lattice structure.
  4537. * @param[in] numStages number of stages in the filter.
  4538. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  4539. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  4540. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1.
  4541. * @param[in] blockSize number of samples to process.
  4542. */
  4543. void arm_iir_lattice_init_f32(
  4544. arm_iir_lattice_instance_f32 * S,
  4545. uint16_t numStages,
  4546. float32_t * pkCoeffs,
  4547. float32_t * pvCoeffs,
  4548. float32_t * pState,
  4549. uint32_t blockSize);
  4550. /**
  4551. * @brief Processing function for the Q31 IIR lattice filter.
  4552. * @param[in] S points to an instance of the Q31 IIR lattice structure.
  4553. * @param[in] pSrc points to the block of input data.
  4554. * @param[out] pDst points to the block of output data.
  4555. * @param[in] blockSize number of samples to process.
  4556. */
  4557. void arm_iir_lattice_q31(
  4558. const arm_iir_lattice_instance_q31 * S,
  4559. const q31_t * pSrc,
  4560. q31_t * pDst,
  4561. uint32_t blockSize);
  4562. /**
  4563. * @brief Initialization function for the Q31 IIR lattice filter.
  4564. * @param[in] S points to an instance of the Q31 IIR lattice structure.
  4565. * @param[in] numStages number of stages in the filter.
  4566. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  4567. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  4568. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize.
  4569. * @param[in] blockSize number of samples to process.
  4570. */
  4571. void arm_iir_lattice_init_q31(
  4572. arm_iir_lattice_instance_q31 * S,
  4573. uint16_t numStages,
  4574. q31_t * pkCoeffs,
  4575. q31_t * pvCoeffs,
  4576. q31_t * pState,
  4577. uint32_t blockSize);
  4578. /**
  4579. * @brief Processing function for the Q15 IIR lattice filter.
  4580. * @param[in] S points to an instance of the Q15 IIR lattice structure.
  4581. * @param[in] pSrc points to the block of input data.
  4582. * @param[out] pDst points to the block of output data.
  4583. * @param[in] blockSize number of samples to process.
  4584. */
  4585. void arm_iir_lattice_q15(
  4586. const arm_iir_lattice_instance_q15 * S,
  4587. const q15_t * pSrc,
  4588. q15_t * pDst,
  4589. uint32_t blockSize);
  4590. /**
  4591. * @brief Initialization function for the Q15 IIR lattice filter.
  4592. * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure.
  4593. * @param[in] numStages number of stages in the filter.
  4594. * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
  4595. * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
  4596. * @param[in] pState points to state buffer. The array is of length numStages+blockSize.
  4597. * @param[in] blockSize number of samples to process per call.
  4598. */
  4599. void arm_iir_lattice_init_q15(
  4600. arm_iir_lattice_instance_q15 * S,
  4601. uint16_t numStages,
  4602. q15_t * pkCoeffs,
  4603. q15_t * pvCoeffs,
  4604. q15_t * pState,
  4605. uint32_t blockSize);
  4606. /**
  4607. * @brief Instance structure for the floating-point LMS filter.
  4608. */
  4609. typedef struct
  4610. {
  4611. uint16_t numTaps; /**< number of coefficients in the filter. */
  4612. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4613. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  4614. float32_t mu; /**< step size that controls filter coefficient updates. */
  4615. } arm_lms_instance_f32;
  4616. /**
  4617. * @brief Processing function for floating-point LMS filter.
  4618. * @param[in] S points to an instance of the floating-point LMS filter structure.
  4619. * @param[in] pSrc points to the block of input data.
  4620. * @param[in] pRef points to the block of reference data.
  4621. * @param[out] pOut points to the block of output data.
  4622. * @param[out] pErr points to the block of error data.
  4623. * @param[in] blockSize number of samples to process.
  4624. */
  4625. void arm_lms_f32(
  4626. const arm_lms_instance_f32 * S,
  4627. const float32_t * pSrc,
  4628. float32_t * pRef,
  4629. float32_t * pOut,
  4630. float32_t * pErr,
  4631. uint32_t blockSize);
  4632. /**
  4633. * @brief Initialization function for floating-point LMS filter.
  4634. * @param[in] S points to an instance of the floating-point LMS filter structure.
  4635. * @param[in] numTaps number of filter coefficients.
  4636. * @param[in] pCoeffs points to the coefficient buffer.
  4637. * @param[in] pState points to state buffer.
  4638. * @param[in] mu step size that controls filter coefficient updates.
  4639. * @param[in] blockSize number of samples to process.
  4640. */
  4641. void arm_lms_init_f32(
  4642. arm_lms_instance_f32 * S,
  4643. uint16_t numTaps,
  4644. float32_t * pCoeffs,
  4645. float32_t * pState,
  4646. float32_t mu,
  4647. uint32_t blockSize);
  4648. /**
  4649. * @brief Instance structure for the Q15 LMS filter.
  4650. */
  4651. typedef struct
  4652. {
  4653. uint16_t numTaps; /**< number of coefficients in the filter. */
  4654. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4655. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  4656. q15_t mu; /**< step size that controls filter coefficient updates. */
  4657. uint32_t postShift; /**< bit shift applied to coefficients. */
  4658. } arm_lms_instance_q15;
  4659. /**
  4660. * @brief Initialization function for the Q15 LMS filter.
  4661. * @param[in] S points to an instance of the Q15 LMS filter structure.
  4662. * @param[in] numTaps number of filter coefficients.
  4663. * @param[in] pCoeffs points to the coefficient buffer.
  4664. * @param[in] pState points to the state buffer.
  4665. * @param[in] mu step size that controls filter coefficient updates.
  4666. * @param[in] blockSize number of samples to process.
  4667. * @param[in] postShift bit shift applied to coefficients.
  4668. */
  4669. void arm_lms_init_q15(
  4670. arm_lms_instance_q15 * S,
  4671. uint16_t numTaps,
  4672. q15_t * pCoeffs,
  4673. q15_t * pState,
  4674. q15_t mu,
  4675. uint32_t blockSize,
  4676. uint32_t postShift);
  4677. /**
  4678. * @brief Processing function for Q15 LMS filter.
  4679. * @param[in] S points to an instance of the Q15 LMS filter structure.
  4680. * @param[in] pSrc points to the block of input data.
  4681. * @param[in] pRef points to the block of reference data.
  4682. * @param[out] pOut points to the block of output data.
  4683. * @param[out] pErr points to the block of error data.
  4684. * @param[in] blockSize number of samples to process.
  4685. */
  4686. void arm_lms_q15(
  4687. const arm_lms_instance_q15 * S,
  4688. const q15_t * pSrc,
  4689. q15_t * pRef,
  4690. q15_t * pOut,
  4691. q15_t * pErr,
  4692. uint32_t blockSize);
  4693. /**
  4694. * @brief Instance structure for the Q31 LMS filter.
  4695. */
  4696. typedef struct
  4697. {
  4698. uint16_t numTaps; /**< number of coefficients in the filter. */
  4699. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4700. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  4701. q31_t mu; /**< step size that controls filter coefficient updates. */
  4702. uint32_t postShift; /**< bit shift applied to coefficients. */
  4703. } arm_lms_instance_q31;
  4704. /**
  4705. * @brief Processing function for Q31 LMS filter.
  4706. * @param[in] S points to an instance of the Q15 LMS filter structure.
  4707. * @param[in] pSrc points to the block of input data.
  4708. * @param[in] pRef points to the block of reference data.
  4709. * @param[out] pOut points to the block of output data.
  4710. * @param[out] pErr points to the block of error data.
  4711. * @param[in] blockSize number of samples to process.
  4712. */
  4713. void arm_lms_q31(
  4714. const arm_lms_instance_q31 * S,
  4715. const q31_t * pSrc,
  4716. q31_t * pRef,
  4717. q31_t * pOut,
  4718. q31_t * pErr,
  4719. uint32_t blockSize);
  4720. /**
  4721. * @brief Initialization function for Q31 LMS filter.
  4722. * @param[in] S points to an instance of the Q31 LMS filter structure.
  4723. * @param[in] numTaps number of filter coefficients.
  4724. * @param[in] pCoeffs points to coefficient buffer.
  4725. * @param[in] pState points to state buffer.
  4726. * @param[in] mu step size that controls filter coefficient updates.
  4727. * @param[in] blockSize number of samples to process.
  4728. * @param[in] postShift bit shift applied to coefficients.
  4729. */
  4730. void arm_lms_init_q31(
  4731. arm_lms_instance_q31 * S,
  4732. uint16_t numTaps,
  4733. q31_t * pCoeffs,
  4734. q31_t * pState,
  4735. q31_t mu,
  4736. uint32_t blockSize,
  4737. uint32_t postShift);
  4738. /**
  4739. * @brief Instance structure for the floating-point normalized LMS filter.
  4740. */
  4741. typedef struct
  4742. {
  4743. uint16_t numTaps; /**< number of coefficients in the filter. */
  4744. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4745. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  4746. float32_t mu; /**< step size that control filter coefficient updates. */
  4747. float32_t energy; /**< saves previous frame energy. */
  4748. float32_t x0; /**< saves previous input sample. */
  4749. } arm_lms_norm_instance_f32;
  4750. /**
  4751. * @brief Processing function for floating-point normalized LMS filter.
  4752. * @param[in] S points to an instance of the floating-point normalized LMS filter structure.
  4753. * @param[in] pSrc points to the block of input data.
  4754. * @param[in] pRef points to the block of reference data.
  4755. * @param[out] pOut points to the block of output data.
  4756. * @param[out] pErr points to the block of error data.
  4757. * @param[in] blockSize number of samples to process.
  4758. */
  4759. void arm_lms_norm_f32(
  4760. arm_lms_norm_instance_f32 * S,
  4761. const float32_t * pSrc,
  4762. float32_t * pRef,
  4763. float32_t * pOut,
  4764. float32_t * pErr,
  4765. uint32_t blockSize);
  4766. /**
  4767. * @brief Initialization function for floating-point normalized LMS filter.
  4768. * @param[in] S points to an instance of the floating-point LMS filter structure.
  4769. * @param[in] numTaps number of filter coefficients.
  4770. * @param[in] pCoeffs points to coefficient buffer.
  4771. * @param[in] pState points to state buffer.
  4772. * @param[in] mu step size that controls filter coefficient updates.
  4773. * @param[in] blockSize number of samples to process.
  4774. */
  4775. void arm_lms_norm_init_f32(
  4776. arm_lms_norm_instance_f32 * S,
  4777. uint16_t numTaps,
  4778. float32_t * pCoeffs,
  4779. float32_t * pState,
  4780. float32_t mu,
  4781. uint32_t blockSize);
  4782. /**
  4783. * @brief Instance structure for the Q31 normalized LMS filter.
  4784. */
  4785. typedef struct
  4786. {
  4787. uint16_t numTaps; /**< number of coefficients in the filter. */
  4788. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4789. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  4790. q31_t mu; /**< step size that controls filter coefficient updates. */
  4791. uint8_t postShift; /**< bit shift applied to coefficients. */
  4792. const q31_t *recipTable; /**< points to the reciprocal initial value table. */
  4793. q31_t energy; /**< saves previous frame energy. */
  4794. q31_t x0; /**< saves previous input sample. */
  4795. } arm_lms_norm_instance_q31;
  4796. /**
  4797. * @brief Processing function for Q31 normalized LMS filter.
  4798. * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
  4799. * @param[in] pSrc points to the block of input data.
  4800. * @param[in] pRef points to the block of reference data.
  4801. * @param[out] pOut points to the block of output data.
  4802. * @param[out] pErr points to the block of error data.
  4803. * @param[in] blockSize number of samples to process.
  4804. */
  4805. void arm_lms_norm_q31(
  4806. arm_lms_norm_instance_q31 * S,
  4807. const q31_t * pSrc,
  4808. q31_t * pRef,
  4809. q31_t * pOut,
  4810. q31_t * pErr,
  4811. uint32_t blockSize);
  4812. /**
  4813. * @brief Initialization function for Q31 normalized LMS filter.
  4814. * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
  4815. * @param[in] numTaps number of filter coefficients.
  4816. * @param[in] pCoeffs points to coefficient buffer.
  4817. * @param[in] pState points to state buffer.
  4818. * @param[in] mu step size that controls filter coefficient updates.
  4819. * @param[in] blockSize number of samples to process.
  4820. * @param[in] postShift bit shift applied to coefficients.
  4821. */
  4822. void arm_lms_norm_init_q31(
  4823. arm_lms_norm_instance_q31 * S,
  4824. uint16_t numTaps,
  4825. q31_t * pCoeffs,
  4826. q31_t * pState,
  4827. q31_t mu,
  4828. uint32_t blockSize,
  4829. uint8_t postShift);
  4830. /**
  4831. * @brief Instance structure for the Q15 normalized LMS filter.
  4832. */
  4833. typedef struct
  4834. {
  4835. uint16_t numTaps; /**< Number of coefficients in the filter. */
  4836. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  4837. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  4838. q15_t mu; /**< step size that controls filter coefficient updates. */
  4839. uint8_t postShift; /**< bit shift applied to coefficients. */
  4840. const q15_t *recipTable; /**< Points to the reciprocal initial value table. */
  4841. q15_t energy; /**< saves previous frame energy. */
  4842. q15_t x0; /**< saves previous input sample. */
  4843. } arm_lms_norm_instance_q15;
  4844. /**
  4845. * @brief Processing function for Q15 normalized LMS filter.
  4846. * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
  4847. * @param[in] pSrc points to the block of input data.
  4848. * @param[in] pRef points to the block of reference data.
  4849. * @param[out] pOut points to the block of output data.
  4850. * @param[out] pErr points to the block of error data.
  4851. * @param[in] blockSize number of samples to process.
  4852. */
  4853. void arm_lms_norm_q15(
  4854. arm_lms_norm_instance_q15 * S,
  4855. const q15_t * pSrc,
  4856. q15_t * pRef,
  4857. q15_t * pOut,
  4858. q15_t * pErr,
  4859. uint32_t blockSize);
  4860. /**
  4861. * @brief Initialization function for Q15 normalized LMS filter.
  4862. * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
  4863. * @param[in] numTaps number of filter coefficients.
  4864. * @param[in] pCoeffs points to coefficient buffer.
  4865. * @param[in] pState points to state buffer.
  4866. * @param[in] mu step size that controls filter coefficient updates.
  4867. * @param[in] blockSize number of samples to process.
  4868. * @param[in] postShift bit shift applied to coefficients.
  4869. */
  4870. void arm_lms_norm_init_q15(
  4871. arm_lms_norm_instance_q15 * S,
  4872. uint16_t numTaps,
  4873. q15_t * pCoeffs,
  4874. q15_t * pState,
  4875. q15_t mu,
  4876. uint32_t blockSize,
  4877. uint8_t postShift);
  4878. /**
  4879. * @brief Correlation of floating-point sequences.
  4880. * @param[in] pSrcA points to the first input sequence.
  4881. * @param[in] srcALen length of the first input sequence.
  4882. * @param[in] pSrcB points to the second input sequence.
  4883. * @param[in] srcBLen length of the second input sequence.
  4884. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  4885. */
  4886. void arm_correlate_f32(
  4887. const float32_t * pSrcA,
  4888. uint32_t srcALen,
  4889. const float32_t * pSrcB,
  4890. uint32_t srcBLen,
  4891. float32_t * pDst);
  4892. /**
  4893. @brief Correlation of Q15 sequences
  4894. @param[in] pSrcA points to the first input sequence
  4895. @param[in] srcALen length of the first input sequence
  4896. @param[in] pSrcB points to the second input sequence
  4897. @param[in] srcBLen length of the second input sequence
  4898. @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  4899. @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  4900. */
  4901. void arm_correlate_opt_q15(
  4902. const q15_t * pSrcA,
  4903. uint32_t srcALen,
  4904. const q15_t * pSrcB,
  4905. uint32_t srcBLen,
  4906. q15_t * pDst,
  4907. q15_t * pScratch);
  4908. /**
  4909. @brief Correlation of Q15 sequences.
  4910. @param[in] pSrcA points to the first input sequence
  4911. @param[in] srcALen length of the first input sequence
  4912. @param[in] pSrcB points to the second input sequence
  4913. @param[in] srcBLen length of the second input sequence
  4914. @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  4915. */
  4916. void arm_correlate_q15(
  4917. const q15_t * pSrcA,
  4918. uint32_t srcALen,
  4919. const q15_t * pSrcB,
  4920. uint32_t srcBLen,
  4921. q15_t * pDst);
  4922. /**
  4923. @brief Correlation of Q15 sequences (fast version).
  4924. @param[in] pSrcA points to the first input sequence
  4925. @param[in] srcALen length of the first input sequence
  4926. @param[in] pSrcB points to the second input sequence
  4927. @param[in] srcBLen length of the second input sequence
  4928. @param[out] pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1.
  4929. @return none
  4930. */
  4931. void arm_correlate_fast_q15(
  4932. const q15_t * pSrcA,
  4933. uint32_t srcALen,
  4934. const q15_t * pSrcB,
  4935. uint32_t srcBLen,
  4936. q15_t * pDst);
  4937. /**
  4938. @brief Correlation of Q15 sequences (fast version).
  4939. @param[in] pSrcA points to the first input sequence.
  4940. @param[in] srcALen length of the first input sequence.
  4941. @param[in] pSrcB points to the second input sequence.
  4942. @param[in] srcBLen length of the second input sequence.
  4943. @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  4944. @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  4945. */
  4946. void arm_correlate_fast_opt_q15(
  4947. const q15_t * pSrcA,
  4948. uint32_t srcALen,
  4949. const q15_t * pSrcB,
  4950. uint32_t srcBLen,
  4951. q15_t * pDst,
  4952. q15_t * pScratch);
  4953. /**
  4954. * @brief Correlation of Q31 sequences.
  4955. * @param[in] pSrcA points to the first input sequence.
  4956. * @param[in] srcALen length of the first input sequence.
  4957. * @param[in] pSrcB points to the second input sequence.
  4958. * @param[in] srcBLen length of the second input sequence.
  4959. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  4960. */
  4961. void arm_correlate_q31(
  4962. const q31_t * pSrcA,
  4963. uint32_t srcALen,
  4964. const q31_t * pSrcB,
  4965. uint32_t srcBLen,
  4966. q31_t * pDst);
  4967. /**
  4968. @brief Correlation of Q31 sequences (fast version).
  4969. @param[in] pSrcA points to the first input sequence
  4970. @param[in] srcALen length of the first input sequence
  4971. @param[in] pSrcB points to the second input sequence
  4972. @param[in] srcBLen length of the second input sequence
  4973. @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  4974. */
  4975. void arm_correlate_fast_q31(
  4976. const q31_t * pSrcA,
  4977. uint32_t srcALen,
  4978. const q31_t * pSrcB,
  4979. uint32_t srcBLen,
  4980. q31_t * pDst);
  4981. /**
  4982. * @brief Correlation of Q7 sequences.
  4983. * @param[in] pSrcA points to the first input sequence.
  4984. * @param[in] srcALen length of the first input sequence.
  4985. * @param[in] pSrcB points to the second input sequence.
  4986. * @param[in] srcBLen length of the second input sequence.
  4987. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  4988. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  4989. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  4990. */
  4991. void arm_correlate_opt_q7(
  4992. const q7_t * pSrcA,
  4993. uint32_t srcALen,
  4994. const q7_t * pSrcB,
  4995. uint32_t srcBLen,
  4996. q7_t * pDst,
  4997. q15_t * pScratch1,
  4998. q15_t * pScratch2);
  4999. /**
  5000. * @brief Correlation of Q7 sequences.
  5001. * @param[in] pSrcA points to the first input sequence.
  5002. * @param[in] srcALen length of the first input sequence.
  5003. * @param[in] pSrcB points to the second input sequence.
  5004. * @param[in] srcBLen length of the second input sequence.
  5005. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  5006. */
  5007. void arm_correlate_q7(
  5008. const q7_t * pSrcA,
  5009. uint32_t srcALen,
  5010. const q7_t * pSrcB,
  5011. uint32_t srcBLen,
  5012. q7_t * pDst);
  5013. /**
  5014. * @brief Instance structure for the floating-point sparse FIR filter.
  5015. */
  5016. typedef struct
  5017. {
  5018. uint16_t numTaps; /**< number of coefficients in the filter. */
  5019. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  5020. float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  5021. const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  5022. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  5023. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  5024. } arm_fir_sparse_instance_f32;
  5025. /**
  5026. * @brief Instance structure for the Q31 sparse FIR filter.
  5027. */
  5028. typedef struct
  5029. {
  5030. uint16_t numTaps; /**< number of coefficients in the filter. */
  5031. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  5032. q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  5033. const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  5034. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  5035. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  5036. } arm_fir_sparse_instance_q31;
  5037. /**
  5038. * @brief Instance structure for the Q15 sparse FIR filter.
  5039. */
  5040. typedef struct
  5041. {
  5042. uint16_t numTaps; /**< number of coefficients in the filter. */
  5043. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  5044. q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  5045. const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  5046. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  5047. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  5048. } arm_fir_sparse_instance_q15;
  5049. /**
  5050. * @brief Instance structure for the Q7 sparse FIR filter.
  5051. */
  5052. typedef struct
  5053. {
  5054. uint16_t numTaps; /**< number of coefficients in the filter. */
  5055. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  5056. q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  5057. const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  5058. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  5059. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  5060. } arm_fir_sparse_instance_q7;
  5061. /**
  5062. * @brief Processing function for the floating-point sparse FIR filter.
  5063. * @param[in] S points to an instance of the floating-point sparse FIR structure.
  5064. * @param[in] pSrc points to the block of input data.
  5065. * @param[out] pDst points to the block of output data
  5066. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  5067. * @param[in] blockSize number of input samples to process per call.
  5068. */
  5069. void arm_fir_sparse_f32(
  5070. arm_fir_sparse_instance_f32 * S,
  5071. const float32_t * pSrc,
  5072. float32_t * pDst,
  5073. float32_t * pScratchIn,
  5074. uint32_t blockSize);
  5075. /**
  5076. * @brief Initialization function for the floating-point sparse FIR filter.
  5077. * @param[in,out] S points to an instance of the floating-point sparse FIR structure.
  5078. * @param[in] numTaps number of nonzero coefficients in the filter.
  5079. * @param[in] pCoeffs points to the array of filter coefficients.
  5080. * @param[in] pState points to the state buffer.
  5081. * @param[in] pTapDelay points to the array of offset times.
  5082. * @param[in] maxDelay maximum offset time supported.
  5083. * @param[in] blockSize number of samples that will be processed per block.
  5084. */
  5085. void arm_fir_sparse_init_f32(
  5086. arm_fir_sparse_instance_f32 * S,
  5087. uint16_t numTaps,
  5088. const float32_t * pCoeffs,
  5089. float32_t * pState,
  5090. int32_t * pTapDelay,
  5091. uint16_t maxDelay,
  5092. uint32_t blockSize);
  5093. /**
  5094. * @brief Processing function for the Q31 sparse FIR filter.
  5095. * @param[in] S points to an instance of the Q31 sparse FIR structure.
  5096. * @param[in] pSrc points to the block of input data.
  5097. * @param[out] pDst points to the block of output data
  5098. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  5099. * @param[in] blockSize number of input samples to process per call.
  5100. */
  5101. void arm_fir_sparse_q31(
  5102. arm_fir_sparse_instance_q31 * S,
  5103. const q31_t * pSrc,
  5104. q31_t * pDst,
  5105. q31_t * pScratchIn,
  5106. uint32_t blockSize);
  5107. /**
  5108. * @brief Initialization function for the Q31 sparse FIR filter.
  5109. * @param[in,out] S points to an instance of the Q31 sparse FIR structure.
  5110. * @param[in] numTaps number of nonzero coefficients in the filter.
  5111. * @param[in] pCoeffs points to the array of filter coefficients.
  5112. * @param[in] pState points to the state buffer.
  5113. * @param[in] pTapDelay points to the array of offset times.
  5114. * @param[in] maxDelay maximum offset time supported.
  5115. * @param[in] blockSize number of samples that will be processed per block.
  5116. */
  5117. void arm_fir_sparse_init_q31(
  5118. arm_fir_sparse_instance_q31 * S,
  5119. uint16_t numTaps,
  5120. const q31_t * pCoeffs,
  5121. q31_t * pState,
  5122. int32_t * pTapDelay,
  5123. uint16_t maxDelay,
  5124. uint32_t blockSize);
  5125. /**
  5126. * @brief Processing function for the Q15 sparse FIR filter.
  5127. * @param[in] S points to an instance of the Q15 sparse FIR structure.
  5128. * @param[in] pSrc points to the block of input data.
  5129. * @param[out] pDst points to the block of output data
  5130. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  5131. * @param[in] pScratchOut points to a temporary buffer of size blockSize.
  5132. * @param[in] blockSize number of input samples to process per call.
  5133. */
  5134. void arm_fir_sparse_q15(
  5135. arm_fir_sparse_instance_q15 * S,
  5136. const q15_t * pSrc,
  5137. q15_t * pDst,
  5138. q15_t * pScratchIn,
  5139. q31_t * pScratchOut,
  5140. uint32_t blockSize);
  5141. /**
  5142. * @brief Initialization function for the Q15 sparse FIR filter.
  5143. * @param[in,out] S points to an instance of the Q15 sparse FIR structure.
  5144. * @param[in] numTaps number of nonzero coefficients in the filter.
  5145. * @param[in] pCoeffs points to the array of filter coefficients.
  5146. * @param[in] pState points to the state buffer.
  5147. * @param[in] pTapDelay points to the array of offset times.
  5148. * @param[in] maxDelay maximum offset time supported.
  5149. * @param[in] blockSize number of samples that will be processed per block.
  5150. */
  5151. void arm_fir_sparse_init_q15(
  5152. arm_fir_sparse_instance_q15 * S,
  5153. uint16_t numTaps,
  5154. const q15_t * pCoeffs,
  5155. q15_t * pState,
  5156. int32_t * pTapDelay,
  5157. uint16_t maxDelay,
  5158. uint32_t blockSize);
  5159. /**
  5160. * @brief Processing function for the Q7 sparse FIR filter.
  5161. * @param[in] S points to an instance of the Q7 sparse FIR structure.
  5162. * @param[in] pSrc points to the block of input data.
  5163. * @param[out] pDst points to the block of output data
  5164. * @param[in] pScratchIn points to a temporary buffer of size blockSize.
  5165. * @param[in] pScratchOut points to a temporary buffer of size blockSize.
  5166. * @param[in] blockSize number of input samples to process per call.
  5167. */
  5168. void arm_fir_sparse_q7(
  5169. arm_fir_sparse_instance_q7 * S,
  5170. const q7_t * pSrc,
  5171. q7_t * pDst,
  5172. q7_t * pScratchIn,
  5173. q31_t * pScratchOut,
  5174. uint32_t blockSize);
  5175. /**
  5176. * @brief Initialization function for the Q7 sparse FIR filter.
  5177. * @param[in,out] S points to an instance of the Q7 sparse FIR structure.
  5178. * @param[in] numTaps number of nonzero coefficients in the filter.
  5179. * @param[in] pCoeffs points to the array of filter coefficients.
  5180. * @param[in] pState points to the state buffer.
  5181. * @param[in] pTapDelay points to the array of offset times.
  5182. * @param[in] maxDelay maximum offset time supported.
  5183. * @param[in] blockSize number of samples that will be processed per block.
  5184. */
  5185. void arm_fir_sparse_init_q7(
  5186. arm_fir_sparse_instance_q7 * S,
  5187. uint16_t numTaps,
  5188. const q7_t * pCoeffs,
  5189. q7_t * pState,
  5190. int32_t * pTapDelay,
  5191. uint16_t maxDelay,
  5192. uint32_t blockSize);
  5193. /**
  5194. * @brief Floating-point sin_cos function.
  5195. * @param[in] theta input value in degrees
  5196. * @param[out] pSinVal points to the processed sine output.
  5197. * @param[out] pCosVal points to the processed cos output.
  5198. */
  5199. void arm_sin_cos_f32(
  5200. float32_t theta,
  5201. float32_t * pSinVal,
  5202. float32_t * pCosVal);
  5203. /**
  5204. * @brief Q31 sin_cos function.
  5205. * @param[in] theta scaled input value in degrees
  5206. * @param[out] pSinVal points to the processed sine output.
  5207. * @param[out] pCosVal points to the processed cosine output.
  5208. */
  5209. void arm_sin_cos_q31(
  5210. q31_t theta,
  5211. q31_t * pSinVal,
  5212. q31_t * pCosVal);
  5213. /**
  5214. * @brief Floating-point complex conjugate.
  5215. * @param[in] pSrc points to the input vector
  5216. * @param[out] pDst points to the output vector
  5217. * @param[in] numSamples number of complex samples in each vector
  5218. */
  5219. void arm_cmplx_conj_f32(
  5220. const float32_t * pSrc,
  5221. float32_t * pDst,
  5222. uint32_t numSamples);
  5223. /**
  5224. * @brief Q31 complex conjugate.
  5225. * @param[in] pSrc points to the input vector
  5226. * @param[out] pDst points to the output vector
  5227. * @param[in] numSamples number of complex samples in each vector
  5228. */
  5229. void arm_cmplx_conj_q31(
  5230. const q31_t * pSrc,
  5231. q31_t * pDst,
  5232. uint32_t numSamples);
  5233. /**
  5234. * @brief Q15 complex conjugate.
  5235. * @param[in] pSrc points to the input vector
  5236. * @param[out] pDst points to the output vector
  5237. * @param[in] numSamples number of complex samples in each vector
  5238. */
  5239. void arm_cmplx_conj_q15(
  5240. const q15_t * pSrc,
  5241. q15_t * pDst,
  5242. uint32_t numSamples);
  5243. /**
  5244. * @brief Floating-point complex magnitude squared
  5245. * @param[in] pSrc points to the complex input vector
  5246. * @param[out] pDst points to the real output vector
  5247. * @param[in] numSamples number of complex samples in the input vector
  5248. */
  5249. void arm_cmplx_mag_squared_f32(
  5250. const float32_t * pSrc,
  5251. float32_t * pDst,
  5252. uint32_t numSamples);
  5253. /**
  5254. * @brief Q31 complex magnitude squared
  5255. * @param[in] pSrc points to the complex input vector
  5256. * @param[out] pDst points to the real output vector
  5257. * @param[in] numSamples number of complex samples in the input vector
  5258. */
  5259. void arm_cmplx_mag_squared_q31(
  5260. const q31_t * pSrc,
  5261. q31_t * pDst,
  5262. uint32_t numSamples);
  5263. /**
  5264. * @brief Q15 complex magnitude squared
  5265. * @param[in] pSrc points to the complex input vector
  5266. * @param[out] pDst points to the real output vector
  5267. * @param[in] numSamples number of complex samples in the input vector
  5268. */
  5269. void arm_cmplx_mag_squared_q15(
  5270. const q15_t * pSrc,
  5271. q15_t * pDst,
  5272. uint32_t numSamples);
  5273. /**
  5274. * @ingroup groupController
  5275. */
  5276. /**
  5277. * @defgroup PID PID Motor Control
  5278. *
  5279. * A Proportional Integral Derivative (PID) controller is a generic feedback control
  5280. * loop mechanism widely used in industrial control systems.
  5281. * A PID controller is the most commonly used type of feedback controller.
  5282. *
  5283. * This set of functions implements (PID) controllers
  5284. * for Q15, Q31, and floating-point data types. The functions operate on a single sample
  5285. * of data and each call to the function returns a single processed value.
  5286. * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
  5287. * is the input sample value. The functions return the output value.
  5288. *
  5289. * \par Algorithm:
  5290. * <pre>
  5291. * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
  5292. * A0 = Kp + Ki + Kd
  5293. * A1 = (-Kp ) - (2 * Kd )
  5294. * A2 = Kd
  5295. * </pre>
  5296. *
  5297. * \par
  5298. * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
  5299. *
  5300. * \par
  5301. * \image html PID.gif "Proportional Integral Derivative Controller"
  5302. *
  5303. * \par
  5304. * The PID controller calculates an "error" value as the difference between
  5305. * the measured output and the reference input.
  5306. * The controller attempts to minimize the error by adjusting the process control inputs.
  5307. * The proportional value determines the reaction to the current error,
  5308. * the integral value determines the reaction based on the sum of recent errors,
  5309. * and the derivative value determines the reaction based on the rate at which the error has been changing.
  5310. *
  5311. * \par Instance Structure
  5312. * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
  5313. * A separate instance structure must be defined for each PID Controller.
  5314. * There are separate instance structure declarations for each of the 3 supported data types.
  5315. *
  5316. * \par Reset Functions
  5317. * There is also an associated reset function for each data type which clears the state array.
  5318. *
  5319. * \par Initialization Functions
  5320. * There is also an associated initialization function for each data type.
  5321. * The initialization function performs the following operations:
  5322. * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
  5323. * - Zeros out the values in the state buffer.
  5324. *
  5325. * \par
  5326. * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
  5327. *
  5328. * \par Fixed-Point Behavior
  5329. * Care must be taken when using the fixed-point versions of the PID Controller functions.
  5330. * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
  5331. * Refer to the function specific documentation below for usage guidelines.
  5332. */
  5333. /**
  5334. * @addtogroup PID
  5335. * @{
  5336. */
  5337. /**
  5338. * @brief Process function for the floating-point PID Control.
  5339. * @param[in,out] S is an instance of the floating-point PID Control structure
  5340. * @param[in] in input sample to process
  5341. * @return processed output sample.
  5342. */
  5343. __STATIC_FORCEINLINE float32_t arm_pid_f32(
  5344. arm_pid_instance_f32 * S,
  5345. float32_t in)
  5346. {
  5347. float32_t out;
  5348. /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
  5349. out = (S->A0 * in) +
  5350. (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
  5351. /* Update state */
  5352. S->state[1] = S->state[0];
  5353. S->state[0] = in;
  5354. S->state[2] = out;
  5355. /* return to application */
  5356. return (out);
  5357. }
  5358. /**
  5359. @brief Process function for the Q31 PID Control.
  5360. @param[in,out] S points to an instance of the Q31 PID Control structure
  5361. @param[in] in input sample to process
  5362. @return processed output sample.
  5363. \par Scaling and Overflow Behavior
  5364. The function is implemented using an internal 64-bit accumulator.
  5365. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
  5366. Thus, if the accumulator result overflows it wraps around rather than clip.
  5367. In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
  5368. After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
  5369. */
  5370. __STATIC_FORCEINLINE q31_t arm_pid_q31(
  5371. arm_pid_instance_q31 * S,
  5372. q31_t in)
  5373. {
  5374. q63_t acc;
  5375. q31_t out;
  5376. /* acc = A0 * x[n] */
  5377. acc = (q63_t) S->A0 * in;
  5378. /* acc += A1 * x[n-1] */
  5379. acc += (q63_t) S->A1 * S->state[0];
  5380. /* acc += A2 * x[n-2] */
  5381. acc += (q63_t) S->A2 * S->state[1];
  5382. /* convert output to 1.31 format to add y[n-1] */
  5383. out = (q31_t) (acc >> 31U);
  5384. /* out += y[n-1] */
  5385. out += S->state[2];
  5386. /* Update state */
  5387. S->state[1] = S->state[0];
  5388. S->state[0] = in;
  5389. S->state[2] = out;
  5390. /* return to application */
  5391. return (out);
  5392. }
  5393. /**
  5394. @brief Process function for the Q15 PID Control.
  5395. @param[in,out] S points to an instance of the Q15 PID Control structure
  5396. @param[in] in input sample to process
  5397. @return processed output sample.
  5398. \par Scaling and Overflow Behavior
  5399. The function is implemented using a 64-bit internal accumulator.
  5400. Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
  5401. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
  5402. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
  5403. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
  5404. Lastly, the accumulator is saturated to yield a result in 1.15 format.
  5405. */
  5406. __STATIC_FORCEINLINE q15_t arm_pid_q15(
  5407. arm_pid_instance_q15 * S,
  5408. q15_t in)
  5409. {
  5410. q63_t acc;
  5411. q15_t out;
  5412. #if defined (ARM_MATH_DSP)
  5413. /* Implementation of PID controller */
  5414. /* acc = A0 * x[n] */
  5415. acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in);
  5416. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  5417. acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)read_q15x2 (S->state), (uint64_t)acc);
  5418. #else
  5419. /* acc = A0 * x[n] */
  5420. acc = ((q31_t) S->A0) * in;
  5421. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  5422. acc += (q31_t) S->A1 * S->state[0];
  5423. acc += (q31_t) S->A2 * S->state[1];
  5424. #endif
  5425. /* acc += y[n-1] */
  5426. acc += (q31_t) S->state[2] << 15;
  5427. /* saturate the output */
  5428. out = (q15_t) (__SSAT((q31_t)(acc >> 15), 16));
  5429. /* Update state */
  5430. S->state[1] = S->state[0];
  5431. S->state[0] = in;
  5432. S->state[2] = out;
  5433. /* return to application */
  5434. return (out);
  5435. }
  5436. /**
  5437. * @} end of PID group
  5438. */
  5439. /**
  5440. * @brief Floating-point matrix inverse.
  5441. * @param[in] src points to the instance of the input floating-point matrix structure.
  5442. * @param[out] dst points to the instance of the output floating-point matrix structure.
  5443. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  5444. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  5445. */
  5446. arm_status arm_mat_inverse_f32(
  5447. const arm_matrix_instance_f32 * src,
  5448. arm_matrix_instance_f32 * dst);
  5449. /**
  5450. * @brief Floating-point matrix inverse.
  5451. * @param[in] src points to the instance of the input floating-point matrix structure.
  5452. * @param[out] dst points to the instance of the output floating-point matrix structure.
  5453. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  5454. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  5455. */
  5456. arm_status arm_mat_inverse_f64(
  5457. const arm_matrix_instance_f64 * src,
  5458. arm_matrix_instance_f64 * dst);
  5459. /**
  5460. * @ingroup groupController
  5461. */
  5462. /**
  5463. * @defgroup clarke Vector Clarke Transform
  5464. * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
  5465. * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
  5466. * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
  5467. * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
  5468. * \image html clarke.gif Stator current space vector and its components in (a,b).
  5469. * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
  5470. * can be calculated using only <code>Ia</code> and <code>Ib</code>.
  5471. *
  5472. * The function operates on a single sample of data and each call to the function returns the processed output.
  5473. * The library provides separate functions for Q31 and floating-point data types.
  5474. * \par Algorithm
  5475. * \image html clarkeFormula.gif
  5476. * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
  5477. * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
  5478. * \par Fixed-Point Behavior
  5479. * Care must be taken when using the Q31 version of the Clarke transform.
  5480. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  5481. * Refer to the function specific documentation below for usage guidelines.
  5482. */
  5483. /**
  5484. * @addtogroup clarke
  5485. * @{
  5486. */
  5487. /**
  5488. *
  5489. * @brief Floating-point Clarke transform
  5490. * @param[in] Ia input three-phase coordinate <code>a</code>
  5491. * @param[in] Ib input three-phase coordinate <code>b</code>
  5492. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  5493. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  5494. * @return none
  5495. */
  5496. __STATIC_FORCEINLINE void arm_clarke_f32(
  5497. float32_t Ia,
  5498. float32_t Ib,
  5499. float32_t * pIalpha,
  5500. float32_t * pIbeta)
  5501. {
  5502. /* Calculate pIalpha using the equation, pIalpha = Ia */
  5503. *pIalpha = Ia;
  5504. /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
  5505. *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
  5506. }
  5507. /**
  5508. @brief Clarke transform for Q31 version
  5509. @param[in] Ia input three-phase coordinate <code>a</code>
  5510. @param[in] Ib input three-phase coordinate <code>b</code>
  5511. @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  5512. @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  5513. @return none
  5514. \par Scaling and Overflow Behavior
  5515. The function is implemented using an internal 32-bit accumulator.
  5516. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  5517. There is saturation on the addition, hence there is no risk of overflow.
  5518. */
  5519. __STATIC_FORCEINLINE void arm_clarke_q31(
  5520. q31_t Ia,
  5521. q31_t Ib,
  5522. q31_t * pIalpha,
  5523. q31_t * pIbeta)
  5524. {
  5525. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  5526. /* Calculating pIalpha from Ia by equation pIalpha = Ia */
  5527. *pIalpha = Ia;
  5528. /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
  5529. product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
  5530. /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
  5531. product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
  5532. /* pIbeta is calculated by adding the intermediate products */
  5533. *pIbeta = __QADD(product1, product2);
  5534. }
  5535. /**
  5536. * @} end of clarke group
  5537. */
  5538. /**
  5539. * @ingroup groupController
  5540. */
  5541. /**
  5542. * @defgroup inv_clarke Vector Inverse Clarke Transform
  5543. * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
  5544. *
  5545. * The function operates on a single sample of data and each call to the function returns the processed output.
  5546. * The library provides separate functions for Q31 and floating-point data types.
  5547. * \par Algorithm
  5548. * \image html clarkeInvFormula.gif
  5549. * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
  5550. * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
  5551. * \par Fixed-Point Behavior
  5552. * Care must be taken when using the Q31 version of the Clarke transform.
  5553. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  5554. * Refer to the function specific documentation below for usage guidelines.
  5555. */
  5556. /**
  5557. * @addtogroup inv_clarke
  5558. * @{
  5559. */
  5560. /**
  5561. * @brief Floating-point Inverse Clarke transform
  5562. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  5563. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  5564. * @param[out] pIa points to output three-phase coordinate <code>a</code>
  5565. * @param[out] pIb points to output three-phase coordinate <code>b</code>
  5566. * @return none
  5567. */
  5568. __STATIC_FORCEINLINE void arm_inv_clarke_f32(
  5569. float32_t Ialpha,
  5570. float32_t Ibeta,
  5571. float32_t * pIa,
  5572. float32_t * pIb)
  5573. {
  5574. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  5575. *pIa = Ialpha;
  5576. /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
  5577. *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta;
  5578. }
  5579. /**
  5580. @brief Inverse Clarke transform for Q31 version
  5581. @param[in] Ialpha input two-phase orthogonal vector axis alpha
  5582. @param[in] Ibeta input two-phase orthogonal vector axis beta
  5583. @param[out] pIa points to output three-phase coordinate <code>a</code>
  5584. @param[out] pIb points to output three-phase coordinate <code>b</code>
  5585. @return none
  5586. \par Scaling and Overflow Behavior
  5587. The function is implemented using an internal 32-bit accumulator.
  5588. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  5589. There is saturation on the subtraction, hence there is no risk of overflow.
  5590. */
  5591. __STATIC_FORCEINLINE void arm_inv_clarke_q31(
  5592. q31_t Ialpha,
  5593. q31_t Ibeta,
  5594. q31_t * pIa,
  5595. q31_t * pIb)
  5596. {
  5597. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  5598. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  5599. *pIa = Ialpha;
  5600. /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
  5601. product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
  5602. /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
  5603. product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
  5604. /* pIb is calculated by subtracting the products */
  5605. *pIb = __QSUB(product2, product1);
  5606. }
  5607. /**
  5608. * @} end of inv_clarke group
  5609. */
  5610. /**
  5611. * @ingroup groupController
  5612. */
  5613. /**
  5614. * @defgroup park Vector Park Transform
  5615. *
  5616. * Forward Park transform converts the input two-coordinate vector to flux and torque components.
  5617. * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
  5618. * from the stationary to the moving reference frame and control the spatial relationship between
  5619. * the stator vector current and rotor flux vector.
  5620. * If we consider the d axis aligned with the rotor flux, the diagram below shows the
  5621. * current vector and the relationship from the two reference frames:
  5622. * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
  5623. *
  5624. * The function operates on a single sample of data and each call to the function returns the processed output.
  5625. * The library provides separate functions for Q31 and floating-point data types.
  5626. * \par Algorithm
  5627. * \image html parkFormula.gif
  5628. * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
  5629. * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  5630. * cosine and sine values of theta (rotor flux position).
  5631. * \par Fixed-Point Behavior
  5632. * Care must be taken when using the Q31 version of the Park transform.
  5633. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  5634. * Refer to the function specific documentation below for usage guidelines.
  5635. */
  5636. /**
  5637. * @addtogroup park
  5638. * @{
  5639. */
  5640. /**
  5641. * @brief Floating-point Park transform
  5642. * @param[in] Ialpha input two-phase vector coordinate alpha
  5643. * @param[in] Ibeta input two-phase vector coordinate beta
  5644. * @param[out] pId points to output rotor reference frame d
  5645. * @param[out] pIq points to output rotor reference frame q
  5646. * @param[in] sinVal sine value of rotation angle theta
  5647. * @param[in] cosVal cosine value of rotation angle theta
  5648. * @return none
  5649. *
  5650. * The function implements the forward Park transform.
  5651. *
  5652. */
  5653. __STATIC_FORCEINLINE void arm_park_f32(
  5654. float32_t Ialpha,
  5655. float32_t Ibeta,
  5656. float32_t * pId,
  5657. float32_t * pIq,
  5658. float32_t sinVal,
  5659. float32_t cosVal)
  5660. {
  5661. /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
  5662. *pId = Ialpha * cosVal + Ibeta * sinVal;
  5663. /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
  5664. *pIq = -Ialpha * sinVal + Ibeta * cosVal;
  5665. }
  5666. /**
  5667. @brief Park transform for Q31 version
  5668. @param[in] Ialpha input two-phase vector coordinate alpha
  5669. @param[in] Ibeta input two-phase vector coordinate beta
  5670. @param[out] pId points to output rotor reference frame d
  5671. @param[out] pIq points to output rotor reference frame q
  5672. @param[in] sinVal sine value of rotation angle theta
  5673. @param[in] cosVal cosine value of rotation angle theta
  5674. @return none
  5675. \par Scaling and Overflow Behavior
  5676. The function is implemented using an internal 32-bit accumulator.
  5677. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  5678. There is saturation on the addition and subtraction, hence there is no risk of overflow.
  5679. */
  5680. __STATIC_FORCEINLINE void arm_park_q31(
  5681. q31_t Ialpha,
  5682. q31_t Ibeta,
  5683. q31_t * pId,
  5684. q31_t * pIq,
  5685. q31_t sinVal,
  5686. q31_t cosVal)
  5687. {
  5688. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  5689. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  5690. /* Intermediate product is calculated by (Ialpha * cosVal) */
  5691. product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
  5692. /* Intermediate product is calculated by (Ibeta * sinVal) */
  5693. product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
  5694. /* Intermediate product is calculated by (Ialpha * sinVal) */
  5695. product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
  5696. /* Intermediate product is calculated by (Ibeta * cosVal) */
  5697. product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
  5698. /* Calculate pId by adding the two intermediate products 1 and 2 */
  5699. *pId = __QADD(product1, product2);
  5700. /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
  5701. *pIq = __QSUB(product4, product3);
  5702. }
  5703. /**
  5704. * @} end of park group
  5705. */
  5706. /**
  5707. * @ingroup groupController
  5708. */
  5709. /**
  5710. * @defgroup inv_park Vector Inverse Park transform
  5711. * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
  5712. *
  5713. * The function operates on a single sample of data and each call to the function returns the processed output.
  5714. * The library provides separate functions for Q31 and floating-point data types.
  5715. * \par Algorithm
  5716. * \image html parkInvFormula.gif
  5717. * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
  5718. * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  5719. * cosine and sine values of theta (rotor flux position).
  5720. * \par Fixed-Point Behavior
  5721. * Care must be taken when using the Q31 version of the Park transform.
  5722. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  5723. * Refer to the function specific documentation below for usage guidelines.
  5724. */
  5725. /**
  5726. * @addtogroup inv_park
  5727. * @{
  5728. */
  5729. /**
  5730. * @brief Floating-point Inverse Park transform
  5731. * @param[in] Id input coordinate of rotor reference frame d
  5732. * @param[in] Iq input coordinate of rotor reference frame q
  5733. * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  5734. * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  5735. * @param[in] sinVal sine value of rotation angle theta
  5736. * @param[in] cosVal cosine value of rotation angle theta
  5737. * @return none
  5738. */
  5739. __STATIC_FORCEINLINE void arm_inv_park_f32(
  5740. float32_t Id,
  5741. float32_t Iq,
  5742. float32_t * pIalpha,
  5743. float32_t * pIbeta,
  5744. float32_t sinVal,
  5745. float32_t cosVal)
  5746. {
  5747. /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
  5748. *pIalpha = Id * cosVal - Iq * sinVal;
  5749. /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
  5750. *pIbeta = Id * sinVal + Iq * cosVal;
  5751. }
  5752. /**
  5753. @brief Inverse Park transform for Q31 version
  5754. @param[in] Id input coordinate of rotor reference frame d
  5755. @param[in] Iq input coordinate of rotor reference frame q
  5756. @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
  5757. @param[out] pIbeta points to output two-phase orthogonal vector axis beta
  5758. @param[in] sinVal sine value of rotation angle theta
  5759. @param[in] cosVal cosine value of rotation angle theta
  5760. @return none
  5761. @par Scaling and Overflow Behavior
  5762. The function is implemented using an internal 32-bit accumulator.
  5763. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  5764. There is saturation on the addition, hence there is no risk of overflow.
  5765. */
  5766. __STATIC_FORCEINLINE void arm_inv_park_q31(
  5767. q31_t Id,
  5768. q31_t Iq,
  5769. q31_t * pIalpha,
  5770. q31_t * pIbeta,
  5771. q31_t sinVal,
  5772. q31_t cosVal)
  5773. {
  5774. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  5775. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  5776. /* Intermediate product is calculated by (Id * cosVal) */
  5777. product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
  5778. /* Intermediate product is calculated by (Iq * sinVal) */
  5779. product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
  5780. /* Intermediate product is calculated by (Id * sinVal) */
  5781. product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
  5782. /* Intermediate product is calculated by (Iq * cosVal) */
  5783. product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
  5784. /* Calculate pIalpha by using the two intermediate products 1 and 2 */
  5785. *pIalpha = __QSUB(product1, product2);
  5786. /* Calculate pIbeta by using the two intermediate products 3 and 4 */
  5787. *pIbeta = __QADD(product4, product3);
  5788. }
  5789. /**
  5790. * @} end of Inverse park group
  5791. */
  5792. /**
  5793. * @ingroup groupInterpolation
  5794. */
  5795. /**
  5796. * @defgroup LinearInterpolate Linear Interpolation
  5797. *
  5798. * Linear interpolation is a method of curve fitting using linear polynomials.
  5799. * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
  5800. *
  5801. * \par
  5802. * \image html LinearInterp.gif "Linear interpolation"
  5803. *
  5804. * \par
  5805. * A Linear Interpolate function calculates an output value(y), for the input(x)
  5806. * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
  5807. *
  5808. * \par Algorithm:
  5809. * <pre>
  5810. * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
  5811. * where x0, x1 are nearest values of input x
  5812. * y0, y1 are nearest values to output y
  5813. * </pre>
  5814. *
  5815. * \par
  5816. * This set of functions implements Linear interpolation process
  5817. * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
  5818. * sample of data and each call to the function returns a single processed value.
  5819. * <code>S</code> points to an instance of the Linear Interpolate function data structure.
  5820. * <code>x</code> is the input sample value. The functions returns the output value.
  5821. *
  5822. * \par
  5823. * if x is outside of the table boundary, Linear interpolation returns first value of the table
  5824. * if x is below input range and returns last value of table if x is above range.
  5825. */
  5826. /**
  5827. * @addtogroup LinearInterpolate
  5828. * @{
  5829. */
  5830. /**
  5831. * @brief Process function for the floating-point Linear Interpolation Function.
  5832. * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
  5833. * @param[in] x input sample to process
  5834. * @return y processed output sample.
  5835. *
  5836. */
  5837. __STATIC_FORCEINLINE float32_t arm_linear_interp_f32(
  5838. arm_linear_interp_instance_f32 * S,
  5839. float32_t x)
  5840. {
  5841. float32_t y;
  5842. float32_t x0, x1; /* Nearest input values */
  5843. float32_t y0, y1; /* Nearest output values */
  5844. float32_t xSpacing = S->xSpacing; /* spacing between input values */
  5845. int32_t i; /* Index variable */
  5846. float32_t *pYData = S->pYData; /* pointer to output table */
  5847. /* Calculation of index */
  5848. i = (int32_t) ((x - S->x1) / xSpacing);
  5849. if (i < 0)
  5850. {
  5851. /* Iniatilize output for below specified range as least output value of table */
  5852. y = pYData[0];
  5853. }
  5854. else if ((uint32_t)i >= (S->nValues - 1))
  5855. {
  5856. /* Iniatilize output for above specified range as last output value of table */
  5857. y = pYData[S->nValues - 1];
  5858. }
  5859. else
  5860. {
  5861. /* Calculation of nearest input values */
  5862. x0 = S->x1 + i * xSpacing;
  5863. x1 = S->x1 + (i + 1) * xSpacing;
  5864. /* Read of nearest output values */
  5865. y0 = pYData[i];
  5866. y1 = pYData[i + 1];
  5867. /* Calculation of output */
  5868. y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
  5869. }
  5870. /* returns output value */
  5871. return (y);
  5872. }
  5873. /**
  5874. *
  5875. * @brief Process function for the Q31 Linear Interpolation Function.
  5876. * @param[in] pYData pointer to Q31 Linear Interpolation table
  5877. * @param[in] x input sample to process
  5878. * @param[in] nValues number of table values
  5879. * @return y processed output sample.
  5880. *
  5881. * \par
  5882. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  5883. * This function can support maximum of table size 2^12.
  5884. *
  5885. */
  5886. __STATIC_FORCEINLINE q31_t arm_linear_interp_q31(
  5887. q31_t * pYData,
  5888. q31_t x,
  5889. uint32_t nValues)
  5890. {
  5891. q31_t y; /* output */
  5892. q31_t y0, y1; /* Nearest output values */
  5893. q31_t fract; /* fractional part */
  5894. int32_t index; /* Index to read nearest output values */
  5895. /* Input is in 12.20 format */
  5896. /* 12 bits for the table index */
  5897. /* Index value calculation */
  5898. index = ((x & (q31_t)0xFFF00000) >> 20);
  5899. if (index >= (int32_t)(nValues - 1))
  5900. {
  5901. return (pYData[nValues - 1]);
  5902. }
  5903. else if (index < 0)
  5904. {
  5905. return (pYData[0]);
  5906. }
  5907. else
  5908. {
  5909. /* 20 bits for the fractional part */
  5910. /* shift left by 11 to keep fract in 1.31 format */
  5911. fract = (x & 0x000FFFFF) << 11;
  5912. /* Read two nearest output values from the index in 1.31(q31) format */
  5913. y0 = pYData[index];
  5914. y1 = pYData[index + 1];
  5915. /* Calculation of y0 * (1-fract) and y is in 2.30 format */
  5916. y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
  5917. /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
  5918. y += ((q31_t) (((q63_t) y1 * fract) >> 32));
  5919. /* Convert y to 1.31 format */
  5920. return (y << 1U);
  5921. }
  5922. }
  5923. /**
  5924. *
  5925. * @brief Process function for the Q15 Linear Interpolation Function.
  5926. * @param[in] pYData pointer to Q15 Linear Interpolation table
  5927. * @param[in] x input sample to process
  5928. * @param[in] nValues number of table values
  5929. * @return y processed output sample.
  5930. *
  5931. * \par
  5932. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  5933. * This function can support maximum of table size 2^12.
  5934. *
  5935. */
  5936. __STATIC_FORCEINLINE q15_t arm_linear_interp_q15(
  5937. q15_t * pYData,
  5938. q31_t x,
  5939. uint32_t nValues)
  5940. {
  5941. q63_t y; /* output */
  5942. q15_t y0, y1; /* Nearest output values */
  5943. q31_t fract; /* fractional part */
  5944. int32_t index; /* Index to read nearest output values */
  5945. /* Input is in 12.20 format */
  5946. /* 12 bits for the table index */
  5947. /* Index value calculation */
  5948. index = ((x & (int32_t)0xFFF00000) >> 20);
  5949. if (index >= (int32_t)(nValues - 1))
  5950. {
  5951. return (pYData[nValues - 1]);
  5952. }
  5953. else if (index < 0)
  5954. {
  5955. return (pYData[0]);
  5956. }
  5957. else
  5958. {
  5959. /* 20 bits for the fractional part */
  5960. /* fract is in 12.20 format */
  5961. fract = (x & 0x000FFFFF);
  5962. /* Read two nearest output values from the index */
  5963. y0 = pYData[index];
  5964. y1 = pYData[index + 1];
  5965. /* Calculation of y0 * (1-fract) and y is in 13.35 format */
  5966. y = ((q63_t) y0 * (0xFFFFF - fract));
  5967. /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
  5968. y += ((q63_t) y1 * (fract));
  5969. /* convert y to 1.15 format */
  5970. return (q15_t) (y >> 20);
  5971. }
  5972. }
  5973. /**
  5974. *
  5975. * @brief Process function for the Q7 Linear Interpolation Function.
  5976. * @param[in] pYData pointer to Q7 Linear Interpolation table
  5977. * @param[in] x input sample to process
  5978. * @param[in] nValues number of table values
  5979. * @return y processed output sample.
  5980. *
  5981. * \par
  5982. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  5983. * This function can support maximum of table size 2^12.
  5984. */
  5985. __STATIC_FORCEINLINE q7_t arm_linear_interp_q7(
  5986. q7_t * pYData,
  5987. q31_t x,
  5988. uint32_t nValues)
  5989. {
  5990. q31_t y; /* output */
  5991. q7_t y0, y1; /* Nearest output values */
  5992. q31_t fract; /* fractional part */
  5993. uint32_t index; /* Index to read nearest output values */
  5994. /* Input is in 12.20 format */
  5995. /* 12 bits for the table index */
  5996. /* Index value calculation */
  5997. if (x < 0)
  5998. {
  5999. return (pYData[0]);
  6000. }
  6001. index = (x >> 20) & 0xfff;
  6002. if (index >= (nValues - 1))
  6003. {
  6004. return (pYData[nValues - 1]);
  6005. }
  6006. else
  6007. {
  6008. /* 20 bits for the fractional part */
  6009. /* fract is in 12.20 format */
  6010. fract = (x & 0x000FFFFF);
  6011. /* Read two nearest output values from the index and are in 1.7(q7) format */
  6012. y0 = pYData[index];
  6013. y1 = pYData[index + 1];
  6014. /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
  6015. y = ((y0 * (0xFFFFF - fract)));
  6016. /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
  6017. y += (y1 * fract);
  6018. /* convert y to 1.7(q7) format */
  6019. return (q7_t) (y >> 20);
  6020. }
  6021. }
  6022. /**
  6023. * @} end of LinearInterpolate group
  6024. */
  6025. /**
  6026. * @brief Fast approximation to the trigonometric sine function for floating-point data.
  6027. * @param[in] x input value in radians.
  6028. * @return sin(x).
  6029. */
  6030. float32_t arm_sin_f32(
  6031. float32_t x);
  6032. /**
  6033. * @brief Fast approximation to the trigonometric sine function for Q31 data.
  6034. * @param[in] x Scaled input value in radians.
  6035. * @return sin(x).
  6036. */
  6037. q31_t arm_sin_q31(
  6038. q31_t x);
  6039. /**
  6040. * @brief Fast approximation to the trigonometric sine function for Q15 data.
  6041. * @param[in] x Scaled input value in radians.
  6042. * @return sin(x).
  6043. */
  6044. q15_t arm_sin_q15(
  6045. q15_t x);
  6046. /**
  6047. * @brief Fast approximation to the trigonometric cosine function for floating-point data.
  6048. * @param[in] x input value in radians.
  6049. * @return cos(x).
  6050. */
  6051. float32_t arm_cos_f32(
  6052. float32_t x);
  6053. /**
  6054. * @brief Fast approximation to the trigonometric cosine function for Q31 data.
  6055. * @param[in] x Scaled input value in radians.
  6056. * @return cos(x).
  6057. */
  6058. q31_t arm_cos_q31(
  6059. q31_t x);
  6060. /**
  6061. * @brief Fast approximation to the trigonometric cosine function for Q15 data.
  6062. * @param[in] x Scaled input value in radians.
  6063. * @return cos(x).
  6064. */
  6065. q15_t arm_cos_q15(
  6066. q15_t x);
  6067. /**
  6068. @brief Floating-point vector of log values.
  6069. @param[in] pSrc points to the input vector
  6070. @param[out] pDst points to the output vector
  6071. @param[in] blockSize number of samples in each vector
  6072. @return none
  6073. */
  6074. void arm_vlog_f32(
  6075. const float32_t * pSrc,
  6076. float32_t * pDst,
  6077. uint32_t blockSize);
  6078. /**
  6079. @brief Floating-point vector of exp values.
  6080. @param[in] pSrc points to the input vector
  6081. @param[out] pDst points to the output vector
  6082. @param[in] blockSize number of samples in each vector
  6083. @return none
  6084. */
  6085. void arm_vexp_f32(
  6086. const float32_t * pSrc,
  6087. float32_t * pDst,
  6088. uint32_t blockSize);
  6089. /**
  6090. * @ingroup groupFastMath
  6091. */
  6092. /**
  6093. * @defgroup SQRT Square Root
  6094. *
  6095. * Computes the square root of a number.
  6096. * There are separate functions for Q15, Q31, and floating-point data types.
  6097. * The square root function is computed using the Newton-Raphson algorithm.
  6098. * This is an iterative algorithm of the form:
  6099. * <pre>
  6100. * x1 = x0 - f(x0)/f'(x0)
  6101. * </pre>
  6102. * where <code>x1</code> is the current estimate,
  6103. * <code>x0</code> is the previous estimate, and
  6104. * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
  6105. * For the square root function, the algorithm reduces to:
  6106. * <pre>
  6107. * x0 = in/2 [initial guess]
  6108. * x1 = 1/2 * ( x0 + in / x0) [each iteration]
  6109. * </pre>
  6110. */
  6111. /**
  6112. * @addtogroup SQRT
  6113. * @{
  6114. */
  6115. /**
  6116. @brief Floating-point square root function.
  6117. @param[in] in input value
  6118. @param[out] pOut square root of input value
  6119. @return execution status
  6120. - \ref ARM_MATH_SUCCESS : input value is positive
  6121. - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0
  6122. */
  6123. __STATIC_FORCEINLINE arm_status arm_sqrt_f32(
  6124. float32_t in,
  6125. float32_t * pOut)
  6126. {
  6127. if (in >= 0.0f)
  6128. {
  6129. #if defined ( __CC_ARM )
  6130. #if defined __TARGET_FPU_VFP
  6131. *pOut = __sqrtf(in);
  6132. #else
  6133. *pOut = sqrtf(in);
  6134. #endif
  6135. #elif defined ( __ICCARM__ )
  6136. #if defined __ARMVFP__
  6137. __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in));
  6138. #else
  6139. *pOut = sqrtf(in);
  6140. #endif
  6141. #else
  6142. *pOut = sqrtf(in);
  6143. #endif
  6144. return (ARM_MATH_SUCCESS);
  6145. }
  6146. else
  6147. {
  6148. *pOut = 0.0f;
  6149. return (ARM_MATH_ARGUMENT_ERROR);
  6150. }
  6151. }
  6152. /**
  6153. @brief Q31 square root function.
  6154. @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF
  6155. @param[out] pOut points to square root of input value
  6156. @return execution status
  6157. - \ref ARM_MATH_SUCCESS : input value is positive
  6158. - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0
  6159. */
  6160. arm_status arm_sqrt_q31(
  6161. q31_t in,
  6162. q31_t * pOut);
  6163. /**
  6164. @brief Q15 square root function.
  6165. @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF
  6166. @param[out] pOut points to square root of input value
  6167. @return execution status
  6168. - \ref ARM_MATH_SUCCESS : input value is positive
  6169. - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0
  6170. */
  6171. arm_status arm_sqrt_q15(
  6172. q15_t in,
  6173. q15_t * pOut);
  6174. /**
  6175. * @brief Vector Floating-point square root function.
  6176. * @param[in] pIn input vector.
  6177. * @param[out] pOut vector of square roots of input elements.
  6178. * @param[in] len length of input vector.
  6179. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  6180. * <code>in</code> is negative value and returns zero output for negative values.
  6181. */
  6182. void arm_vsqrt_f32(
  6183. float32_t * pIn,
  6184. float32_t * pOut,
  6185. uint16_t len);
  6186. void arm_vsqrt_q31(
  6187. q31_t * pIn,
  6188. q31_t * pOut,
  6189. uint16_t len);
  6190. void arm_vsqrt_q15(
  6191. q15_t * pIn,
  6192. q15_t * pOut,
  6193. uint16_t len);
  6194. /**
  6195. * @} end of SQRT group
  6196. */
  6197. /**
  6198. * @brief floating-point Circular write function.
  6199. */
  6200. __STATIC_FORCEINLINE void arm_circularWrite_f32(
  6201. int32_t * circBuffer,
  6202. int32_t L,
  6203. uint16_t * writeOffset,
  6204. int32_t bufferInc,
  6205. const int32_t * src,
  6206. int32_t srcInc,
  6207. uint32_t blockSize)
  6208. {
  6209. uint32_t i = 0U;
  6210. int32_t wOffset;
  6211. /* Copy the value of Index pointer that points
  6212. * to the current location where the input samples to be copied */
  6213. wOffset = *writeOffset;
  6214. /* Loop over the blockSize */
  6215. i = blockSize;
  6216. while (i > 0U)
  6217. {
  6218. /* copy the input sample to the circular buffer */
  6219. circBuffer[wOffset] = *src;
  6220. /* Update the input pointer */
  6221. src += srcInc;
  6222. /* Circularly update wOffset. Watch out for positive and negative value */
  6223. wOffset += bufferInc;
  6224. if (wOffset >= L)
  6225. wOffset -= L;
  6226. /* Decrement the loop counter */
  6227. i--;
  6228. }
  6229. /* Update the index pointer */
  6230. *writeOffset = (uint16_t)wOffset;
  6231. }
  6232. /**
  6233. * @brief floating-point Circular Read function.
  6234. */
  6235. __STATIC_FORCEINLINE void arm_circularRead_f32(
  6236. int32_t * circBuffer,
  6237. int32_t L,
  6238. int32_t * readOffset,
  6239. int32_t bufferInc,
  6240. int32_t * dst,
  6241. int32_t * dst_base,
  6242. int32_t dst_length,
  6243. int32_t dstInc,
  6244. uint32_t blockSize)
  6245. {
  6246. uint32_t i = 0U;
  6247. int32_t rOffset;
  6248. int32_t* dst_end;
  6249. /* Copy the value of Index pointer that points
  6250. * to the current location from where the input samples to be read */
  6251. rOffset = *readOffset;
  6252. dst_end = dst_base + dst_length;
  6253. /* Loop over the blockSize */
  6254. i = blockSize;
  6255. while (i > 0U)
  6256. {
  6257. /* copy the sample from the circular buffer to the destination buffer */
  6258. *dst = circBuffer[rOffset];
  6259. /* Update the input pointer */
  6260. dst += dstInc;
  6261. if (dst == dst_end)
  6262. {
  6263. dst = dst_base;
  6264. }
  6265. /* Circularly update rOffset. Watch out for positive and negative value */
  6266. rOffset += bufferInc;
  6267. if (rOffset >= L)
  6268. {
  6269. rOffset -= L;
  6270. }
  6271. /* Decrement the loop counter */
  6272. i--;
  6273. }
  6274. /* Update the index pointer */
  6275. *readOffset = rOffset;
  6276. }
  6277. /**
  6278. * @brief Q15 Circular write function.
  6279. */
  6280. __STATIC_FORCEINLINE void arm_circularWrite_q15(
  6281. q15_t * circBuffer,
  6282. int32_t L,
  6283. uint16_t * writeOffset,
  6284. int32_t bufferInc,
  6285. const q15_t * src,
  6286. int32_t srcInc,
  6287. uint32_t blockSize)
  6288. {
  6289. uint32_t i = 0U;
  6290. int32_t wOffset;
  6291. /* Copy the value of Index pointer that points
  6292. * to the current location where the input samples to be copied */
  6293. wOffset = *writeOffset;
  6294. /* Loop over the blockSize */
  6295. i = blockSize;
  6296. while (i > 0U)
  6297. {
  6298. /* copy the input sample to the circular buffer */
  6299. circBuffer[wOffset] = *src;
  6300. /* Update the input pointer */
  6301. src += srcInc;
  6302. /* Circularly update wOffset. Watch out for positive and negative value */
  6303. wOffset += bufferInc;
  6304. if (wOffset >= L)
  6305. wOffset -= L;
  6306. /* Decrement the loop counter */
  6307. i--;
  6308. }
  6309. /* Update the index pointer */
  6310. *writeOffset = (uint16_t)wOffset;
  6311. }
  6312. /**
  6313. * @brief Q15 Circular Read function.
  6314. */
  6315. __STATIC_FORCEINLINE void arm_circularRead_q15(
  6316. q15_t * circBuffer,
  6317. int32_t L,
  6318. int32_t * readOffset,
  6319. int32_t bufferInc,
  6320. q15_t * dst,
  6321. q15_t * dst_base,
  6322. int32_t dst_length,
  6323. int32_t dstInc,
  6324. uint32_t blockSize)
  6325. {
  6326. uint32_t i = 0;
  6327. int32_t rOffset;
  6328. q15_t* dst_end;
  6329. /* Copy the value of Index pointer that points
  6330. * to the current location from where the input samples to be read */
  6331. rOffset = *readOffset;
  6332. dst_end = dst_base + dst_length;
  6333. /* Loop over the blockSize */
  6334. i = blockSize;
  6335. while (i > 0U)
  6336. {
  6337. /* copy the sample from the circular buffer to the destination buffer */
  6338. *dst = circBuffer[rOffset];
  6339. /* Update the input pointer */
  6340. dst += dstInc;
  6341. if (dst == dst_end)
  6342. {
  6343. dst = dst_base;
  6344. }
  6345. /* Circularly update wOffset. Watch out for positive and negative value */
  6346. rOffset += bufferInc;
  6347. if (rOffset >= L)
  6348. {
  6349. rOffset -= L;
  6350. }
  6351. /* Decrement the loop counter */
  6352. i--;
  6353. }
  6354. /* Update the index pointer */
  6355. *readOffset = rOffset;
  6356. }
  6357. /**
  6358. * @brief Q7 Circular write function.
  6359. */
  6360. __STATIC_FORCEINLINE void arm_circularWrite_q7(
  6361. q7_t * circBuffer,
  6362. int32_t L,
  6363. uint16_t * writeOffset,
  6364. int32_t bufferInc,
  6365. const q7_t * src,
  6366. int32_t srcInc,
  6367. uint32_t blockSize)
  6368. {
  6369. uint32_t i = 0U;
  6370. int32_t wOffset;
  6371. /* Copy the value of Index pointer that points
  6372. * to the current location where the input samples to be copied */
  6373. wOffset = *writeOffset;
  6374. /* Loop over the blockSize */
  6375. i = blockSize;
  6376. while (i > 0U)
  6377. {
  6378. /* copy the input sample to the circular buffer */
  6379. circBuffer[wOffset] = *src;
  6380. /* Update the input pointer */
  6381. src += srcInc;
  6382. /* Circularly update wOffset. Watch out for positive and negative value */
  6383. wOffset += bufferInc;
  6384. if (wOffset >= L)
  6385. wOffset -= L;
  6386. /* Decrement the loop counter */
  6387. i--;
  6388. }
  6389. /* Update the index pointer */
  6390. *writeOffset = (uint16_t)wOffset;
  6391. }
  6392. /**
  6393. * @brief Q7 Circular Read function.
  6394. */
  6395. __STATIC_FORCEINLINE void arm_circularRead_q7(
  6396. q7_t * circBuffer,
  6397. int32_t L,
  6398. int32_t * readOffset,
  6399. int32_t bufferInc,
  6400. q7_t * dst,
  6401. q7_t * dst_base,
  6402. int32_t dst_length,
  6403. int32_t dstInc,
  6404. uint32_t blockSize)
  6405. {
  6406. uint32_t i = 0;
  6407. int32_t rOffset;
  6408. q7_t* dst_end;
  6409. /* Copy the value of Index pointer that points
  6410. * to the current location from where the input samples to be read */
  6411. rOffset = *readOffset;
  6412. dst_end = dst_base + dst_length;
  6413. /* Loop over the blockSize */
  6414. i = blockSize;
  6415. while (i > 0U)
  6416. {
  6417. /* copy the sample from the circular buffer to the destination buffer */
  6418. *dst = circBuffer[rOffset];
  6419. /* Update the input pointer */
  6420. dst += dstInc;
  6421. if (dst == dst_end)
  6422. {
  6423. dst = dst_base;
  6424. }
  6425. /* Circularly update rOffset. Watch out for positive and negative value */
  6426. rOffset += bufferInc;
  6427. if (rOffset >= L)
  6428. {
  6429. rOffset -= L;
  6430. }
  6431. /* Decrement the loop counter */
  6432. i--;
  6433. }
  6434. /* Update the index pointer */
  6435. *readOffset = rOffset;
  6436. }
  6437. /**
  6438. * @brief Sum of the squares of the elements of a Q31 vector.
  6439. * @param[in] pSrc is input pointer
  6440. * @param[in] blockSize is the number of samples to process
  6441. * @param[out] pResult is output value.
  6442. */
  6443. void arm_power_q31(
  6444. const q31_t * pSrc,
  6445. uint32_t blockSize,
  6446. q63_t * pResult);
  6447. /**
  6448. * @brief Sum of the squares of the elements of a floating-point vector.
  6449. * @param[in] pSrc is input pointer
  6450. * @param[in] blockSize is the number of samples to process
  6451. * @param[out] pResult is output value.
  6452. */
  6453. void arm_power_f32(
  6454. const float32_t * pSrc,
  6455. uint32_t blockSize,
  6456. float32_t * pResult);
  6457. /**
  6458. * @brief Sum of the squares of the elements of a Q15 vector.
  6459. * @param[in] pSrc is input pointer
  6460. * @param[in] blockSize is the number of samples to process
  6461. * @param[out] pResult is output value.
  6462. */
  6463. void arm_power_q15(
  6464. const q15_t * pSrc,
  6465. uint32_t blockSize,
  6466. q63_t * pResult);
  6467. /**
  6468. * @brief Sum of the squares of the elements of a Q7 vector.
  6469. * @param[in] pSrc is input pointer
  6470. * @param[in] blockSize is the number of samples to process
  6471. * @param[out] pResult is output value.
  6472. */
  6473. void arm_power_q7(
  6474. const q7_t * pSrc,
  6475. uint32_t blockSize,
  6476. q31_t * pResult);
  6477. /**
  6478. * @brief Mean value of a Q7 vector.
  6479. * @param[in] pSrc is input pointer
  6480. * @param[in] blockSize is the number of samples to process
  6481. * @param[out] pResult is output value.
  6482. */
  6483. void arm_mean_q7(
  6484. const q7_t * pSrc,
  6485. uint32_t blockSize,
  6486. q7_t * pResult);
  6487. /**
  6488. * @brief Mean value of a Q15 vector.
  6489. * @param[in] pSrc is input pointer
  6490. * @param[in] blockSize is the number of samples to process
  6491. * @param[out] pResult is output value.
  6492. */
  6493. void arm_mean_q15(
  6494. const q15_t * pSrc,
  6495. uint32_t blockSize,
  6496. q15_t * pResult);
  6497. /**
  6498. * @brief Mean value of a Q31 vector.
  6499. * @param[in] pSrc is input pointer
  6500. * @param[in] blockSize is the number of samples to process
  6501. * @param[out] pResult is output value.
  6502. */
  6503. void arm_mean_q31(
  6504. const q31_t * pSrc,
  6505. uint32_t blockSize,
  6506. q31_t * pResult);
  6507. /**
  6508. * @brief Mean value of a floating-point vector.
  6509. * @param[in] pSrc is input pointer
  6510. * @param[in] blockSize is the number of samples to process
  6511. * @param[out] pResult is output value.
  6512. */
  6513. void arm_mean_f32(
  6514. const float32_t * pSrc,
  6515. uint32_t blockSize,
  6516. float32_t * pResult);
  6517. /**
  6518. * @brief Variance of the elements of a floating-point vector.
  6519. * @param[in] pSrc is input pointer
  6520. * @param[in] blockSize is the number of samples to process
  6521. * @param[out] pResult is output value.
  6522. */
  6523. void arm_var_f32(
  6524. const float32_t * pSrc,
  6525. uint32_t blockSize,
  6526. float32_t * pResult);
  6527. /**
  6528. * @brief Variance of the elements of a Q31 vector.
  6529. * @param[in] pSrc is input pointer
  6530. * @param[in] blockSize is the number of samples to process
  6531. * @param[out] pResult is output value.
  6532. */
  6533. void arm_var_q31(
  6534. const q31_t * pSrc,
  6535. uint32_t blockSize,
  6536. q31_t * pResult);
  6537. /**
  6538. * @brief Variance of the elements of a Q15 vector.
  6539. * @param[in] pSrc is input pointer
  6540. * @param[in] blockSize is the number of samples to process
  6541. * @param[out] pResult is output value.
  6542. */
  6543. void arm_var_q15(
  6544. const q15_t * pSrc,
  6545. uint32_t blockSize,
  6546. q15_t * pResult);
  6547. /**
  6548. * @brief Root Mean Square of the elements of a floating-point vector.
  6549. * @param[in] pSrc is input pointer
  6550. * @param[in] blockSize is the number of samples to process
  6551. * @param[out] pResult is output value.
  6552. */
  6553. void arm_rms_f32(
  6554. const float32_t * pSrc,
  6555. uint32_t blockSize,
  6556. float32_t * pResult);
  6557. /**
  6558. * @brief Root Mean Square of the elements of a Q31 vector.
  6559. * @param[in] pSrc is input pointer
  6560. * @param[in] blockSize is the number of samples to process
  6561. * @param[out] pResult is output value.
  6562. */
  6563. void arm_rms_q31(
  6564. const q31_t * pSrc,
  6565. uint32_t blockSize,
  6566. q31_t * pResult);
  6567. /**
  6568. * @brief Root Mean Square of the elements of a Q15 vector.
  6569. * @param[in] pSrc is input pointer
  6570. * @param[in] blockSize is the number of samples to process
  6571. * @param[out] pResult is output value.
  6572. */
  6573. void arm_rms_q15(
  6574. const q15_t * pSrc,
  6575. uint32_t blockSize,
  6576. q15_t * pResult);
  6577. /**
  6578. * @brief Standard deviation of the elements of a floating-point vector.
  6579. * @param[in] pSrc is input pointer
  6580. * @param[in] blockSize is the number of samples to process
  6581. * @param[out] pResult is output value.
  6582. */
  6583. void arm_std_f32(
  6584. const float32_t * pSrc,
  6585. uint32_t blockSize,
  6586. float32_t * pResult);
  6587. /**
  6588. * @brief Standard deviation of the elements of a Q31 vector.
  6589. * @param[in] pSrc is input pointer
  6590. * @param[in] blockSize is the number of samples to process
  6591. * @param[out] pResult is output value.
  6592. */
  6593. void arm_std_q31(
  6594. const q31_t * pSrc,
  6595. uint32_t blockSize,
  6596. q31_t * pResult);
  6597. /**
  6598. * @brief Standard deviation of the elements of a Q15 vector.
  6599. * @param[in] pSrc is input pointer
  6600. * @param[in] blockSize is the number of samples to process
  6601. * @param[out] pResult is output value.
  6602. */
  6603. void arm_std_q15(
  6604. const q15_t * pSrc,
  6605. uint32_t blockSize,
  6606. q15_t * pResult);
  6607. /**
  6608. * @brief Floating-point complex magnitude
  6609. * @param[in] pSrc points to the complex input vector
  6610. * @param[out] pDst points to the real output vector
  6611. * @param[in] numSamples number of complex samples in the input vector
  6612. */
  6613. void arm_cmplx_mag_f32(
  6614. const float32_t * pSrc,
  6615. float32_t * pDst,
  6616. uint32_t numSamples);
  6617. /**
  6618. * @brief Q31 complex magnitude
  6619. * @param[in] pSrc points to the complex input vector
  6620. * @param[out] pDst points to the real output vector
  6621. * @param[in] numSamples number of complex samples in the input vector
  6622. */
  6623. void arm_cmplx_mag_q31(
  6624. const q31_t * pSrc,
  6625. q31_t * pDst,
  6626. uint32_t numSamples);
  6627. /**
  6628. * @brief Q15 complex magnitude
  6629. * @param[in] pSrc points to the complex input vector
  6630. * @param[out] pDst points to the real output vector
  6631. * @param[in] numSamples number of complex samples in the input vector
  6632. */
  6633. void arm_cmplx_mag_q15(
  6634. const q15_t * pSrc,
  6635. q15_t * pDst,
  6636. uint32_t numSamples);
  6637. /**
  6638. * @brief Q15 complex dot product
  6639. * @param[in] pSrcA points to the first input vector
  6640. * @param[in] pSrcB points to the second input vector
  6641. * @param[in] numSamples number of complex samples in each vector
  6642. * @param[out] realResult real part of the result returned here
  6643. * @param[out] imagResult imaginary part of the result returned here
  6644. */
  6645. void arm_cmplx_dot_prod_q15(
  6646. const q15_t * pSrcA,
  6647. const q15_t * pSrcB,
  6648. uint32_t numSamples,
  6649. q31_t * realResult,
  6650. q31_t * imagResult);
  6651. /**
  6652. * @brief Q31 complex dot product
  6653. * @param[in] pSrcA points to the first input vector
  6654. * @param[in] pSrcB points to the second input vector
  6655. * @param[in] numSamples number of complex samples in each vector
  6656. * @param[out] realResult real part of the result returned here
  6657. * @param[out] imagResult imaginary part of the result returned here
  6658. */
  6659. void arm_cmplx_dot_prod_q31(
  6660. const q31_t * pSrcA,
  6661. const q31_t * pSrcB,
  6662. uint32_t numSamples,
  6663. q63_t * realResult,
  6664. q63_t * imagResult);
  6665. /**
  6666. * @brief Floating-point complex dot product
  6667. * @param[in] pSrcA points to the first input vector
  6668. * @param[in] pSrcB points to the second input vector
  6669. * @param[in] numSamples number of complex samples in each vector
  6670. * @param[out] realResult real part of the result returned here
  6671. * @param[out] imagResult imaginary part of the result returned here
  6672. */
  6673. void arm_cmplx_dot_prod_f32(
  6674. const float32_t * pSrcA,
  6675. const float32_t * pSrcB,
  6676. uint32_t numSamples,
  6677. float32_t * realResult,
  6678. float32_t * imagResult);
  6679. /**
  6680. * @brief Q15 complex-by-real multiplication
  6681. * @param[in] pSrcCmplx points to the complex input vector
  6682. * @param[in] pSrcReal points to the real input vector
  6683. * @param[out] pCmplxDst points to the complex output vector
  6684. * @param[in] numSamples number of samples in each vector
  6685. */
  6686. void arm_cmplx_mult_real_q15(
  6687. const q15_t * pSrcCmplx,
  6688. const q15_t * pSrcReal,
  6689. q15_t * pCmplxDst,
  6690. uint32_t numSamples);
  6691. /**
  6692. * @brief Q31 complex-by-real multiplication
  6693. * @param[in] pSrcCmplx points to the complex input vector
  6694. * @param[in] pSrcReal points to the real input vector
  6695. * @param[out] pCmplxDst points to the complex output vector
  6696. * @param[in] numSamples number of samples in each vector
  6697. */
  6698. void arm_cmplx_mult_real_q31(
  6699. const q31_t * pSrcCmplx,
  6700. const q31_t * pSrcReal,
  6701. q31_t * pCmplxDst,
  6702. uint32_t numSamples);
  6703. /**
  6704. * @brief Floating-point complex-by-real multiplication
  6705. * @param[in] pSrcCmplx points to the complex input vector
  6706. * @param[in] pSrcReal points to the real input vector
  6707. * @param[out] pCmplxDst points to the complex output vector
  6708. * @param[in] numSamples number of samples in each vector
  6709. */
  6710. void arm_cmplx_mult_real_f32(
  6711. const float32_t * pSrcCmplx,
  6712. const float32_t * pSrcReal,
  6713. float32_t * pCmplxDst,
  6714. uint32_t numSamples);
  6715. /**
  6716. * @brief Minimum value of a Q7 vector.
  6717. * @param[in] pSrc is input pointer
  6718. * @param[in] blockSize is the number of samples to process
  6719. * @param[out] result is output pointer
  6720. * @param[in] index is the array index of the minimum value in the input buffer.
  6721. */
  6722. void arm_min_q7(
  6723. const q7_t * pSrc,
  6724. uint32_t blockSize,
  6725. q7_t * result,
  6726. uint32_t * index);
  6727. /**
  6728. * @brief Minimum value of a Q15 vector.
  6729. * @param[in] pSrc is input pointer
  6730. * @param[in] blockSize is the number of samples to process
  6731. * @param[out] pResult is output pointer
  6732. * @param[in] pIndex is the array index of the minimum value in the input buffer.
  6733. */
  6734. void arm_min_q15(
  6735. const q15_t * pSrc,
  6736. uint32_t blockSize,
  6737. q15_t * pResult,
  6738. uint32_t * pIndex);
  6739. /**
  6740. * @brief Minimum value of a Q31 vector.
  6741. * @param[in] pSrc is input pointer
  6742. * @param[in] blockSize is the number of samples to process
  6743. * @param[out] pResult is output pointer
  6744. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  6745. */
  6746. void arm_min_q31(
  6747. const q31_t * pSrc,
  6748. uint32_t blockSize,
  6749. q31_t * pResult,
  6750. uint32_t * pIndex);
  6751. /**
  6752. * @brief Minimum value of a floating-point vector.
  6753. * @param[in] pSrc is input pointer
  6754. * @param[in] blockSize is the number of samples to process
  6755. * @param[out] pResult is output pointer
  6756. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  6757. */
  6758. void arm_min_f32(
  6759. const float32_t * pSrc,
  6760. uint32_t blockSize,
  6761. float32_t * pResult,
  6762. uint32_t * pIndex);
  6763. /**
  6764. * @brief Maximum value of a Q7 vector.
  6765. * @param[in] pSrc points to the input buffer
  6766. * @param[in] blockSize length of the input vector
  6767. * @param[out] pResult maximum value returned here
  6768. * @param[out] pIndex index of maximum value returned here
  6769. */
  6770. void arm_max_q7(
  6771. const q7_t * pSrc,
  6772. uint32_t blockSize,
  6773. q7_t * pResult,
  6774. uint32_t * pIndex);
  6775. /**
  6776. * @brief Maximum value of a Q15 vector.
  6777. * @param[in] pSrc points to the input buffer
  6778. * @param[in] blockSize length of the input vector
  6779. * @param[out] pResult maximum value returned here
  6780. * @param[out] pIndex index of maximum value returned here
  6781. */
  6782. void arm_max_q15(
  6783. const q15_t * pSrc,
  6784. uint32_t blockSize,
  6785. q15_t * pResult,
  6786. uint32_t * pIndex);
  6787. /**
  6788. * @brief Maximum value of a Q31 vector.
  6789. * @param[in] pSrc points to the input buffer
  6790. * @param[in] blockSize length of the input vector
  6791. * @param[out] pResult maximum value returned here
  6792. * @param[out] pIndex index of maximum value returned here
  6793. */
  6794. void arm_max_q31(
  6795. const q31_t * pSrc,
  6796. uint32_t blockSize,
  6797. q31_t * pResult,
  6798. uint32_t * pIndex);
  6799. /**
  6800. * @brief Maximum value of a floating-point vector.
  6801. * @param[in] pSrc points to the input buffer
  6802. * @param[in] blockSize length of the input vector
  6803. * @param[out] pResult maximum value returned here
  6804. * @param[out] pIndex index of maximum value returned here
  6805. */
  6806. void arm_max_f32(
  6807. const float32_t * pSrc,
  6808. uint32_t blockSize,
  6809. float32_t * pResult,
  6810. uint32_t * pIndex);
  6811. /**
  6812. @brief Maximum value of a floating-point vector.
  6813. @param[in] pSrc points to the input vector
  6814. @param[in] blockSize number of samples in input vector
  6815. @param[out] pResult maximum value returned here
  6816. @return none
  6817. */
  6818. void arm_max_no_idx_f32(
  6819. const float32_t *pSrc,
  6820. uint32_t blockSize,
  6821. float32_t *pResult);
  6822. /**
  6823. * @brief Q15 complex-by-complex multiplication
  6824. * @param[in] pSrcA points to the first input vector
  6825. * @param[in] pSrcB points to the second input vector
  6826. * @param[out] pDst points to the output vector
  6827. * @param[in] numSamples number of complex samples in each vector
  6828. */
  6829. void arm_cmplx_mult_cmplx_q15(
  6830. const q15_t * pSrcA,
  6831. const q15_t * pSrcB,
  6832. q15_t * pDst,
  6833. uint32_t numSamples);
  6834. /**
  6835. * @brief Q31 complex-by-complex multiplication
  6836. * @param[in] pSrcA points to the first input vector
  6837. * @param[in] pSrcB points to the second input vector
  6838. * @param[out] pDst points to the output vector
  6839. * @param[in] numSamples number of complex samples in each vector
  6840. */
  6841. void arm_cmplx_mult_cmplx_q31(
  6842. const q31_t * pSrcA,
  6843. const q31_t * pSrcB,
  6844. q31_t * pDst,
  6845. uint32_t numSamples);
  6846. /**
  6847. * @brief Floating-point complex-by-complex multiplication
  6848. * @param[in] pSrcA points to the first input vector
  6849. * @param[in] pSrcB points to the second input vector
  6850. * @param[out] pDst points to the output vector
  6851. * @param[in] numSamples number of complex samples in each vector
  6852. */
  6853. void arm_cmplx_mult_cmplx_f32(
  6854. const float32_t * pSrcA,
  6855. const float32_t * pSrcB,
  6856. float32_t * pDst,
  6857. uint32_t numSamples);
  6858. /**
  6859. * @brief Converts the elements of the floating-point vector to Q31 vector.
  6860. * @param[in] pSrc points to the floating-point input vector
  6861. * @param[out] pDst points to the Q31 output vector
  6862. * @param[in] blockSize length of the input vector
  6863. */
  6864. void arm_float_to_q31(
  6865. const float32_t * pSrc,
  6866. q31_t * pDst,
  6867. uint32_t blockSize);
  6868. /**
  6869. * @brief Converts the elements of the floating-point vector to Q15 vector.
  6870. * @param[in] pSrc points to the floating-point input vector
  6871. * @param[out] pDst points to the Q15 output vector
  6872. * @param[in] blockSize length of the input vector
  6873. */
  6874. void arm_float_to_q15(
  6875. const float32_t * pSrc,
  6876. q15_t * pDst,
  6877. uint32_t blockSize);
  6878. /**
  6879. * @brief Converts the elements of the floating-point vector to Q7 vector.
  6880. * @param[in] pSrc points to the floating-point input vector
  6881. * @param[out] pDst points to the Q7 output vector
  6882. * @param[in] blockSize length of the input vector
  6883. */
  6884. void arm_float_to_q7(
  6885. const float32_t * pSrc,
  6886. q7_t * pDst,
  6887. uint32_t blockSize);
  6888. /**
  6889. * @brief Converts the elements of the Q31 vector to floating-point vector.
  6890. * @param[in] pSrc is input pointer
  6891. * @param[out] pDst is output pointer
  6892. * @param[in] blockSize is the number of samples to process
  6893. */
  6894. void arm_q31_to_float(
  6895. const q31_t * pSrc,
  6896. float32_t * pDst,
  6897. uint32_t blockSize);
  6898. /**
  6899. * @brief Converts the elements of the Q31 vector to Q15 vector.
  6900. * @param[in] pSrc is input pointer
  6901. * @param[out] pDst is output pointer
  6902. * @param[in] blockSize is the number of samples to process
  6903. */
  6904. void arm_q31_to_q15(
  6905. const q31_t * pSrc,
  6906. q15_t * pDst,
  6907. uint32_t blockSize);
  6908. /**
  6909. * @brief Converts the elements of the Q31 vector to Q7 vector.
  6910. * @param[in] pSrc is input pointer
  6911. * @param[out] pDst is output pointer
  6912. * @param[in] blockSize is the number of samples to process
  6913. */
  6914. void arm_q31_to_q7(
  6915. const q31_t * pSrc,
  6916. q7_t * pDst,
  6917. uint32_t blockSize);
  6918. /**
  6919. * @brief Converts the elements of the Q15 vector to floating-point vector.
  6920. * @param[in] pSrc is input pointer
  6921. * @param[out] pDst is output pointer
  6922. * @param[in] blockSize is the number of samples to process
  6923. */
  6924. void arm_q15_to_float(
  6925. const q15_t * pSrc,
  6926. float32_t * pDst,
  6927. uint32_t blockSize);
  6928. /**
  6929. * @brief Converts the elements of the Q15 vector to Q31 vector.
  6930. * @param[in] pSrc is input pointer
  6931. * @param[out] pDst is output pointer
  6932. * @param[in] blockSize is the number of samples to process
  6933. */
  6934. void arm_q15_to_q31(
  6935. const q15_t * pSrc,
  6936. q31_t * pDst,
  6937. uint32_t blockSize);
  6938. /**
  6939. * @brief Converts the elements of the Q15 vector to Q7 vector.
  6940. * @param[in] pSrc is input pointer
  6941. * @param[out] pDst is output pointer
  6942. * @param[in] blockSize is the number of samples to process
  6943. */
  6944. void arm_q15_to_q7(
  6945. const q15_t * pSrc,
  6946. q7_t * pDst,
  6947. uint32_t blockSize);
  6948. /**
  6949. * @brief Converts the elements of the Q7 vector to floating-point vector.
  6950. * @param[in] pSrc is input pointer
  6951. * @param[out] pDst is output pointer
  6952. * @param[in] blockSize is the number of samples to process
  6953. */
  6954. void arm_q7_to_float(
  6955. const q7_t * pSrc,
  6956. float32_t * pDst,
  6957. uint32_t blockSize);
  6958. /**
  6959. * @brief Converts the elements of the Q7 vector to Q31 vector.
  6960. * @param[in] pSrc input pointer
  6961. * @param[out] pDst output pointer
  6962. * @param[in] blockSize number of samples to process
  6963. */
  6964. void arm_q7_to_q31(
  6965. const q7_t * pSrc,
  6966. q31_t * pDst,
  6967. uint32_t blockSize);
  6968. /**
  6969. * @brief Converts the elements of the Q7 vector to Q15 vector.
  6970. * @param[in] pSrc input pointer
  6971. * @param[out] pDst output pointer
  6972. * @param[in] blockSize number of samples to process
  6973. */
  6974. void arm_q7_to_q15(
  6975. const q7_t * pSrc,
  6976. q15_t * pDst,
  6977. uint32_t blockSize);
  6978. /**
  6979. * @brief Struct for specifying SVM Kernel
  6980. */
  6981. typedef enum
  6982. {
  6983. ARM_ML_KERNEL_LINEAR = 0,
  6984. /**< Linear kernel */
  6985. ARM_ML_KERNEL_POLYNOMIAL = 1,
  6986. /**< Polynomial kernel */
  6987. ARM_ML_KERNEL_RBF = 2,
  6988. /**< Radial Basis Function kernel */
  6989. ARM_ML_KERNEL_SIGMOID = 3
  6990. /**< Sigmoid kernel */
  6991. } arm_ml_kernel_type;
  6992. /**
  6993. * @brief Instance structure for linear SVM prediction function.
  6994. */
  6995. typedef struct
  6996. {
  6997. uint32_t nbOfSupportVectors; /**< Number of support vectors */
  6998. uint32_t vectorDimension; /**< Dimension of vector space */
  6999. float32_t intercept; /**< Intercept */
  7000. const float32_t *dualCoefficients; /**< Dual coefficients */
  7001. const float32_t *supportVectors; /**< Support vectors */
  7002. const int32_t *classes; /**< The two SVM classes */
  7003. } arm_svm_linear_instance_f32;
  7004. /**
  7005. * @brief Instance structure for polynomial SVM prediction function.
  7006. */
  7007. typedef struct
  7008. {
  7009. uint32_t nbOfSupportVectors; /**< Number of support vectors */
  7010. uint32_t vectorDimension; /**< Dimension of vector space */
  7011. float32_t intercept; /**< Intercept */
  7012. const float32_t *dualCoefficients; /**< Dual coefficients */
  7013. const float32_t *supportVectors; /**< Support vectors */
  7014. const int32_t *classes; /**< The two SVM classes */
  7015. int32_t degree; /**< Polynomial degree */
  7016. float32_t coef0; /**< Polynomial constant */
  7017. float32_t gamma; /**< Gamma factor */
  7018. } arm_svm_polynomial_instance_f32;
  7019. /**
  7020. * @brief Instance structure for rbf SVM prediction function.
  7021. */
  7022. typedef struct
  7023. {
  7024. uint32_t nbOfSupportVectors; /**< Number of support vectors */
  7025. uint32_t vectorDimension; /**< Dimension of vector space */
  7026. float32_t intercept; /**< Intercept */
  7027. const float32_t *dualCoefficients; /**< Dual coefficients */
  7028. const float32_t *supportVectors; /**< Support vectors */
  7029. const int32_t *classes; /**< The two SVM classes */
  7030. float32_t gamma; /**< Gamma factor */
  7031. } arm_svm_rbf_instance_f32;
  7032. /**
  7033. * @brief Instance structure for sigmoid SVM prediction function.
  7034. */
  7035. typedef struct
  7036. {
  7037. uint32_t nbOfSupportVectors; /**< Number of support vectors */
  7038. uint32_t vectorDimension; /**< Dimension of vector space */
  7039. float32_t intercept; /**< Intercept */
  7040. const float32_t *dualCoefficients; /**< Dual coefficients */
  7041. const float32_t *supportVectors; /**< Support vectors */
  7042. const int32_t *classes; /**< The two SVM classes */
  7043. float32_t coef0; /**< Independant constant */
  7044. float32_t gamma; /**< Gamma factor */
  7045. } arm_svm_sigmoid_instance_f32;
  7046. /**
  7047. * @brief SVM linear instance init function
  7048. * @param[in] S Parameters for SVM functions
  7049. * @param[in] nbOfSupportVectors Number of support vectors
  7050. * @param[in] vectorDimension Dimension of vector space
  7051. * @param[in] intercept Intercept
  7052. * @param[in] dualCoefficients Array of dual coefficients
  7053. * @param[in] supportVectors Array of support vectors
  7054. * @param[in] classes Array of 2 classes ID
  7055. * @return none.
  7056. *
  7057. */
  7058. void arm_svm_linear_init_f32(arm_svm_linear_instance_f32 *S,
  7059. uint32_t nbOfSupportVectors,
  7060. uint32_t vectorDimension,
  7061. float32_t intercept,
  7062. const float32_t *dualCoefficients,
  7063. const float32_t *supportVectors,
  7064. const int32_t *classes);
  7065. /**
  7066. * @brief SVM linear prediction
  7067. * @param[in] S Pointer to an instance of the linear SVM structure.
  7068. * @param[in] in Pointer to input vector
  7069. * @param[out] pResult Decision value
  7070. * @return none.
  7071. *
  7072. */
  7073. void arm_svm_linear_predict_f32(const arm_svm_linear_instance_f32 *S,
  7074. const float32_t * in,
  7075. int32_t * pResult);
  7076. /**
  7077. * @brief SVM polynomial instance init function
  7078. * @param[in] S points to an instance of the polynomial SVM structure.
  7079. * @param[in] nbOfSupportVectors Number of support vectors
  7080. * @param[in] vectorDimension Dimension of vector space
  7081. * @param[in] intercept Intercept
  7082. * @param[in] dualCoefficients Array of dual coefficients
  7083. * @param[in] supportVectors Array of support vectors
  7084. * @param[in] classes Array of 2 classes ID
  7085. * @param[in] degree Polynomial degree
  7086. * @param[in] coef0 coeff0 (scikit-learn terminology)
  7087. * @param[in] gamma gamma (scikit-learn terminology)
  7088. * @return none.
  7089. *
  7090. */
  7091. void arm_svm_polynomial_init_f32(arm_svm_polynomial_instance_f32 *S,
  7092. uint32_t nbOfSupportVectors,
  7093. uint32_t vectorDimension,
  7094. float32_t intercept,
  7095. const float32_t *dualCoefficients,
  7096. const float32_t *supportVectors,
  7097. const int32_t *classes,
  7098. int32_t degree,
  7099. float32_t coef0,
  7100. float32_t gamma
  7101. );
  7102. /**
  7103. * @brief SVM polynomial prediction
  7104. * @param[in] S Pointer to an instance of the polynomial SVM structure.
  7105. * @param[in] in Pointer to input vector
  7106. * @param[out] pResult Decision value
  7107. * @return none.
  7108. *
  7109. */
  7110. void arm_svm_polynomial_predict_f32(const arm_svm_polynomial_instance_f32 *S,
  7111. const float32_t * in,
  7112. int32_t * pResult);
  7113. /**
  7114. * @brief SVM radial basis function instance init function
  7115. * @param[in] S points to an instance of the polynomial SVM structure.
  7116. * @param[in] nbOfSupportVectors Number of support vectors
  7117. * @param[in] vectorDimension Dimension of vector space
  7118. * @param[in] intercept Intercept
  7119. * @param[in] dualCoefficients Array of dual coefficients
  7120. * @param[in] supportVectors Array of support vectors
  7121. * @param[in] classes Array of 2 classes ID
  7122. * @param[in] gamma gamma (scikit-learn terminology)
  7123. * @return none.
  7124. *
  7125. */
  7126. void arm_svm_rbf_init_f32(arm_svm_rbf_instance_f32 *S,
  7127. uint32_t nbOfSupportVectors,
  7128. uint32_t vectorDimension,
  7129. float32_t intercept,
  7130. const float32_t *dualCoefficients,
  7131. const float32_t *supportVectors,
  7132. const int32_t *classes,
  7133. float32_t gamma
  7134. );
  7135. /**
  7136. * @brief SVM rbf prediction
  7137. * @param[in] S Pointer to an instance of the rbf SVM structure.
  7138. * @param[in] in Pointer to input vector
  7139. * @param[out] pResult decision value
  7140. * @return none.
  7141. *
  7142. */
  7143. void arm_svm_rbf_predict_f32(const arm_svm_rbf_instance_f32 *S,
  7144. const float32_t * in,
  7145. int32_t * pResult);
  7146. /**
  7147. * @brief SVM sigmoid instance init function
  7148. * @param[in] S points to an instance of the rbf SVM structure.
  7149. * @param[in] nbOfSupportVectors Number of support vectors
  7150. * @param[in] vectorDimension Dimension of vector space
  7151. * @param[in] intercept Intercept
  7152. * @param[in] dualCoefficients Array of dual coefficients
  7153. * @param[in] supportVectors Array of support vectors
  7154. * @param[in] classes Array of 2 classes ID
  7155. * @param[in] coef0 coeff0 (scikit-learn terminology)
  7156. * @param[in] gamma gamma (scikit-learn terminology)
  7157. * @return none.
  7158. *
  7159. */
  7160. void arm_svm_sigmoid_init_f32(arm_svm_sigmoid_instance_f32 *S,
  7161. uint32_t nbOfSupportVectors,
  7162. uint32_t vectorDimension,
  7163. float32_t intercept,
  7164. const float32_t *dualCoefficients,
  7165. const float32_t *supportVectors,
  7166. const int32_t *classes,
  7167. float32_t coef0,
  7168. float32_t gamma
  7169. );
  7170. /**
  7171. * @brief SVM sigmoid prediction
  7172. * @param[in] S Pointer to an instance of the rbf SVM structure.
  7173. * @param[in] in Pointer to input vector
  7174. * @param[out] pResult Decision value
  7175. * @return none.
  7176. *
  7177. */
  7178. void arm_svm_sigmoid_predict_f32(const arm_svm_sigmoid_instance_f32 *S,
  7179. const float32_t * in,
  7180. int32_t * pResult);
  7181. /**
  7182. * @brief Instance structure for Naive Gaussian Bayesian estimator.
  7183. */
  7184. typedef struct
  7185. {
  7186. uint32_t vectorDimension; /**< Dimension of vector space */
  7187. uint32_t numberOfClasses; /**< Number of different classes */
  7188. const float32_t *theta; /**< Mean values for the Gaussians */
  7189. const float32_t *sigma; /**< Variances for the Gaussians */
  7190. const float32_t *classPriors; /**< Class prior probabilities */
  7191. float32_t epsilon; /**< Additive value to variances */
  7192. } arm_gaussian_naive_bayes_instance_f32;
  7193. /**
  7194. * @brief Naive Gaussian Bayesian Estimator
  7195. *
  7196. * @param[in] S points to a naive bayes instance structure
  7197. * @param[in] in points to the elements of the input vector.
  7198. * @param[in] pBuffer points to a buffer of length numberOfClasses
  7199. * @return The predicted class
  7200. *
  7201. */
  7202. uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S,
  7203. const float32_t * in,
  7204. float32_t *pBuffer);
  7205. /**
  7206. * @brief Computation of the LogSumExp
  7207. *
  7208. * In probabilistic computations, the dynamic of the probability values can be very
  7209. * wide because they come from gaussian functions.
  7210. * To avoid underflow and overflow issues, the values are represented by their log.
  7211. * In this representation, multiplying the original exp values is easy : their logs are added.
  7212. * But adding the original exp values is requiring some special handling and it is the
  7213. * goal of the LogSumExp function.
  7214. *
  7215. * If the values are x1...xn, the function is computing:
  7216. *
  7217. * ln(exp(x1) + ... + exp(xn)) and the computation is done in such a way that
  7218. * rounding issues are minimised.
  7219. *
  7220. * The max xm of the values is extracted and the function is computing:
  7221. * xm + ln(exp(x1 - xm) + ... + exp(xn - xm))
  7222. *
  7223. * @param[in] *in Pointer to an array of input values.
  7224. * @param[in] blockSize Number of samples in the input array.
  7225. * @return LogSumExp
  7226. *
  7227. */
  7228. float32_t arm_logsumexp_f32(const float32_t *in, uint32_t blockSize);
  7229. /**
  7230. * @brief Dot product with log arithmetic
  7231. *
  7232. * Vectors are containing the log of the samples
  7233. *
  7234. * @param[in] pSrcA points to the first input vector
  7235. * @param[in] pSrcB points to the second input vector
  7236. * @param[in] blockSize number of samples in each vector
  7237. * @param[in] pTmpBuffer temporary buffer of length blockSize
  7238. * @return The log of the dot product .
  7239. *
  7240. */
  7241. float32_t arm_logsumexp_dot_prod_f32(const float32_t * pSrcA,
  7242. const float32_t * pSrcB,
  7243. uint32_t blockSize,
  7244. float32_t *pTmpBuffer);
  7245. /**
  7246. * @brief Entropy
  7247. *
  7248. * @param[in] pSrcA Array of input values.
  7249. * @param[in] blockSize Number of samples in the input array.
  7250. * @return Entropy -Sum(p ln p)
  7251. *
  7252. */
  7253. float32_t arm_entropy_f32(const float32_t * pSrcA,uint32_t blockSize);
  7254. /**
  7255. * @brief Entropy
  7256. *
  7257. * @param[in] pSrcA Array of input values.
  7258. * @param[in] blockSize Number of samples in the input array.
  7259. * @return Entropy -Sum(p ln p)
  7260. *
  7261. */
  7262. float64_t arm_entropy_f64(const float64_t * pSrcA, uint32_t blockSize);
  7263. /**
  7264. * @brief Kullback-Leibler
  7265. *
  7266. * @param[in] pSrcA Pointer to an array of input values for probability distribution A.
  7267. * @param[in] pSrcB Pointer to an array of input values for probability distribution B.
  7268. * @param[in] blockSize Number of samples in the input array.
  7269. * @return Kullback-Leibler Divergence D(A || B)
  7270. *
  7271. */
  7272. float32_t arm_kullback_leibler_f32(const float32_t * pSrcA
  7273. ,const float32_t * pSrcB
  7274. ,uint32_t blockSize);
  7275. /**
  7276. * @brief Kullback-Leibler
  7277. *
  7278. * @param[in] pSrcA Pointer to an array of input values for probability distribution A.
  7279. * @param[in] pSrcB Pointer to an array of input values for probability distribution B.
  7280. * @param[in] blockSize Number of samples in the input array.
  7281. * @return Kullback-Leibler Divergence D(A || B)
  7282. *
  7283. */
  7284. float64_t arm_kullback_leibler_f64(const float64_t * pSrcA,
  7285. const float64_t * pSrcB,
  7286. uint32_t blockSize);
  7287. /**
  7288. * @brief Weighted sum
  7289. *
  7290. *
  7291. * @param[in] *in Array of input values.
  7292. * @param[in] *weigths Weights
  7293. * @param[in] blockSize Number of samples in the input array.
  7294. * @return Weighted sum
  7295. *
  7296. */
  7297. float32_t arm_weighted_sum_f32(const float32_t *in
  7298. , const float32_t *weigths
  7299. , uint32_t blockSize);
  7300. /**
  7301. * @brief Barycenter
  7302. *
  7303. *
  7304. * @param[in] in List of vectors
  7305. * @param[in] weights Weights of the vectors
  7306. * @param[out] out Barycenter
  7307. * @param[in] nbVectors Number of vectors
  7308. * @param[in] vecDim Dimension of space (vector dimension)
  7309. * @return None
  7310. *
  7311. */
  7312. void arm_barycenter_f32(const float32_t *in
  7313. , const float32_t *weights
  7314. , float32_t *out
  7315. , uint32_t nbVectors
  7316. , uint32_t vecDim);
  7317. /**
  7318. * @brief Euclidean distance between two vectors
  7319. * @param[in] pA First vector
  7320. * @param[in] pB Second vector
  7321. * @param[in] blockSize vector length
  7322. * @return distance
  7323. *
  7324. */
  7325. float32_t arm_euclidean_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize);
  7326. /**
  7327. * @brief Bray-Curtis distance between two vectors
  7328. * @param[in] pA First vector
  7329. * @param[in] pB Second vector
  7330. * @param[in] blockSize vector length
  7331. * @return distance
  7332. *
  7333. */
  7334. float32_t arm_braycurtis_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize);
  7335. /**
  7336. * @brief Canberra distance between two vectors
  7337. *
  7338. * This function may divide by zero when samples pA[i] and pB[i] are both zero.
  7339. * The result of the computation will be correct. So the division per zero may be
  7340. * ignored.
  7341. *
  7342. * @param[in] pA First vector
  7343. * @param[in] pB Second vector
  7344. * @param[in] blockSize vector length
  7345. * @return distance
  7346. *
  7347. */
  7348. float32_t arm_canberra_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize);
  7349. /**
  7350. * @brief Chebyshev distance between two vectors
  7351. * @param[in] pA First vector
  7352. * @param[in] pB Second vector
  7353. * @param[in] blockSize vector length
  7354. * @return distance
  7355. *
  7356. */
  7357. float32_t arm_chebyshev_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize);
  7358. /**
  7359. * @brief Cityblock (Manhattan) distance between two vectors
  7360. * @param[in] pA First vector
  7361. * @param[in] pB Second vector
  7362. * @param[in] blockSize vector length
  7363. * @return distance
  7364. *
  7365. */
  7366. float32_t arm_cityblock_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize);
  7367. /**
  7368. * @brief Correlation distance between two vectors
  7369. *
  7370. * The input vectors are modified in place !
  7371. *
  7372. * @param[in] pA First vector
  7373. * @param[in] pB Second vector
  7374. * @param[in] blockSize vector length
  7375. * @return distance
  7376. *
  7377. */
  7378. float32_t arm_correlation_distance_f32(float32_t *pA,float32_t *pB, uint32_t blockSize);
  7379. /**
  7380. * @brief Cosine distance between two vectors
  7381. *
  7382. * @param[in] pA First vector
  7383. * @param[in] pB Second vector
  7384. * @param[in] blockSize vector length
  7385. * @return distance
  7386. *
  7387. */
  7388. float32_t arm_cosine_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize);
  7389. /**
  7390. * @brief Jensen-Shannon distance between two vectors
  7391. *
  7392. * This function is assuming that elements of second vector are > 0
  7393. * and 0 only when the corresponding element of first vector is 0.
  7394. * Otherwise the result of the computation does not make sense
  7395. * and for speed reasons, the cases returning NaN or Infinity are not
  7396. * managed.
  7397. *
  7398. * When the function is computing x log (x / y) with x 0 and y 0,
  7399. * it will compute the right value (0) but a division per zero will occur
  7400. * and shoudl be ignored in client code.
  7401. *
  7402. * @param[in] pA First vector
  7403. * @param[in] pB Second vector
  7404. * @param[in] blockSize vector length
  7405. * @return distance
  7406. *
  7407. */
  7408. float32_t arm_jensenshannon_distance_f32(const float32_t *pA,const float32_t *pB,uint32_t blockSize);
  7409. /**
  7410. * @brief Minkowski distance between two vectors
  7411. *
  7412. * @param[in] pA First vector
  7413. * @param[in] pB Second vector
  7414. * @param[in] n Norm order (>= 2)
  7415. * @param[in] blockSize vector length
  7416. * @return distance
  7417. *
  7418. */
  7419. float32_t arm_minkowski_distance_f32(const float32_t *pA,const float32_t *pB, int32_t order, uint32_t blockSize);
  7420. /**
  7421. * @brief Dice distance between two vectors
  7422. *
  7423. * @param[in] pA First vector of packed booleans
  7424. * @param[in] pB Second vector of packed booleans
  7425. * @param[in] order Distance order
  7426. * @param[in] blockSize Number of samples
  7427. * @return distance
  7428. *
  7429. */
  7430. float32_t arm_dice_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7431. /**
  7432. * @brief Hamming distance between two vectors
  7433. *
  7434. * @param[in] pA First vector of packed booleans
  7435. * @param[in] pB Second vector of packed booleans
  7436. * @param[in] numberOfBools Number of booleans
  7437. * @return distance
  7438. *
  7439. */
  7440. float32_t arm_hamming_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7441. /**
  7442. * @brief Jaccard distance between two vectors
  7443. *
  7444. * @param[in] pA First vector of packed booleans
  7445. * @param[in] pB Second vector of packed booleans
  7446. * @param[in] numberOfBools Number of booleans
  7447. * @return distance
  7448. *
  7449. */
  7450. float32_t arm_jaccard_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7451. /**
  7452. * @brief Kulsinski distance between two vectors
  7453. *
  7454. * @param[in] pA First vector of packed booleans
  7455. * @param[in] pB Second vector of packed booleans
  7456. * @param[in] numberOfBools Number of booleans
  7457. * @return distance
  7458. *
  7459. */
  7460. float32_t arm_kulsinski_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7461. /**
  7462. * @brief Roger Stanimoto distance between two vectors
  7463. *
  7464. * @param[in] pA First vector of packed booleans
  7465. * @param[in] pB Second vector of packed booleans
  7466. * @param[in] numberOfBools Number of booleans
  7467. * @return distance
  7468. *
  7469. */
  7470. float32_t arm_rogerstanimoto_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7471. /**
  7472. * @brief Russell-Rao distance between two vectors
  7473. *
  7474. * @param[in] pA First vector of packed booleans
  7475. * @param[in] pB Second vector of packed booleans
  7476. * @param[in] numberOfBools Number of booleans
  7477. * @return distance
  7478. *
  7479. */
  7480. float32_t arm_russellrao_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7481. /**
  7482. * @brief Sokal-Michener distance between two vectors
  7483. *
  7484. * @param[in] pA First vector of packed booleans
  7485. * @param[in] pB Second vector of packed booleans
  7486. * @param[in] numberOfBools Number of booleans
  7487. * @return distance
  7488. *
  7489. */
  7490. float32_t arm_sokalmichener_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7491. /**
  7492. * @brief Sokal-Sneath distance between two vectors
  7493. *
  7494. * @param[in] pA First vector of packed booleans
  7495. * @param[in] pB Second vector of packed booleans
  7496. * @param[in] numberOfBools Number of booleans
  7497. * @return distance
  7498. *
  7499. */
  7500. float32_t arm_sokalsneath_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7501. /**
  7502. * @brief Yule distance between two vectors
  7503. *
  7504. * @param[in] pA First vector of packed booleans
  7505. * @param[in] pB Second vector of packed booleans
  7506. * @param[in] numberOfBools Number of booleans
  7507. * @return distance
  7508. *
  7509. */
  7510. float32_t arm_yule_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools);
  7511. /**
  7512. * @ingroup groupInterpolation
  7513. */
  7514. /**
  7515. * @defgroup BilinearInterpolate Bilinear Interpolation
  7516. *
  7517. * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
  7518. * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
  7519. * determines values between the grid points.
  7520. * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
  7521. * Bilinear interpolation is often used in image processing to rescale images.
  7522. * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
  7523. *
  7524. * <b>Algorithm</b>
  7525. * \par
  7526. * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
  7527. * For floating-point, the instance structure is defined as:
  7528. * <pre>
  7529. * typedef struct
  7530. * {
  7531. * uint16_t numRows;
  7532. * uint16_t numCols;
  7533. * float32_t *pData;
  7534. * } arm_bilinear_interp_instance_f32;
  7535. * </pre>
  7536. *
  7537. * \par
  7538. * where <code>numRows</code> specifies the number of rows in the table;
  7539. * <code>numCols</code> specifies the number of columns in the table;
  7540. * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
  7541. * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
  7542. * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
  7543. *
  7544. * \par
  7545. * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
  7546. * <pre>
  7547. * XF = floor(x)
  7548. * YF = floor(y)
  7549. * </pre>
  7550. * \par
  7551. * The interpolated output point is computed as:
  7552. * <pre>
  7553. * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
  7554. * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
  7555. * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
  7556. * + f(XF+1, YF+1) * (x-XF)*(y-YF)
  7557. * </pre>
  7558. * Note that the coordinates (x, y) contain integer and fractional components.
  7559. * The integer components specify which portion of the table to use while the
  7560. * fractional components control the interpolation processor.
  7561. *
  7562. * \par
  7563. * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
  7564. */
  7565. /**
  7566. * @addtogroup BilinearInterpolate
  7567. * @{
  7568. */
  7569. /**
  7570. * @brief Floating-point bilinear interpolation.
  7571. * @param[in,out] S points to an instance of the interpolation structure.
  7572. * @param[in] X interpolation coordinate.
  7573. * @param[in] Y interpolation coordinate.
  7574. * @return out interpolated value.
  7575. */
  7576. __STATIC_FORCEINLINE float32_t arm_bilinear_interp_f32(
  7577. const arm_bilinear_interp_instance_f32 * S,
  7578. float32_t X,
  7579. float32_t Y)
  7580. {
  7581. float32_t out;
  7582. float32_t f00, f01, f10, f11;
  7583. float32_t *pData = S->pData;
  7584. int32_t xIndex, yIndex, index;
  7585. float32_t xdiff, ydiff;
  7586. float32_t b1, b2, b3, b4;
  7587. xIndex = (int32_t) X;
  7588. yIndex = (int32_t) Y;
  7589. /* Care taken for table outside boundary */
  7590. /* Returns zero output when values are outside table boundary */
  7591. if (xIndex < 0 || xIndex > (S->numCols - 2) || yIndex < 0 || yIndex > (S->numRows - 2))
  7592. {
  7593. return (0);
  7594. }
  7595. /* Calculation of index for two nearest points in X-direction */
  7596. index = (xIndex ) + (yIndex ) * S->numCols;
  7597. /* Read two nearest points in X-direction */
  7598. f00 = pData[index];
  7599. f01 = pData[index + 1];
  7600. /* Calculation of index for two nearest points in Y-direction */
  7601. index = (xIndex ) + (yIndex+1) * S->numCols;
  7602. /* Read two nearest points in Y-direction */
  7603. f10 = pData[index];
  7604. f11 = pData[index + 1];
  7605. /* Calculation of intermediate values */
  7606. b1 = f00;
  7607. b2 = f01 - f00;
  7608. b3 = f10 - f00;
  7609. b4 = f00 - f01 - f10 + f11;
  7610. /* Calculation of fractional part in X */
  7611. xdiff = X - xIndex;
  7612. /* Calculation of fractional part in Y */
  7613. ydiff = Y - yIndex;
  7614. /* Calculation of bi-linear interpolated output */
  7615. out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
  7616. /* return to application */
  7617. return (out);
  7618. }
  7619. /**
  7620. * @brief Q31 bilinear interpolation.
  7621. * @param[in,out] S points to an instance of the interpolation structure.
  7622. * @param[in] X interpolation coordinate in 12.20 format.
  7623. * @param[in] Y interpolation coordinate in 12.20 format.
  7624. * @return out interpolated value.
  7625. */
  7626. __STATIC_FORCEINLINE q31_t arm_bilinear_interp_q31(
  7627. arm_bilinear_interp_instance_q31 * S,
  7628. q31_t X,
  7629. q31_t Y)
  7630. {
  7631. q31_t out; /* Temporary output */
  7632. q31_t acc = 0; /* output */
  7633. q31_t xfract, yfract; /* X, Y fractional parts */
  7634. q31_t x1, x2, y1, y2; /* Nearest output values */
  7635. int32_t rI, cI; /* Row and column indices */
  7636. q31_t *pYData = S->pData; /* pointer to output table values */
  7637. uint32_t nCols = S->numCols; /* num of rows */
  7638. /* Input is in 12.20 format */
  7639. /* 12 bits for the table index */
  7640. /* Index value calculation */
  7641. rI = ((X & (q31_t)0xFFF00000) >> 20);
  7642. /* Input is in 12.20 format */
  7643. /* 12 bits for the table index */
  7644. /* Index value calculation */
  7645. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  7646. /* Care taken for table outside boundary */
  7647. /* Returns zero output when values are outside table boundary */
  7648. if (rI < 0 || rI > (S->numCols - 2) || cI < 0 || cI > (S->numRows - 2))
  7649. {
  7650. return (0);
  7651. }
  7652. /* 20 bits for the fractional part */
  7653. /* shift left xfract by 11 to keep 1.31 format */
  7654. xfract = (X & 0x000FFFFF) << 11U;
  7655. /* Read two nearest output values from the index */
  7656. x1 = pYData[(rI) + (int32_t)nCols * (cI) ];
  7657. x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1];
  7658. /* 20 bits for the fractional part */
  7659. /* shift left yfract by 11 to keep 1.31 format */
  7660. yfract = (Y & 0x000FFFFF) << 11U;
  7661. /* Read two nearest output values from the index */
  7662. y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ];
  7663. y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1];
  7664. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
  7665. out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
  7666. acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
  7667. /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
  7668. out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
  7669. acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
  7670. /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
  7671. out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
  7672. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  7673. /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
  7674. out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
  7675. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  7676. /* Convert acc to 1.31(q31) format */
  7677. return ((q31_t)(acc << 2));
  7678. }
  7679. /**
  7680. * @brief Q15 bilinear interpolation.
  7681. * @param[in,out] S points to an instance of the interpolation structure.
  7682. * @param[in] X interpolation coordinate in 12.20 format.
  7683. * @param[in] Y interpolation coordinate in 12.20 format.
  7684. * @return out interpolated value.
  7685. */
  7686. __STATIC_FORCEINLINE q15_t arm_bilinear_interp_q15(
  7687. arm_bilinear_interp_instance_q15 * S,
  7688. q31_t X,
  7689. q31_t Y)
  7690. {
  7691. q63_t acc = 0; /* output */
  7692. q31_t out; /* Temporary output */
  7693. q15_t x1, x2, y1, y2; /* Nearest output values */
  7694. q31_t xfract, yfract; /* X, Y fractional parts */
  7695. int32_t rI, cI; /* Row and column indices */
  7696. q15_t *pYData = S->pData; /* pointer to output table values */
  7697. uint32_t nCols = S->numCols; /* num of rows */
  7698. /* Input is in 12.20 format */
  7699. /* 12 bits for the table index */
  7700. /* Index value calculation */
  7701. rI = ((X & (q31_t)0xFFF00000) >> 20);
  7702. /* Input is in 12.20 format */
  7703. /* 12 bits for the table index */
  7704. /* Index value calculation */
  7705. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  7706. /* Care taken for table outside boundary */
  7707. /* Returns zero output when values are outside table boundary */
  7708. if (rI < 0 || rI > (S->numCols - 2) || cI < 0 || cI > (S->numRows - 2))
  7709. {
  7710. return (0);
  7711. }
  7712. /* 20 bits for the fractional part */
  7713. /* xfract should be in 12.20 format */
  7714. xfract = (X & 0x000FFFFF);
  7715. /* Read two nearest output values from the index */
  7716. x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
  7717. x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
  7718. /* 20 bits for the fractional part */
  7719. /* yfract should be in 12.20 format */
  7720. yfract = (Y & 0x000FFFFF);
  7721. /* Read two nearest output values from the index */
  7722. y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
  7723. y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
  7724. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
  7725. /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
  7726. /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
  7727. out = (q31_t) (((q63_t) x1 * (0x0FFFFF - xfract)) >> 4U);
  7728. acc = ((q63_t) out * (0x0FFFFF - yfract));
  7729. /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
  7730. out = (q31_t) (((q63_t) x2 * (0x0FFFFF - yfract)) >> 4U);
  7731. acc += ((q63_t) out * (xfract));
  7732. /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
  7733. out = (q31_t) (((q63_t) y1 * (0x0FFFFF - xfract)) >> 4U);
  7734. acc += ((q63_t) out * (yfract));
  7735. /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
  7736. out = (q31_t) (((q63_t) y2 * (xfract)) >> 4U);
  7737. acc += ((q63_t) out * (yfract));
  7738. /* acc is in 13.51 format and down shift acc by 36 times */
  7739. /* Convert out to 1.15 format */
  7740. return ((q15_t)(acc >> 36));
  7741. }
  7742. /**
  7743. * @brief Q7 bilinear interpolation.
  7744. * @param[in,out] S points to an instance of the interpolation structure.
  7745. * @param[in] X interpolation coordinate in 12.20 format.
  7746. * @param[in] Y interpolation coordinate in 12.20 format.
  7747. * @return out interpolated value.
  7748. */
  7749. __STATIC_FORCEINLINE q7_t arm_bilinear_interp_q7(
  7750. arm_bilinear_interp_instance_q7 * S,
  7751. q31_t X,
  7752. q31_t Y)
  7753. {
  7754. q63_t acc = 0; /* output */
  7755. q31_t out; /* Temporary output */
  7756. q31_t xfract, yfract; /* X, Y fractional parts */
  7757. q7_t x1, x2, y1, y2; /* Nearest output values */
  7758. int32_t rI, cI; /* Row and column indices */
  7759. q7_t *pYData = S->pData; /* pointer to output table values */
  7760. uint32_t nCols = S->numCols; /* num of rows */
  7761. /* Input is in 12.20 format */
  7762. /* 12 bits for the table index */
  7763. /* Index value calculation */
  7764. rI = ((X & (q31_t)0xFFF00000) >> 20);
  7765. /* Input is in 12.20 format */
  7766. /* 12 bits for the table index */
  7767. /* Index value calculation */
  7768. cI = ((Y & (q31_t)0xFFF00000) >> 20);
  7769. /* Care taken for table outside boundary */
  7770. /* Returns zero output when values are outside table boundary */
  7771. if (rI < 0 || rI > (S->numCols - 2) || cI < 0 || cI > (S->numRows - 2))
  7772. {
  7773. return (0);
  7774. }
  7775. /* 20 bits for the fractional part */
  7776. /* xfract should be in 12.20 format */
  7777. xfract = (X & (q31_t)0x000FFFFF);
  7778. /* Read two nearest output values from the index */
  7779. x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
  7780. x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
  7781. /* 20 bits for the fractional part */
  7782. /* yfract should be in 12.20 format */
  7783. yfract = (Y & (q31_t)0x000FFFFF);
  7784. /* Read two nearest output values from the index */
  7785. y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
  7786. y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
  7787. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
  7788. out = ((x1 * (0xFFFFF - xfract)));
  7789. acc = (((q63_t) out * (0xFFFFF - yfract)));
  7790. /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
  7791. out = ((x2 * (0xFFFFF - yfract)));
  7792. acc += (((q63_t) out * (xfract)));
  7793. /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
  7794. out = ((y1 * (0xFFFFF - xfract)));
  7795. acc += (((q63_t) out * (yfract)));
  7796. /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
  7797. out = ((y2 * (yfract)));
  7798. acc += (((q63_t) out * (xfract)));
  7799. /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
  7800. return ((q7_t)(acc >> 40));
  7801. }
  7802. /**
  7803. * @} end of BilinearInterpolate group
  7804. */
  7805. /* SMMLAR */
  7806. #define multAcc_32x32_keep32_R(a, x, y) \
  7807. a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
  7808. /* SMMLSR */
  7809. #define multSub_32x32_keep32_R(a, x, y) \
  7810. a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
  7811. /* SMMULR */
  7812. #define mult_32x32_keep32_R(a, x, y) \
  7813. a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
  7814. /* SMMLA */
  7815. #define multAcc_32x32_keep32(a, x, y) \
  7816. a += (q31_t) (((q63_t) x * y) >> 32)
  7817. /* SMMLS */
  7818. #define multSub_32x32_keep32(a, x, y) \
  7819. a -= (q31_t) (((q63_t) x * y) >> 32)
  7820. /* SMMUL */
  7821. #define mult_32x32_keep32(a, x, y) \
  7822. a = (q31_t) (((q63_t) x * y ) >> 32)
  7823. #if defined ( __CC_ARM )
  7824. /* Enter low optimization region - place directly above function definition */
  7825. #if defined( __ARM_ARCH_7EM__ )
  7826. #define LOW_OPTIMIZATION_ENTER \
  7827. _Pragma ("push") \
  7828. _Pragma ("O1")
  7829. #else
  7830. #define LOW_OPTIMIZATION_ENTER
  7831. #endif
  7832. /* Exit low optimization region - place directly after end of function definition */
  7833. #if defined ( __ARM_ARCH_7EM__ )
  7834. #define LOW_OPTIMIZATION_EXIT \
  7835. _Pragma ("pop")
  7836. #else
  7837. #define LOW_OPTIMIZATION_EXIT
  7838. #endif
  7839. /* Enter low optimization region - place directly above function definition */
  7840. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7841. /* Exit low optimization region - place directly after end of function definition */
  7842. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7843. #elif defined (__ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
  7844. #define LOW_OPTIMIZATION_ENTER
  7845. #define LOW_OPTIMIZATION_EXIT
  7846. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7847. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7848. #elif defined ( __GNUC__ )
  7849. #define LOW_OPTIMIZATION_ENTER \
  7850. __attribute__(( optimize("-O1") ))
  7851. #define LOW_OPTIMIZATION_EXIT
  7852. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7853. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7854. #elif defined ( __ICCARM__ )
  7855. /* Enter low optimization region - place directly above function definition */
  7856. #if defined ( __ARM_ARCH_7EM__ )
  7857. #define LOW_OPTIMIZATION_ENTER \
  7858. _Pragma ("optimize=low")
  7859. #else
  7860. #define LOW_OPTIMIZATION_ENTER
  7861. #endif
  7862. /* Exit low optimization region - place directly after end of function definition */
  7863. #define LOW_OPTIMIZATION_EXIT
  7864. /* Enter low optimization region - place directly above function definition */
  7865. #if defined ( __ARM_ARCH_7EM__ )
  7866. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
  7867. _Pragma ("optimize=low")
  7868. #else
  7869. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7870. #endif
  7871. /* Exit low optimization region - place directly after end of function definition */
  7872. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7873. #elif defined ( __TI_ARM__ )
  7874. #define LOW_OPTIMIZATION_ENTER
  7875. #define LOW_OPTIMIZATION_EXIT
  7876. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7877. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7878. #elif defined ( __CSMC__ )
  7879. #define LOW_OPTIMIZATION_ENTER
  7880. #define LOW_OPTIMIZATION_EXIT
  7881. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7882. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7883. #elif defined ( __TASKING__ )
  7884. #define LOW_OPTIMIZATION_ENTER
  7885. #define LOW_OPTIMIZATION_EXIT
  7886. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7887. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7888. #elif defined ( _MSC_VER ) || defined(__GNUC_PYTHON__)
  7889. #define LOW_OPTIMIZATION_ENTER
  7890. #define LOW_OPTIMIZATION_EXIT
  7891. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  7892. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  7893. #endif
  7894. /* Compiler specific diagnostic adjustment */
  7895. #if defined ( __CC_ARM )
  7896. #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
  7897. #elif defined ( __GNUC__ )
  7898. #pragma GCC diagnostic pop
  7899. #elif defined ( __ICCARM__ )
  7900. #elif defined ( __TI_ARM__ )
  7901. #elif defined ( __CSMC__ )
  7902. #elif defined ( __TASKING__ )
  7903. #elif defined ( _MSC_VER )
  7904. #else
  7905. #error Unknown compiler
  7906. #endif
  7907. #ifdef __cplusplus
  7908. }
  7909. #endif
  7910. #endif /* _ARM_MATH_H */
  7911. /**
  7912. *
  7913. * End of file.
  7914. */