arm_math.h 251 KB

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