1
0

arm_math.h 225 KB

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