arm_math.h 234 KB

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