arm_math.h 246 KB

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