arm_math.h 249 KB

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