arm_math.h 282 KB

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