1
0

arm_math.h 228 KB

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