arm_math.h 242 KB

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