arm_math.h 233 KB

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