arm_math.h 235 KB

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