gpu_nms.cu 281 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081
  1. // ------------------------------------------------------------------
  2. // Faster R-CNN
  3. // Copyright (c) 2015 Microsoft
  4. // Licensed under The MIT License [see fast-rcnn/LICENSE for details]
  5. // Written by Shaoqing Ren
  6. // ------------------------------------------------------------------
  7. //#include "gpu_nms.hpp"
  8. #include <vector>
  9. #include <iostream>
  10. #define CUDA_CHECK(condition) \
  11. /* Code block avoids redefinition of cudaError_t error */ \
  12. do { \
  13. cudaError_t error = condition; \
  14. if (error != cudaSuccess) { \
  15. std::cout << cudaGetErrorString(error) << std::endl; \
  16. } \
  17. } while (0)
  18. #define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0))
  19. int const threadsPerBlock = sizeof(unsigned long long) * 8;
  20. __device__ inline float devIoU(float const * const a, float const * const b) {
  21. float left = max(a[0], b[0]), right = min(a[2], b[2]);
  22. float top = max(a[1], b[1]), bottom = min(a[3], b[3]);
  23. float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f);
  24. float interS = width * height;
  25. float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1);
  26. float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1);
  27. return interS / (Sa + Sb - interS);
  28. }
  29. __global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh,
  30. const float *dev_boxes, unsigned long long *dev_mask) {
  31. const int row_start = blockIdx.y;
  32. const int col_start = blockIdx.x;
  33. // if (row_start > col_start) return;
  34. const int row_size =
  35. min(n_boxes - row_start * threadsPerBlock, threadsPerBlock);
  36. const int col_size =
  37. min(n_boxes - col_start * threadsPerBlock, threadsPerBlock);
  38. __shared__ float block_boxes[threadsPerBlock * 5];
  39. if (threadIdx.x < col_size) {
  40. block_boxes[threadIdx.x * 5 + 0] =
  41. dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0];
  42. block_boxes[threadIdx.x * 5 + 1] =
  43. dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1];
  44. block_boxes[threadIdx.x * 5 + 2] =
  45. dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2];
  46. block_boxes[threadIdx.x * 5 + 3] =
  47. dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3];
  48. block_boxes[threadIdx.x * 5 + 4] =
  49. dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4];
  50. }
  51. __syncthreads();
  52. if (threadIdx.x < row_size) {
  53. const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x;
  54. const float *cur_box = dev_boxes + cur_box_idx * 5;
  55. int i = 0;
  56. unsigned long long t = 0;
  57. int start = 0;
  58. if (row_start == col_start) {
  59. start = threadIdx.x + 1;
  60. }
  61. for (i = start; i < col_size; i++) {
  62. if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) {
  63. t |= 1ULL << i;
  64. }
  65. }
  66. const int col_blocks = DIVUP(n_boxes, threadsPerBlock);
  67. dev_mask[cur_box_idx * col_blocks + col_start] = t;
  68. }
  69. }
  70. void _set_device(int device_id) {
  71. int current_device;
  72. CUDA_CHECK(cudaGetDevice(&current_device));
  73. if (current_device == device_id) {
  74. return;
  75. }
  76. // The call to cudaSetDevice must come before any calls to Get, which
  77. // may perform initialization using the GPU.
  78. CUDA_CHECK(cudaSetDevice(device_id));
  79. }
  80. void _nms(long* keep_out, int* num_out, const float* boxes_host, int boxes_num,
  81. int boxes_dim, float nms_overlap_thresh, int device_id) {
  82. _set_device(device_id);
  83. float* boxes_dev = NULL;
  84. unsigned long long* mask_dev = NULL;
  85. const int col_blocks = DIVUP(boxes_num, threadsPerBlock);
  86. CUDA_CHECK(cudaMalloc(&boxes_dev,
  87. boxes_num * boxes_dim * sizeof(float)));
  88. CUDA_CHECK(cudaMemcpy(boxes_dev,
  89. boxes_host,
  90. boxes_num * boxes_dim * sizeof(float),
  91. cudaMemcpyHostToDevice));
  92. CUDA_CHECK(cudaMalloc(&mask_dev,
  93. boxes_num * col_blocks * sizeof(unsigned long long)));
  94. dim3 blocks(DIVUP(boxes_num, threadsPerBlock),
  95. DIVUP(boxes_num, threadsPerBlock));
  96. dim3 threads(threadsPerBlock);
  97. nms_kernel<<<blocks, threads>>>(boxes_num,
  98. nms_overlap_thresh,
  99. boxes_dev,
  100. mask_dev);
  101. std::vector<unsigned long long> mask_host(boxes_num * col_blocks);
  102. CUDA_CHECK(cudaMemcpy(&mask_host[0],
  103. mask_dev,
  104. sizeof(unsigned long long) * boxes_num * col_blocks,
  105. cudaMemcpyDeviceToHost));
  106. std::vector<unsigned long long> remv(col_blocks);
  107. memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks);
  108. int num_to_keep = 0;
  109. for (int i = 0; i < boxes_num; i++) {
  110. int nblock = i / threadsPerBlock;
  111. int inblock = i % threadsPerBlock;
  112. if (!(remv[nblock] & (1ULL << inblock))) {
  113. keep_out[num_to_keep++] = i;
  114. unsigned long long *p = &mask_host[0] + i * col_blocks;
  115. for (int j = nblock; j < col_blocks; j++) {
  116. remv[j] |= p[j];
  117. }
  118. }
  119. }
  120. *num_out = num_to_keep;
  121. CUDA_CHECK(cudaFree(boxes_dev));
  122. CUDA_CHECK(cudaFree(mask_dev));
  123. }
  124. /* Generated by Cython 0.24 */
  125. #define PY_SSIZE_T_CLEAN
  126. #include "Python.h"
  127. #ifndef Py_PYTHON_H
  128. #error Python headers needed to compile C extensions, please install development version of Python.
  129. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
  130. #error Cython requires Python 2.6+ or Python 3.2+.
  131. #else
  132. #define CYTHON_ABI "0_24"
  133. #include <stddef.h>
  134. #ifndef offsetof
  135. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  136. #endif
  137. #if !defined(WIN32) && !defined(MS_WINDOWS)
  138. #ifndef __stdcall
  139. #define __stdcall
  140. #endif
  141. #ifndef __cdecl
  142. #define __cdecl
  143. #endif
  144. #ifndef __fastcall
  145. #define __fastcall
  146. #endif
  147. #endif
  148. #ifndef DL_IMPORT
  149. #define DL_IMPORT(t) t
  150. #endif
  151. #ifndef DL_EXPORT
  152. #define DL_EXPORT(t) t
  153. #endif
  154. #ifndef PY_LONG_LONG
  155. #define PY_LONG_LONG LONG_LONG
  156. #endif
  157. #ifndef Py_HUGE_VAL
  158. #define Py_HUGE_VAL HUGE_VAL
  159. #endif
  160. #ifdef PYPY_VERSION
  161. #define CYTHON_COMPILING_IN_PYPY 1
  162. #define CYTHON_COMPILING_IN_CPYTHON 0
  163. #else
  164. #define CYTHON_COMPILING_IN_PYPY 0
  165. #define CYTHON_COMPILING_IN_CPYTHON 1
  166. #endif
  167. #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
  168. #define CYTHON_USE_PYLONG_INTERNALS 1
  169. #endif
  170. #if CYTHON_USE_PYLONG_INTERNALS
  171. #include "longintrepr.h"
  172. #undef SHIFT
  173. #undef BASE
  174. #undef MASK
  175. #endif
  176. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  177. #define Py_OptimizeFlag 0
  178. #endif
  179. #define __PYX_BUILD_PY_SSIZE_T "n"
  180. #define CYTHON_FORMAT_SSIZE_T "z"
  181. #if PY_MAJOR_VERSION < 3
  182. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  183. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  184. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  185. #define __Pyx_DefaultClassType PyClass_Type
  186. #else
  187. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  188. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  189. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  190. #define __Pyx_DefaultClassType PyType_Type
  191. #endif
  192. #ifndef Py_TPFLAGS_CHECKTYPES
  193. #define Py_TPFLAGS_CHECKTYPES 0
  194. #endif
  195. #ifndef Py_TPFLAGS_HAVE_INDEX
  196. #define Py_TPFLAGS_HAVE_INDEX 0
  197. #endif
  198. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  199. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  200. #endif
  201. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  202. #define Py_TPFLAGS_HAVE_FINALIZE 0
  203. #endif
  204. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  205. #define CYTHON_PEP393_ENABLED 1
  206. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  207. 0 : _PyUnicode_Ready((PyObject *)(op)))
  208. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  209. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  210. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  211. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  212. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  213. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  214. #else
  215. #define CYTHON_PEP393_ENABLED 0
  216. #define __Pyx_PyUnicode_READY(op) (0)
  217. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  218. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  219. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  220. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  221. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  222. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  223. #endif
  224. #if CYTHON_COMPILING_IN_PYPY
  225. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  226. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  227. #else
  228. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  229. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  230. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  231. #endif
  232. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  233. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  234. #endif
  235. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  236. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  237. #endif
  238. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  239. #define PyObject_Malloc(s) PyMem_Malloc(s)
  240. #define PyObject_Free(p) PyMem_Free(p)
  241. #define PyObject_Realloc(p) PyMem_Realloc(p)
  242. #endif
  243. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  244. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  245. #if PY_MAJOR_VERSION >= 3
  246. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  247. #else
  248. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  249. #endif
  250. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  251. #define PyObject_ASCII(o) PyObject_Repr(o)
  252. #endif
  253. #if PY_MAJOR_VERSION >= 3
  254. #define PyBaseString_Type PyUnicode_Type
  255. #define PyStringObject PyUnicodeObject
  256. #define PyString_Type PyUnicode_Type
  257. #define PyString_Check PyUnicode_Check
  258. #define PyString_CheckExact PyUnicode_CheckExact
  259. #endif
  260. #if PY_MAJOR_VERSION >= 3
  261. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  262. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  263. #else
  264. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  265. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  266. #endif
  267. #ifndef PySet_CheckExact
  268. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  269. #endif
  270. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  271. #if PY_MAJOR_VERSION >= 3
  272. #define PyIntObject PyLongObject
  273. #define PyInt_Type PyLong_Type
  274. #define PyInt_Check(op) PyLong_Check(op)
  275. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  276. #define PyInt_FromString PyLong_FromString
  277. #define PyInt_FromUnicode PyLong_FromUnicode
  278. #define PyInt_FromLong PyLong_FromLong
  279. #define PyInt_FromSize_t PyLong_FromSize_t
  280. #define PyInt_FromSsize_t PyLong_FromSsize_t
  281. #define PyInt_AsLong PyLong_AsLong
  282. #define PyInt_AS_LONG PyLong_AS_LONG
  283. #define PyInt_AsSsize_t PyLong_AsSsize_t
  284. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  285. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  286. #define PyNumber_Int PyNumber_Long
  287. #endif
  288. #if PY_MAJOR_VERSION >= 3
  289. #define PyBoolObject PyLongObject
  290. #endif
  291. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  292. #ifndef PyUnicode_InternFromString
  293. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  294. #endif
  295. #endif
  296. #if PY_VERSION_HEX < 0x030200A4
  297. typedef long Py_hash_t;
  298. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  299. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  300. #else
  301. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  302. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  303. #endif
  304. #if PY_MAJOR_VERSION >= 3
  305. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  306. #else
  307. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  308. #endif
  309. #if PY_VERSION_HEX >= 0x030500B1
  310. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  311. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  312. #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  313. typedef struct {
  314. unaryfunc am_await;
  315. unaryfunc am_aiter;
  316. unaryfunc am_anext;
  317. } __Pyx_PyAsyncMethodsStruct;
  318. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  319. #else
  320. #define __Pyx_PyType_AsAsync(obj) NULL
  321. #endif
  322. #ifndef CYTHON_RESTRICT
  323. #if defined(__GNUC__)
  324. #define CYTHON_RESTRICT __restrict__
  325. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  326. #define CYTHON_RESTRICT __restrict
  327. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  328. #define CYTHON_RESTRICT restrict
  329. #else
  330. #define CYTHON_RESTRICT
  331. #endif
  332. #endif
  333. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  334. #ifndef __cplusplus
  335. #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
  336. #endif
  337. #ifndef CYTHON_INLINE
  338. #define CYTHON_INLINE inline
  339. #endif
  340. template<typename T>
  341. void __Pyx_call_destructor(T& x) {
  342. x.~T();
  343. }
  344. template<typename T>
  345. class __Pyx_FakeReference {
  346. public:
  347. __Pyx_FakeReference() : ptr(NULL) { }
  348. __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
  349. T *operator->() { return ptr; }
  350. operator T&() { return *ptr; }
  351. private:
  352. T *ptr;
  353. };
  354. #if defined(WIN32) || defined(MS_WINDOWS)
  355. #define _USE_MATH_DEFINES
  356. #endif
  357. #include <math.h>
  358. #ifdef NAN
  359. #define __PYX_NAN() ((float) NAN)
  360. #else
  361. static CYTHON_INLINE float __PYX_NAN() {
  362. float value;
  363. memset(&value, 0xFF, sizeof(value));
  364. return value;
  365. }
  366. #endif
  367. #define __PYX_ERR(f_index, lineno, Ln_error) \
  368. { \
  369. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  370. }
  371. #if PY_MAJOR_VERSION >= 3
  372. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  373. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  374. #else
  375. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  376. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  377. #endif
  378. #ifndef __PYX_EXTERN_C
  379. #ifdef __cplusplus
  380. #define __PYX_EXTERN_C extern "C"
  381. #else
  382. #define __PYX_EXTERN_C extern
  383. #endif
  384. #endif
  385. #define __PYX_HAVE__nms__gpu_nms
  386. #define __PYX_HAVE_API__nms__gpu_nms
  387. #include "string.h"
  388. #include "stdio.h"
  389. #include "stdlib.h"
  390. #include "numpy/arrayobject.h"
  391. #include "numpy/ufuncobject.h"
  392. #include "gpu_nms.hpp"
  393. #ifdef _OPENMP
  394. #include <omp.h>
  395. #endif /* _OPENMP */
  396. #ifdef PYREX_WITHOUT_ASSERTIONS
  397. #define CYTHON_WITHOUT_ASSERTIONS
  398. #endif
  399. #ifndef CYTHON_UNUSED
  400. # if defined(__GNUC__)
  401. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  402. # define CYTHON_UNUSED __attribute__ ((__unused__))
  403. # else
  404. # define CYTHON_UNUSED
  405. # endif
  406. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  407. # define CYTHON_UNUSED __attribute__ ((__unused__))
  408. # else
  409. # define CYTHON_UNUSED
  410. # endif
  411. #endif
  412. #ifndef CYTHON_NCP_UNUSED
  413. # if CYTHON_COMPILING_IN_CPYTHON
  414. # define CYTHON_NCP_UNUSED
  415. # else
  416. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  417. # endif
  418. #endif
  419. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  420. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  421. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  422. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  423. #define __PYX_DEFAULT_STRING_ENCODING ""
  424. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  425. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  426. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  427. #define __Pyx_long_cast(x) ((long)x)
  428. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  429. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  430. (sizeof(type) > sizeof(Py_ssize_t) &&\
  431. likely(v < (type)PY_SSIZE_T_MAX ||\
  432. v == (type)PY_SSIZE_T_MAX) &&\
  433. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  434. v == (type)PY_SSIZE_T_MIN))) ||\
  435. (sizeof(type) == sizeof(Py_ssize_t) &&\
  436. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  437. v == (type)PY_SSIZE_T_MAX))) )
  438. #if defined (__cplusplus) && __cplusplus >= 201103L
  439. #include <cstdlib>
  440. #define __Pyx_sst_abs(value) std::abs(value)
  441. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  442. #define __Pyx_sst_abs(value) abs(value)
  443. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  444. #define __Pyx_sst_abs(value) labs(value)
  445. #elif defined (_MSC_VER) && defined (_M_X64)
  446. #define __Pyx_sst_abs(value) _abs64(value)
  447. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  448. #define __Pyx_sst_abs(value) llabs(value)
  449. #elif defined (__GNUC__)
  450. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  451. #else
  452. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  453. #endif
  454. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
  455. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  456. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  457. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  458. #define __Pyx_PyBytes_FromString PyBytes_FromString
  459. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  460. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  461. #if PY_MAJOR_VERSION < 3
  462. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  463. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  464. #else
  465. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  466. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  467. #endif
  468. #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  469. #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  470. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  471. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  472. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  473. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  474. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  475. #if PY_MAJOR_VERSION < 3
  476. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
  477. {
  478. const Py_UNICODE *u_end = u;
  479. while (*u_end++) ;
  480. return (size_t)(u_end - u - 1);
  481. }
  482. #else
  483. #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
  484. #endif
  485. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  486. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  487. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  488. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  489. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  490. #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
  491. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  492. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  493. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  494. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  495. #if CYTHON_COMPILING_IN_CPYTHON
  496. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  497. #else
  498. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  499. #endif
  500. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  501. #if PY_MAJOR_VERSION >= 3
  502. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  503. #else
  504. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  505. #endif
  506. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  507. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  508. static int __Pyx_sys_getdefaultencoding_not_ascii;
  509. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  510. PyObject* sys;
  511. PyObject* default_encoding = NULL;
  512. PyObject* ascii_chars_u = NULL;
  513. PyObject* ascii_chars_b = NULL;
  514. const char* default_encoding_c;
  515. sys = PyImport_ImportModule("sys");
  516. if (!sys) goto bad;
  517. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  518. Py_DECREF(sys);
  519. if (!default_encoding) goto bad;
  520. default_encoding_c = PyBytes_AsString(default_encoding);
  521. if (!default_encoding_c) goto bad;
  522. if (strcmp(default_encoding_c, "ascii") == 0) {
  523. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  524. } else {
  525. char ascii_chars[128];
  526. int c;
  527. for (c = 0; c < 128; c++) {
  528. ascii_chars[c] = c;
  529. }
  530. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  531. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  532. if (!ascii_chars_u) goto bad;
  533. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  534. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  535. PyErr_Format(
  536. PyExc_ValueError,
  537. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  538. default_encoding_c);
  539. goto bad;
  540. }
  541. Py_DECREF(ascii_chars_u);
  542. Py_DECREF(ascii_chars_b);
  543. }
  544. Py_DECREF(default_encoding);
  545. return 0;
  546. bad:
  547. Py_XDECREF(default_encoding);
  548. Py_XDECREF(ascii_chars_u);
  549. Py_XDECREF(ascii_chars_b);
  550. return -1;
  551. }
  552. #endif
  553. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  554. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  555. #else
  556. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  557. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  558. static char* __PYX_DEFAULT_STRING_ENCODING;
  559. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  560. PyObject* sys;
  561. PyObject* default_encoding = NULL;
  562. char* default_encoding_c;
  563. sys = PyImport_ImportModule("sys");
  564. if (!sys) goto bad;
  565. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  566. Py_DECREF(sys);
  567. if (!default_encoding) goto bad;
  568. default_encoding_c = PyBytes_AsString(default_encoding);
  569. if (!default_encoding_c) goto bad;
  570. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  571. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  572. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  573. Py_DECREF(default_encoding);
  574. return 0;
  575. bad:
  576. Py_XDECREF(default_encoding);
  577. return -1;
  578. }
  579. #endif
  580. #endif
  581. /* Test for GCC > 2.95 */
  582. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  583. #define likely(x) __builtin_expect(!!(x), 1)
  584. #define unlikely(x) __builtin_expect(!!(x), 0)
  585. #else /* !__GNUC__ or GCC < 2.95 */
  586. #define likely(x) (x)
  587. #define unlikely(x) (x)
  588. #endif /* __GNUC__ */
  589. static PyObject *__pyx_m;
  590. static PyObject *__pyx_d;
  591. static PyObject *__pyx_b;
  592. static PyObject *__pyx_empty_tuple;
  593. static PyObject *__pyx_empty_bytes;
  594. static PyObject *__pyx_empty_unicode;
  595. static int __pyx_lineno;
  596. static int __pyx_clineno = 0;
  597. static const char * __pyx_cfilenm= __FILE__;
  598. static const char *__pyx_filename;
  599. /* None.proto */
  600. #if !defined(CYTHON_CCOMPLEX)
  601. #if defined(__cplusplus)
  602. #define CYTHON_CCOMPLEX 1
  603. #elif defined(_Complex_I)
  604. #define CYTHON_CCOMPLEX 1
  605. #else
  606. #define CYTHON_CCOMPLEX 0
  607. #endif
  608. #endif
  609. #if CYTHON_CCOMPLEX
  610. #ifdef __cplusplus
  611. #include <complex>
  612. #else
  613. #include <complex.h>
  614. #endif
  615. #endif
  616. #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  617. #undef _Complex_I
  618. #define _Complex_I 1.0fj
  619. #endif
  620. static const char *__pyx_f[] = {
  621. "nms\\gpu_nms.pyx",
  622. "__init__.pxd",
  623. "type.pxd",
  624. };
  625. /* BufferFormatStructs.proto */
  626. #define IS_UNSIGNED(type) (((type) -1) > 0)
  627. struct __Pyx_StructField_;
  628. #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
  629. typedef struct {
  630. const char* name;
  631. struct __Pyx_StructField_* fields;
  632. size_t size;
  633. size_t arraysize[8];
  634. int ndim;
  635. char typegroup;
  636. char is_unsigned;
  637. int flags;
  638. } __Pyx_TypeInfo;
  639. typedef struct __Pyx_StructField_ {
  640. __Pyx_TypeInfo* type;
  641. const char* name;
  642. size_t offset;
  643. } __Pyx_StructField;
  644. typedef struct {
  645. __Pyx_StructField* field;
  646. size_t parent_offset;
  647. } __Pyx_BufFmt_StackElem;
  648. typedef struct {
  649. __Pyx_StructField root;
  650. __Pyx_BufFmt_StackElem* head;
  651. size_t fmt_offset;
  652. size_t new_count, enc_count;
  653. size_t struct_alignment;
  654. int is_complex;
  655. char enc_type;
  656. char new_packmode;
  657. char enc_packmode;
  658. char is_valid_array;
  659. } __Pyx_BufFmt_Context;
  660. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":725
  661. * # in Cython to enable them only on the right systems.
  662. *
  663. * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<<
  664. * ctypedef npy_int16 int16_t
  665. * ctypedef npy_int32 int32_t
  666. */
  667. typedef npy_int8 __pyx_t_5numpy_int8_t;
  668. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":726
  669. *
  670. * ctypedef npy_int8 int8_t
  671. * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<<
  672. * ctypedef npy_int32 int32_t
  673. * ctypedef npy_int64 int64_t
  674. */
  675. typedef npy_int16 __pyx_t_5numpy_int16_t;
  676. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":727
  677. * ctypedef npy_int8 int8_t
  678. * ctypedef npy_int16 int16_t
  679. * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<<
  680. * ctypedef npy_int64 int64_t
  681. * #ctypedef npy_int96 int96_t
  682. */
  683. typedef npy_int32 __pyx_t_5numpy_int32_t;
  684. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":728
  685. * ctypedef npy_int16 int16_t
  686. * ctypedef npy_int32 int32_t
  687. * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<<
  688. * #ctypedef npy_int96 int96_t
  689. * #ctypedef npy_int128 int128_t
  690. */
  691. typedef npy_int64 __pyx_t_5numpy_int64_t;
  692. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":732
  693. * #ctypedef npy_int128 int128_t
  694. *
  695. * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<<
  696. * ctypedef npy_uint16 uint16_t
  697. * ctypedef npy_uint32 uint32_t
  698. */
  699. typedef npy_uint8 __pyx_t_5numpy_uint8_t;
  700. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":733
  701. *
  702. * ctypedef npy_uint8 uint8_t
  703. * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<<
  704. * ctypedef npy_uint32 uint32_t
  705. * ctypedef npy_uint64 uint64_t
  706. */
  707. typedef npy_uint16 __pyx_t_5numpy_uint16_t;
  708. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":734
  709. * ctypedef npy_uint8 uint8_t
  710. * ctypedef npy_uint16 uint16_t
  711. * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<<
  712. * ctypedef npy_uint64 uint64_t
  713. * #ctypedef npy_uint96 uint96_t
  714. */
  715. typedef npy_uint32 __pyx_t_5numpy_uint32_t;
  716. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":735
  717. * ctypedef npy_uint16 uint16_t
  718. * ctypedef npy_uint32 uint32_t
  719. * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<<
  720. * #ctypedef npy_uint96 uint96_t
  721. * #ctypedef npy_uint128 uint128_t
  722. */
  723. typedef npy_uint64 __pyx_t_5numpy_uint64_t;
  724. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":739
  725. * #ctypedef npy_uint128 uint128_t
  726. *
  727. * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<<
  728. * ctypedef npy_float64 float64_t
  729. * #ctypedef npy_float80 float80_t
  730. */
  731. typedef npy_float32 __pyx_t_5numpy_float32_t;
  732. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":740
  733. *
  734. * ctypedef npy_float32 float32_t
  735. * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<<
  736. * #ctypedef npy_float80 float80_t
  737. * #ctypedef npy_float128 float128_t
  738. */
  739. typedef npy_float64 __pyx_t_5numpy_float64_t;
  740. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":749
  741. * # The int types are mapped a bit surprising --
  742. * # numpy.int corresponds to 'l' and numpy.long to 'q'
  743. * ctypedef npy_long int_t # <<<<<<<<<<<<<<
  744. * ctypedef npy_longlong long_t
  745. * ctypedef npy_longlong longlong_t
  746. */
  747. typedef npy_long __pyx_t_5numpy_int_t;
  748. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":750
  749. * # numpy.int corresponds to 'l' and numpy.long to 'q'
  750. * ctypedef npy_long int_t
  751. * ctypedef npy_longlong long_t # <<<<<<<<<<<<<<
  752. * ctypedef npy_longlong longlong_t
  753. *
  754. */
  755. typedef npy_longlong __pyx_t_5numpy_long_t;
  756. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":751
  757. * ctypedef npy_long int_t
  758. * ctypedef npy_longlong long_t
  759. * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<<
  760. *
  761. * ctypedef npy_ulong uint_t
  762. */
  763. typedef npy_longlong __pyx_t_5numpy_longlong_t;
  764. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":753
  765. * ctypedef npy_longlong longlong_t
  766. *
  767. * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<<
  768. * ctypedef npy_ulonglong ulong_t
  769. * ctypedef npy_ulonglong ulonglong_t
  770. */
  771. typedef npy_ulong __pyx_t_5numpy_uint_t;
  772. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":754
  773. *
  774. * ctypedef npy_ulong uint_t
  775. * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<<
  776. * ctypedef npy_ulonglong ulonglong_t
  777. *
  778. */
  779. typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
  780. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":755
  781. * ctypedef npy_ulong uint_t
  782. * ctypedef npy_ulonglong ulong_t
  783. * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<<
  784. *
  785. * ctypedef npy_intp intp_t
  786. */
  787. typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
  788. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":757
  789. * ctypedef npy_ulonglong ulonglong_t
  790. *
  791. * ctypedef npy_intp intp_t # <<<<<<<<<<<<<<
  792. * ctypedef npy_uintp uintp_t
  793. *
  794. */
  795. typedef npy_intp __pyx_t_5numpy_intp_t;
  796. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":758
  797. *
  798. * ctypedef npy_intp intp_t
  799. * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<<
  800. *
  801. * ctypedef npy_double float_t
  802. */
  803. typedef npy_uintp __pyx_t_5numpy_uintp_t;
  804. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":760
  805. * ctypedef npy_uintp uintp_t
  806. *
  807. * ctypedef npy_double float_t # <<<<<<<<<<<<<<
  808. * ctypedef npy_double double_t
  809. * ctypedef npy_longdouble longdouble_t
  810. */
  811. typedef npy_double __pyx_t_5numpy_float_t;
  812. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":761
  813. *
  814. * ctypedef npy_double float_t
  815. * ctypedef npy_double double_t # <<<<<<<<<<<<<<
  816. * ctypedef npy_longdouble longdouble_t
  817. *
  818. */
  819. typedef npy_double __pyx_t_5numpy_double_t;
  820. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":762
  821. * ctypedef npy_double float_t
  822. * ctypedef npy_double double_t
  823. * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<<
  824. *
  825. * ctypedef npy_cfloat cfloat_t
  826. */
  827. typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
  828. /* None.proto */
  829. #if CYTHON_CCOMPLEX
  830. #ifdef __cplusplus
  831. typedef ::std::complex< float > __pyx_t_float_complex;
  832. #else
  833. typedef float _Complex __pyx_t_float_complex;
  834. #endif
  835. #else
  836. typedef struct { float real, imag; } __pyx_t_float_complex;
  837. #endif
  838. /* None.proto */
  839. #if CYTHON_CCOMPLEX
  840. #ifdef __cplusplus
  841. typedef ::std::complex< double > __pyx_t_double_complex;
  842. #else
  843. typedef double _Complex __pyx_t_double_complex;
  844. #endif
  845. #else
  846. typedef struct { double real, imag; } __pyx_t_double_complex;
  847. #endif
  848. /*--- Type declarations ---*/
  849. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":764
  850. * ctypedef npy_longdouble longdouble_t
  851. *
  852. * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<<
  853. * ctypedef npy_cdouble cdouble_t
  854. * ctypedef npy_clongdouble clongdouble_t
  855. */
  856. typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
  857. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":765
  858. *
  859. * ctypedef npy_cfloat cfloat_t
  860. * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<<
  861. * ctypedef npy_clongdouble clongdouble_t
  862. *
  863. */
  864. typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
  865. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":766
  866. * ctypedef npy_cfloat cfloat_t
  867. * ctypedef npy_cdouble cdouble_t
  868. * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<<
  869. *
  870. * ctypedef npy_cdouble complex_t
  871. */
  872. typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
  873. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":768
  874. * ctypedef npy_clongdouble clongdouble_t
  875. *
  876. * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<<
  877. *
  878. * cdef inline object PyArray_MultiIterNew1(a):
  879. */
  880. typedef npy_cdouble __pyx_t_5numpy_complex_t;
  881. /* --- Runtime support code (head) --- */
  882. /* Refnanny.proto */
  883. #ifndef CYTHON_REFNANNY
  884. #define CYTHON_REFNANNY 0
  885. #endif
  886. #if CYTHON_REFNANNY
  887. typedef struct {
  888. void (*INCREF)(void*, PyObject*, int);
  889. void (*DECREF)(void*, PyObject*, int);
  890. void (*GOTREF)(void*, PyObject*, int);
  891. void (*GIVEREF)(void*, PyObject*, int);
  892. void* (*SetupContext)(const char*, int, const char*);
  893. void (*FinishContext)(void**);
  894. } __Pyx_RefNannyAPIStruct;
  895. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  896. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  897. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  898. #ifdef WITH_THREAD
  899. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  900. if (acquire_gil) {\
  901. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  902. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  903. PyGILState_Release(__pyx_gilstate_save);\
  904. } else {\
  905. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  906. }
  907. #else
  908. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  909. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  910. #endif
  911. #define __Pyx_RefNannyFinishContext()\
  912. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  913. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  914. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  915. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  916. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  917. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  918. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  919. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  920. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  921. #else
  922. #define __Pyx_RefNannyDeclarations
  923. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  924. #define __Pyx_RefNannyFinishContext()
  925. #define __Pyx_INCREF(r) Py_INCREF(r)
  926. #define __Pyx_DECREF(r) Py_DECREF(r)
  927. #define __Pyx_GOTREF(r)
  928. #define __Pyx_GIVEREF(r)
  929. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  930. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  931. #define __Pyx_XGOTREF(r)
  932. #define __Pyx_XGIVEREF(r)
  933. #endif
  934. #define __Pyx_XDECREF_SET(r, v) do {\
  935. PyObject *tmp = (PyObject *) r;\
  936. r = v; __Pyx_XDECREF(tmp);\
  937. } while (0)
  938. #define __Pyx_DECREF_SET(r, v) do {\
  939. PyObject *tmp = (PyObject *) r;\
  940. r = v; __Pyx_DECREF(tmp);\
  941. } while (0)
  942. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  943. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  944. /* RaiseArgTupleInvalid.proto */
  945. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  946. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  947. /* RaiseDoubleKeywords.proto */
  948. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  949. /* ParseKeywords.proto */
  950. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  951. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  952. const char* function_name);
  953. /* ArgTypeTest.proto */
  954. static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
  955. const char *name, int exact);
  956. /* BufferFormatCheck.proto */
  957. static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
  958. __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
  959. static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
  960. static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
  961. static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
  962. __Pyx_BufFmt_StackElem* stack,
  963. __Pyx_TypeInfo* type); // PROTO
  964. /* PyObjectGetAttrStr.proto */
  965. #if CYTHON_COMPILING_IN_CPYTHON
  966. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  967. PyTypeObject* tp = Py_TYPE(obj);
  968. if (likely(tp->tp_getattro))
  969. return tp->tp_getattro(obj, attr_name);
  970. #if PY_MAJOR_VERSION < 3
  971. if (likely(tp->tp_getattr))
  972. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  973. #endif
  974. return PyObject_GetAttr(obj, attr_name);
  975. }
  976. #else
  977. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  978. #endif
  979. /* GetBuiltinName.proto */
  980. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  981. /* GetModuleGlobalName.proto */
  982. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  983. /* PyObjectCall.proto */
  984. #if CYTHON_COMPILING_IN_CPYTHON
  985. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  986. #else
  987. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  988. #endif
  989. /* ExtTypeTest.proto */
  990. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
  991. /* PyObjectCallMethO.proto */
  992. #if CYTHON_COMPILING_IN_CPYTHON
  993. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  994. #endif
  995. /* PyObjectCallOneArg.proto */
  996. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  997. /* PyObjectCallNoArg.proto */
  998. #if CYTHON_COMPILING_IN_CPYTHON
  999. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  1000. #else
  1001. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  1002. #endif
  1003. /* BufferIndexError.proto */
  1004. static void __Pyx_RaiseBufferIndexError(int axis);
  1005. #define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
  1006. #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1)
  1007. /* SliceObject.proto */
  1008. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
  1009. PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
  1010. PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
  1011. int has_cstart, int has_cstop, int wraparound);
  1012. /* BufferFallbackError.proto */
  1013. static void __Pyx_RaiseBufferFallbackError(void);
  1014. /* PyThreadStateGet.proto */
  1015. #if CYTHON_COMPILING_IN_CPYTHON
  1016. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1017. #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
  1018. #else
  1019. #define __Pyx_PyThreadState_declare
  1020. #define __Pyx_PyThreadState_assign
  1021. #endif
  1022. /* PyErrFetchRestore.proto */
  1023. #if CYTHON_COMPILING_IN_CPYTHON
  1024. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1025. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1026. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1027. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1028. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1029. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1030. #else
  1031. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1032. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1033. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1034. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1035. #endif
  1036. /* RaiseException.proto */
  1037. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1038. /* DictGetItem.proto */
  1039. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  1040. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
  1041. PyObject *value;
  1042. value = PyDict_GetItemWithError(d, key);
  1043. if (unlikely(!value)) {
  1044. if (!PyErr_Occurred()) {
  1045. PyObject* args = PyTuple_Pack(1, key);
  1046. if (likely(args))
  1047. PyErr_SetObject(PyExc_KeyError, args);
  1048. Py_XDECREF(args);
  1049. }
  1050. return NULL;
  1051. }
  1052. Py_INCREF(value);
  1053. return value;
  1054. }
  1055. #else
  1056. #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
  1057. #endif
  1058. /* RaiseTooManyValuesToUnpack.proto */
  1059. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  1060. /* RaiseNeedMoreValuesToUnpack.proto */
  1061. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  1062. /* RaiseNoneIterError.proto */
  1063. static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
  1064. /* Import.proto */
  1065. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1066. /* CodeObjectCache.proto */
  1067. typedef struct {
  1068. PyCodeObject* code_object;
  1069. int code_line;
  1070. } __Pyx_CodeObjectCacheEntry;
  1071. struct __Pyx_CodeObjectCache {
  1072. int count;
  1073. int max_count;
  1074. __Pyx_CodeObjectCacheEntry* entries;
  1075. };
  1076. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1077. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1078. static PyCodeObject *__pyx_find_code_object(int code_line);
  1079. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1080. /* AddTraceback.proto */
  1081. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1082. int py_line, const char *filename);
  1083. /* BufferStructDeclare.proto */
  1084. typedef struct {
  1085. Py_ssize_t shape, strides, suboffsets;
  1086. } __Pyx_Buf_DimInfo;
  1087. typedef struct {
  1088. size_t refcount;
  1089. Py_buffer pybuffer;
  1090. } __Pyx_Buffer;
  1091. typedef struct {
  1092. __Pyx_Buffer *rcbuffer;
  1093. char *data;
  1094. __Pyx_Buf_DimInfo diminfo[8];
  1095. } __Pyx_LocalBuf_ND;
  1096. #if PY_MAJOR_VERSION < 3
  1097. static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
  1098. static void __Pyx_ReleaseBuffer(Py_buffer *view);
  1099. #else
  1100. #define __Pyx_GetBuffer PyObject_GetBuffer
  1101. #define __Pyx_ReleaseBuffer PyBuffer_Release
  1102. #endif
  1103. /* None.proto */
  1104. static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
  1105. static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};
  1106. /* CIntToPy.proto */
  1107. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1108. /* None.proto */
  1109. #if CYTHON_CCOMPLEX
  1110. #ifdef __cplusplus
  1111. #define __Pyx_CREAL(z) ((z).real())
  1112. #define __Pyx_CIMAG(z) ((z).imag())
  1113. #else
  1114. #define __Pyx_CREAL(z) (__real__(z))
  1115. #define __Pyx_CIMAG(z) (__imag__(z))
  1116. #endif
  1117. #else
  1118. #define __Pyx_CREAL(z) ((z).real)
  1119. #define __Pyx_CIMAG(z) ((z).imag)
  1120. #endif
  1121. #if defined(__cplusplus) && CYTHON_CCOMPLEX && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
  1122. #define __Pyx_SET_CREAL(z,x) ((z).real(x))
  1123. #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
  1124. #else
  1125. #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
  1126. #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
  1127. #endif
  1128. /* None.proto */
  1129. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
  1130. /* None.proto */
  1131. #if CYTHON_CCOMPLEX
  1132. #define __Pyx_c_eqf(a, b) ((a)==(b))
  1133. #define __Pyx_c_sumf(a, b) ((a)+(b))
  1134. #define __Pyx_c_difff(a, b) ((a)-(b))
  1135. #define __Pyx_c_prodf(a, b) ((a)*(b))
  1136. #define __Pyx_c_quotf(a, b) ((a)/(b))
  1137. #define __Pyx_c_negf(a) (-(a))
  1138. #ifdef __cplusplus
  1139. #define __Pyx_c_is_zerof(z) ((z)==(float)0)
  1140. #define __Pyx_c_conjf(z) (::std::conj(z))
  1141. #if 1
  1142. #define __Pyx_c_absf(z) (::std::abs(z))
  1143. #define __Pyx_c_powf(a, b) (::std::pow(a, b))
  1144. #endif
  1145. #else
  1146. #define __Pyx_c_is_zerof(z) ((z)==0)
  1147. #define __Pyx_c_conjf(z) (conjf(z))
  1148. #if 1
  1149. #define __Pyx_c_absf(z) (cabsf(z))
  1150. #define __Pyx_c_powf(a, b) (cpowf(a, b))
  1151. #endif
  1152. #endif
  1153. #else
  1154. static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
  1155. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
  1156. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
  1157. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
  1158. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
  1159. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
  1160. static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
  1161. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
  1162. #if 1
  1163. static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
  1164. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
  1165. #endif
  1166. #endif
  1167. /* None.proto */
  1168. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
  1169. /* None.proto */
  1170. #if CYTHON_CCOMPLEX
  1171. #define __Pyx_c_eq(a, b) ((a)==(b))
  1172. #define __Pyx_c_sum(a, b) ((a)+(b))
  1173. #define __Pyx_c_diff(a, b) ((a)-(b))
  1174. #define __Pyx_c_prod(a, b) ((a)*(b))
  1175. #define __Pyx_c_quot(a, b) ((a)/(b))
  1176. #define __Pyx_c_neg(a) (-(a))
  1177. #ifdef __cplusplus
  1178. #define __Pyx_c_is_zero(z) ((z)==(double)0)
  1179. #define __Pyx_c_conj(z) (::std::conj(z))
  1180. #if 1
  1181. #define __Pyx_c_abs(z) (::std::abs(z))
  1182. #define __Pyx_c_pow(a, b) (::std::pow(a, b))
  1183. #endif
  1184. #else
  1185. #define __Pyx_c_is_zero(z) ((z)==0)
  1186. #define __Pyx_c_conj(z) (conj(z))
  1187. #if 1
  1188. #define __Pyx_c_abs(z) (cabs(z))
  1189. #define __Pyx_c_pow(a, b) (cpow(a, b))
  1190. #endif
  1191. #endif
  1192. #else
  1193. static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
  1194. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
  1195. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
  1196. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
  1197. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
  1198. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
  1199. static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
  1200. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
  1201. #if 1
  1202. static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
  1203. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
  1204. #endif
  1205. #endif
  1206. /* CIntToPy.proto */
  1207. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);
  1208. /* CIntFromPy.proto */
  1209. static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *);
  1210. /* CIntFromPy.proto */
  1211. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1212. /* CIntToPy.proto */
  1213. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1214. /* CIntFromPy.proto */
  1215. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1216. /* CheckBinaryVersion.proto */
  1217. static int __Pyx_check_binary_version(void);
  1218. /* PyIdentifierFromString.proto */
  1219. #if !defined(__Pyx_PyIdentifier_FromString)
  1220. #if PY_MAJOR_VERSION < 3
  1221. #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
  1222. #else
  1223. #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
  1224. #endif
  1225. #endif
  1226. /* ModuleImport.proto */
  1227. static PyObject *__Pyx_ImportModule(const char *name);
  1228. /* TypeImport.proto */
  1229. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
  1230. /* InitStrings.proto */
  1231. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1232. /* Module declarations from 'cpython.buffer' */
  1233. /* Module declarations from 'libc.string' */
  1234. /* Module declarations from 'libc.stdio' */
  1235. /* Module declarations from '__builtin__' */
  1236. /* Module declarations from 'cpython.type' */
  1237. static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
  1238. /* Module declarations from 'cpython' */
  1239. /* Module declarations from 'cpython.object' */
  1240. /* Module declarations from 'cpython.ref' */
  1241. /* Module declarations from 'libc.stdlib' */
  1242. /* Module declarations from 'numpy' */
  1243. /* Module declarations from 'numpy' */
  1244. static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
  1245. static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
  1246. static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
  1247. static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
  1248. static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
  1249. static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
  1250. /* Module declarations from 'nms.gpu_nms' */
  1251. static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t = { "float32_t", NULL, sizeof(__pyx_t_5numpy_float32_t), { 0 }, 0, 'R', 0, 0 };
  1252. static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int32_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int32_t), 0 };
  1253. static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_intp_t = { "intp_t", NULL, sizeof(__pyx_t_5numpy_intp_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_intp_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_intp_t), 0 };
  1254. #define __Pyx_MODULE_NAME "nms.gpu_nms"
  1255. int __pyx_module_is_main_nms__gpu_nms = 0;
  1256. /* Implementation of 'nms.gpu_nms' */
  1257. static PyObject *__pyx_builtin_ValueError;
  1258. static PyObject *__pyx_builtin_range;
  1259. static PyObject *__pyx_builtin_RuntimeError;
  1260. static const char __pyx_k_np[] = "np";
  1261. static const char __pyx_k_dets[] = "dets";
  1262. static const char __pyx_k_keep[] = "keep";
  1263. static const char __pyx_k_main[] = "__main__";
  1264. static const char __pyx_k_test[] = "__test__";
  1265. static const char __pyx_k_dtype[] = "dtype";
  1266. static const char __pyx_k_int32[] = "int32";
  1267. static const char __pyx_k_numpy[] = "numpy";
  1268. static const char __pyx_k_order[] = "order";
  1269. static const char __pyx_k_range[] = "range";
  1270. static const char __pyx_k_zeros[] = "zeros";
  1271. static const char __pyx_k_import[] = "__import__";
  1272. static const char __pyx_k_scores[] = "scores";
  1273. static const char __pyx_k_thresh[] = "thresh";
  1274. static const char __pyx_k_argsort[] = "argsort";
  1275. static const char __pyx_k_gpu_nms[] = "gpu_nms";
  1276. static const char __pyx_k_num_out[] = "num_out";
  1277. static const char __pyx_k_boxes_dim[] = "boxes_dim";
  1278. static const char __pyx_k_boxes_num[] = "boxes_num";
  1279. static const char __pyx_k_device_id[] = "device_id";
  1280. static const char __pyx_k_ValueError[] = "ValueError";
  1281. static const char __pyx_k_nms_gpu_nms[] = "nms.gpu_nms";
  1282. static const char __pyx_k_sorted_dets[] = "sorted_dets";
  1283. static const char __pyx_k_RuntimeError[] = "RuntimeError";
  1284. static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
  1285. static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
  1286. static const char __pyx_k_D_v_zix_caffe_caffe_win_20160523[] = "D:\\v-zix\\caffe\\caffe-win-20160523\\models\\py-faster-rcnn-windows\\lib\\nms\\gpu_nms.pyx";
  1287. static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
  1288. static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
  1289. static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
  1290. static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
  1291. static PyObject *__pyx_kp_s_D_v_zix_caffe_caffe_win_20160523;
  1292. static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
  1293. static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
  1294. static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
  1295. static PyObject *__pyx_n_s_RuntimeError;
  1296. static PyObject *__pyx_n_s_ValueError;
  1297. static PyObject *__pyx_n_s_argsort;
  1298. static PyObject *__pyx_n_s_boxes_dim;
  1299. static PyObject *__pyx_n_s_boxes_num;
  1300. static PyObject *__pyx_n_s_dets;
  1301. static PyObject *__pyx_n_s_device_id;
  1302. static PyObject *__pyx_n_s_dtype;
  1303. static PyObject *__pyx_n_s_gpu_nms;
  1304. static PyObject *__pyx_n_s_import;
  1305. static PyObject *__pyx_n_s_int32;
  1306. static PyObject *__pyx_n_s_keep;
  1307. static PyObject *__pyx_n_s_main;
  1308. static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
  1309. static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
  1310. static PyObject *__pyx_n_s_nms_gpu_nms;
  1311. static PyObject *__pyx_n_s_np;
  1312. static PyObject *__pyx_n_s_num_out;
  1313. static PyObject *__pyx_n_s_numpy;
  1314. static PyObject *__pyx_n_s_order;
  1315. static PyObject *__pyx_n_s_range;
  1316. static PyObject *__pyx_n_s_scores;
  1317. static PyObject *__pyx_n_s_sorted_dets;
  1318. static PyObject *__pyx_n_s_test;
  1319. static PyObject *__pyx_n_s_thresh;
  1320. static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
  1321. static PyObject *__pyx_n_s_zeros;
  1322. static PyObject *__pyx_pf_3nms_7gpu_nms_gpu_nms(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dets, PyObject *__pyx_v_thresh, __pyx_t_5numpy_int32_t __pyx_v_device_id); /* proto */
  1323. static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
  1324. static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
  1325. static PyObject *__pyx_int_4;
  1326. static PyObject *__pyx_int_neg_1;
  1327. static PyObject *__pyx_slice_;
  1328. static PyObject *__pyx_slice__3;
  1329. static PyObject *__pyx_slice__4;
  1330. static PyObject *__pyx_tuple__2;
  1331. static PyObject *__pyx_tuple__5;
  1332. static PyObject *__pyx_tuple__6;
  1333. static PyObject *__pyx_tuple__7;
  1334. static PyObject *__pyx_tuple__8;
  1335. static PyObject *__pyx_tuple__9;
  1336. static PyObject *__pyx_tuple__10;
  1337. static PyObject *__pyx_tuple__11;
  1338. static PyObject *__pyx_codeobj__12;
  1339. /* "nms/gpu_nms.pyx":16
  1340. * void _nms(np.int32_t*, int*, np.float32_t*, int, int, float, int)
  1341. *
  1342. * def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh, # <<<<<<<<<<<<<<
  1343. * np.int32_t device_id=0):
  1344. * cdef int boxes_num = dets.shape[0]
  1345. */
  1346. /* Python wrapper */
  1347. static PyObject *__pyx_pw_3nms_7gpu_nms_1gpu_nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1348. static PyMethodDef __pyx_mdef_3nms_7gpu_nms_1gpu_nms = {"gpu_nms", (PyCFunction)__pyx_pw_3nms_7gpu_nms_1gpu_nms, METH_VARARGS|METH_KEYWORDS, 0};
  1349. static PyObject *__pyx_pw_3nms_7gpu_nms_1gpu_nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1350. PyArrayObject *__pyx_v_dets = 0;
  1351. PyObject *__pyx_v_thresh = 0;
  1352. __pyx_t_5numpy_int32_t __pyx_v_device_id;
  1353. PyObject *__pyx_r = 0;
  1354. __Pyx_RefNannyDeclarations
  1355. __Pyx_RefNannySetupContext("gpu_nms (wrapper)", 0);
  1356. {
  1357. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dets,&__pyx_n_s_thresh,&__pyx_n_s_device_id,0};
  1358. PyObject* values[3] = {0,0,0};
  1359. if (unlikely(__pyx_kwds)) {
  1360. Py_ssize_t kw_args;
  1361. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1362. switch (pos_args) {
  1363. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1364. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1365. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1366. case 0: break;
  1367. default: goto __pyx_L5_argtuple_error;
  1368. }
  1369. kw_args = PyDict_Size(__pyx_kwds);
  1370. switch (pos_args) {
  1371. case 0:
  1372. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dets)) != 0)) kw_args--;
  1373. else goto __pyx_L5_argtuple_error;
  1374. case 1:
  1375. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_thresh)) != 0)) kw_args--;
  1376. else {
  1377. __Pyx_RaiseArgtupleInvalid("gpu_nms", 0, 2, 3, 1); __PYX_ERR(0, 16, __pyx_L3_error)
  1378. }
  1379. case 2:
  1380. if (kw_args > 0) {
  1381. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_device_id);
  1382. if (value) { values[2] = value; kw_args--; }
  1383. }
  1384. }
  1385. if (unlikely(kw_args > 0)) {
  1386. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gpu_nms") < 0)) __PYX_ERR(0, 16, __pyx_L3_error)
  1387. }
  1388. } else {
  1389. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1390. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1391. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1392. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1393. break;
  1394. default: goto __pyx_L5_argtuple_error;
  1395. }
  1396. }
  1397. __pyx_v_dets = ((PyArrayObject *)values[0]);
  1398. __pyx_v_thresh = ((PyObject*)values[1]);
  1399. if (values[2]) {
  1400. __pyx_v_device_id = __Pyx_PyInt_As_npy_int32(values[2]); if (unlikely((__pyx_v_device_id == (npy_int32)-1) && PyErr_Occurred())) __PYX_ERR(0, 17, __pyx_L3_error)
  1401. } else {
  1402. __pyx_v_device_id = ((__pyx_t_5numpy_int32_t)0);
  1403. }
  1404. }
  1405. goto __pyx_L4_argument_unpacking_done;
  1406. __pyx_L5_argtuple_error:;
  1407. __Pyx_RaiseArgtupleInvalid("gpu_nms", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 16, __pyx_L3_error)
  1408. __pyx_L3_error:;
  1409. __Pyx_AddTraceback("nms.gpu_nms.gpu_nms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1410. __Pyx_RefNannyFinishContext();
  1411. return NULL;
  1412. __pyx_L4_argument_unpacking_done:;
  1413. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dets), __pyx_ptype_5numpy_ndarray, 1, "dets", 0))) __PYX_ERR(0, 16, __pyx_L1_error)
  1414. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thresh), (&PyFloat_Type), 1, "thresh", 1))) __PYX_ERR(0, 16, __pyx_L1_error)
  1415. __pyx_r = __pyx_pf_3nms_7gpu_nms_gpu_nms(__pyx_self, __pyx_v_dets, __pyx_v_thresh, __pyx_v_device_id);
  1416. /* function exit code */
  1417. goto __pyx_L0;
  1418. __pyx_L1_error:;
  1419. __pyx_r = NULL;
  1420. __pyx_L0:;
  1421. __Pyx_RefNannyFinishContext();
  1422. return __pyx_r;
  1423. }
  1424. static PyObject *__pyx_pf_3nms_7gpu_nms_gpu_nms(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dets, PyObject *__pyx_v_thresh, __pyx_t_5numpy_int32_t __pyx_v_device_id) {
  1425. int __pyx_v_boxes_num;
  1426. int __pyx_v_boxes_dim;
  1427. int __pyx_v_num_out;
  1428. PyArrayObject *__pyx_v_keep = 0;
  1429. PyArrayObject *__pyx_v_scores = 0;
  1430. PyArrayObject *__pyx_v_order = 0;
  1431. PyArrayObject *__pyx_v_sorted_dets = 0;
  1432. __Pyx_LocalBuf_ND __pyx_pybuffernd_dets;
  1433. __Pyx_Buffer __pyx_pybuffer_dets;
  1434. __Pyx_LocalBuf_ND __pyx_pybuffernd_keep;
  1435. __Pyx_Buffer __pyx_pybuffer_keep;
  1436. __Pyx_LocalBuf_ND __pyx_pybuffernd_order;
  1437. __Pyx_Buffer __pyx_pybuffer_order;
  1438. __Pyx_LocalBuf_ND __pyx_pybuffernd_scores;
  1439. __Pyx_Buffer __pyx_pybuffer_scores;
  1440. __Pyx_LocalBuf_ND __pyx_pybuffernd_sorted_dets;
  1441. __Pyx_Buffer __pyx_pybuffer_sorted_dets;
  1442. PyObject *__pyx_r = NULL;
  1443. __Pyx_RefNannyDeclarations
  1444. PyObject *__pyx_t_1 = NULL;
  1445. PyObject *__pyx_t_2 = NULL;
  1446. PyObject *__pyx_t_3 = NULL;
  1447. PyObject *__pyx_t_4 = NULL;
  1448. PyObject *__pyx_t_5 = NULL;
  1449. PyArrayObject *__pyx_t_6 = NULL;
  1450. PyArrayObject *__pyx_t_7 = NULL;
  1451. PyArrayObject *__pyx_t_8 = NULL;
  1452. PyArrayObject *__pyx_t_9 = NULL;
  1453. Py_ssize_t __pyx_t_10;
  1454. int __pyx_t_11;
  1455. Py_ssize_t __pyx_t_12;
  1456. Py_ssize_t __pyx_t_13;
  1457. float __pyx_t_14;
  1458. PyObject *__pyx_t_15 = NULL;
  1459. PyObject *__pyx_t_16 = NULL;
  1460. PyObject *__pyx_t_17 = NULL;
  1461. __Pyx_RefNannySetupContext("gpu_nms", 0);
  1462. __pyx_pybuffer_keep.pybuffer.buf = NULL;
  1463. __pyx_pybuffer_keep.refcount = 0;
  1464. __pyx_pybuffernd_keep.data = NULL;
  1465. __pyx_pybuffernd_keep.rcbuffer = &__pyx_pybuffer_keep;
  1466. __pyx_pybuffer_scores.pybuffer.buf = NULL;
  1467. __pyx_pybuffer_scores.refcount = 0;
  1468. __pyx_pybuffernd_scores.data = NULL;
  1469. __pyx_pybuffernd_scores.rcbuffer = &__pyx_pybuffer_scores;
  1470. __pyx_pybuffer_order.pybuffer.buf = NULL;
  1471. __pyx_pybuffer_order.refcount = 0;
  1472. __pyx_pybuffernd_order.data = NULL;
  1473. __pyx_pybuffernd_order.rcbuffer = &__pyx_pybuffer_order;
  1474. __pyx_pybuffer_sorted_dets.pybuffer.buf = NULL;
  1475. __pyx_pybuffer_sorted_dets.refcount = 0;
  1476. __pyx_pybuffernd_sorted_dets.data = NULL;
  1477. __pyx_pybuffernd_sorted_dets.rcbuffer = &__pyx_pybuffer_sorted_dets;
  1478. __pyx_pybuffer_dets.pybuffer.buf = NULL;
  1479. __pyx_pybuffer_dets.refcount = 0;
  1480. __pyx_pybuffernd_dets.data = NULL;
  1481. __pyx_pybuffernd_dets.rcbuffer = &__pyx_pybuffer_dets;
  1482. {
  1483. __Pyx_BufFmt_StackElem __pyx_stack[1];
  1484. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dets.rcbuffer->pybuffer, (PyObject*)__pyx_v_dets, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 16, __pyx_L1_error)
  1485. }
  1486. __pyx_pybuffernd_dets.diminfo[0].strides = __pyx_pybuffernd_dets.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dets.diminfo[0].shape = __pyx_pybuffernd_dets.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dets.diminfo[1].strides = __pyx_pybuffernd_dets.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dets.diminfo[1].shape = __pyx_pybuffernd_dets.rcbuffer->pybuffer.shape[1];
  1487. /* "nms/gpu_nms.pyx":18
  1488. * def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh,
  1489. * np.int32_t device_id=0):
  1490. * cdef int boxes_num = dets.shape[0] # <<<<<<<<<<<<<<
  1491. * cdef int boxes_dim = dets.shape[1]
  1492. * cdef int num_out
  1493. */
  1494. __pyx_v_boxes_num = (__pyx_v_dets->dimensions[0]);
  1495. /* "nms/gpu_nms.pyx":19
  1496. * np.int32_t device_id=0):
  1497. * cdef int boxes_num = dets.shape[0]
  1498. * cdef int boxes_dim = dets.shape[1] # <<<<<<<<<<<<<<
  1499. * cdef int num_out
  1500. * cdef np.ndarray[np.int32_t, ndim=1] \
  1501. */
  1502. __pyx_v_boxes_dim = (__pyx_v_dets->dimensions[1]);
  1503. /* "nms/gpu_nms.pyx":22
  1504. * cdef int num_out
  1505. * cdef np.ndarray[np.int32_t, ndim=1] \
  1506. * keep = np.zeros(boxes_num, dtype=np.int32) # <<<<<<<<<<<<<<
  1507. * cdef np.ndarray[np.float32_t, ndim=1] \
  1508. * scores = dets[:, 4]
  1509. */
  1510. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  1511. __Pyx_GOTREF(__pyx_t_1);
  1512. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
  1513. __Pyx_GOTREF(__pyx_t_2);
  1514. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1515. __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_boxes_num); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  1516. __Pyx_GOTREF(__pyx_t_1);
  1517. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
  1518. __Pyx_GOTREF(__pyx_t_3);
  1519. __Pyx_GIVEREF(__pyx_t_1);
  1520. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  1521. __pyx_t_1 = 0;
  1522. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  1523. __Pyx_GOTREF(__pyx_t_1);
  1524. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 22, __pyx_L1_error)
  1525. __Pyx_GOTREF(__pyx_t_4);
  1526. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 22, __pyx_L1_error)
  1527. __Pyx_GOTREF(__pyx_t_5);
  1528. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1529. if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
  1530. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1531. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 22, __pyx_L1_error)
  1532. __Pyx_GOTREF(__pyx_t_5);
  1533. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1534. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1535. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1536. if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 22, __pyx_L1_error)
  1537. __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  1538. {
  1539. __Pyx_BufFmt_StackElem __pyx_stack[1];
  1540. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_keep.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
  1541. __pyx_v_keep = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_keep.rcbuffer->pybuffer.buf = NULL;
  1542. __PYX_ERR(0, 21, __pyx_L1_error)
  1543. } else {__pyx_pybuffernd_keep.diminfo[0].strides = __pyx_pybuffernd_keep.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_keep.diminfo[0].shape = __pyx_pybuffernd_keep.rcbuffer->pybuffer.shape[0];
  1544. }
  1545. }
  1546. __pyx_t_6 = 0;
  1547. __pyx_v_keep = ((PyArrayObject *)__pyx_t_5);
  1548. __pyx_t_5 = 0;
  1549. /* "nms/gpu_nms.pyx":24
  1550. * keep = np.zeros(boxes_num, dtype=np.int32)
  1551. * cdef np.ndarray[np.float32_t, ndim=1] \
  1552. * scores = dets[:, 4] # <<<<<<<<<<<<<<
  1553. * #cdef np.ndarray[np.int_t, ndim=1] \ // 20160601, by xzn
  1554. * # order = scores.argsort()[::-1]
  1555. */
  1556. __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 24, __pyx_L1_error)
  1557. __Pyx_GOTREF(__pyx_t_5);
  1558. if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 24, __pyx_L1_error)
  1559. __pyx_t_7 = ((PyArrayObject *)__pyx_t_5);
  1560. {
  1561. __Pyx_BufFmt_StackElem __pyx_stack[1];
  1562. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
  1563. __pyx_v_scores = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_scores.rcbuffer->pybuffer.buf = NULL;
  1564. __PYX_ERR(0, 23, __pyx_L1_error)
  1565. } else {__pyx_pybuffernd_scores.diminfo[0].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_scores.diminfo[0].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[0];
  1566. }
  1567. }
  1568. __pyx_t_7 = 0;
  1569. __pyx_v_scores = ((PyArrayObject *)__pyx_t_5);
  1570. __pyx_t_5 = 0;
  1571. /* "nms/gpu_nms.pyx":28
  1572. * # order = scores.argsort()[::-1]
  1573. * cdef np.ndarray[np.intp_t, ndim=1] \
  1574. * order = scores.argsort()[::-1] # <<<<<<<<<<<<<<
  1575. * cdef np.ndarray[np.float32_t, ndim=2] \
  1576. * sorted_dets = dets[order, :]
  1577. */
  1578. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_scores), __pyx_n_s_argsort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
  1579. __Pyx_GOTREF(__pyx_t_1);
  1580. __pyx_t_3 = NULL;
  1581. if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
  1582. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
  1583. if (likely(__pyx_t_3)) {
  1584. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  1585. __Pyx_INCREF(__pyx_t_3);
  1586. __Pyx_INCREF(function);
  1587. __Pyx_DECREF_SET(__pyx_t_1, function);
  1588. }
  1589. }
  1590. if (__pyx_t_3) {
  1591. __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 28, __pyx_L1_error)
  1592. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1593. } else {
  1594. __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 28, __pyx_L1_error)
  1595. }
  1596. __Pyx_GOTREF(__pyx_t_5);
  1597. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1598. __pyx_t_1 = PyObject_GetItem(__pyx_t_5, __pyx_slice__3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
  1599. __Pyx_GOTREF(__pyx_t_1);
  1600. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1601. if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 28, __pyx_L1_error)
  1602. __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  1603. {
  1604. __Pyx_BufFmt_StackElem __pyx_stack[1];
  1605. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_intp_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
  1606. __pyx_v_order = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_order.rcbuffer->pybuffer.buf = NULL;
  1607. __PYX_ERR(0, 27, __pyx_L1_error)
  1608. } else {__pyx_pybuffernd_order.diminfo[0].strides = __pyx_pybuffernd_order.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_order.diminfo[0].shape = __pyx_pybuffernd_order.rcbuffer->pybuffer.shape[0];
  1609. }
  1610. }
  1611. __pyx_t_8 = 0;
  1612. __pyx_v_order = ((PyArrayObject *)__pyx_t_1);
  1613. __pyx_t_1 = 0;
  1614. /* "nms/gpu_nms.pyx":30
  1615. * order = scores.argsort()[::-1]
  1616. * cdef np.ndarray[np.float32_t, ndim=2] \
  1617. * sorted_dets = dets[order, :] # <<<<<<<<<<<<<<
  1618. * _nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id)
  1619. * keep = keep[:num_out]
  1620. */
  1621. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
  1622. __Pyx_GOTREF(__pyx_t_1);
  1623. __Pyx_INCREF(((PyObject *)__pyx_v_order));
  1624. __Pyx_GIVEREF(((PyObject *)__pyx_v_order));
  1625. PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_order));
  1626. __Pyx_INCREF(__pyx_slice__4);
  1627. __Pyx_GIVEREF(__pyx_slice__4);
  1628. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__4);
  1629. __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
  1630. __Pyx_GOTREF(__pyx_t_5);
  1631. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1632. if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 30, __pyx_L1_error)
  1633. __pyx_t_9 = ((PyArrayObject *)__pyx_t_5);
  1634. {
  1635. __Pyx_BufFmt_StackElem __pyx_stack[1];
  1636. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
  1637. __pyx_v_sorted_dets = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer.buf = NULL;
  1638. __PYX_ERR(0, 29, __pyx_L1_error)
  1639. } else {__pyx_pybuffernd_sorted_dets.diminfo[0].strides = __pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sorted_dets.diminfo[0].shape = __pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sorted_dets.diminfo[1].strides = __pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sorted_dets.diminfo[1].shape = __pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer.shape[1];
  1640. }
  1641. }
  1642. __pyx_t_9 = 0;
  1643. __pyx_v_sorted_dets = ((PyArrayObject *)__pyx_t_5);
  1644. __pyx_t_5 = 0;
  1645. /* "nms/gpu_nms.pyx":31
  1646. * cdef np.ndarray[np.float32_t, ndim=2] \
  1647. * sorted_dets = dets[order, :]
  1648. * _nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id) # <<<<<<<<<<<<<<
  1649. * keep = keep[:num_out]
  1650. * return list(order[keep])
  1651. */
  1652. __pyx_t_10 = 0;
  1653. __pyx_t_11 = -1;
  1654. if (__pyx_t_10 < 0) {
  1655. __pyx_t_10 += __pyx_pybuffernd_keep.diminfo[0].shape;
  1656. if (unlikely(__pyx_t_10 < 0)) __pyx_t_11 = 0;
  1657. } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_keep.diminfo[0].shape)) __pyx_t_11 = 0;
  1658. if (unlikely(__pyx_t_11 != -1)) {
  1659. __Pyx_RaiseBufferIndexError(__pyx_t_11);
  1660. __PYX_ERR(0, 31, __pyx_L1_error)
  1661. }
  1662. __pyx_t_12 = 0;
  1663. __pyx_t_13 = 0;
  1664. __pyx_t_11 = -1;
  1665. if (__pyx_t_12 < 0) {
  1666. __pyx_t_12 += __pyx_pybuffernd_sorted_dets.diminfo[0].shape;
  1667. if (unlikely(__pyx_t_12 < 0)) __pyx_t_11 = 0;
  1668. } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_sorted_dets.diminfo[0].shape)) __pyx_t_11 = 0;
  1669. if (__pyx_t_13 < 0) {
  1670. __pyx_t_13 += __pyx_pybuffernd_sorted_dets.diminfo[1].shape;
  1671. if (unlikely(__pyx_t_13 < 0)) __pyx_t_11 = 1;
  1672. } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_sorted_dets.diminfo[1].shape)) __pyx_t_11 = 1;
  1673. if (unlikely(__pyx_t_11 != -1)) {
  1674. __Pyx_RaiseBufferIndexError(__pyx_t_11);
  1675. __PYX_ERR(0, 31, __pyx_L1_error)
  1676. }
  1677. __pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_v_thresh); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 31, __pyx_L1_error)
  1678. _nms((&(*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_keep.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_keep.diminfo[0].strides))), (&__pyx_v_num_out), (&(*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_sorted_dets.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_sorted_dets.diminfo[1].strides))), __pyx_v_boxes_num, __pyx_v_boxes_dim, __pyx_t_14, __pyx_v_device_id);
  1679. /* "nms/gpu_nms.pyx":32
  1680. * sorted_dets = dets[order, :]
  1681. * _nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id)
  1682. * keep = keep[:num_out] # <<<<<<<<<<<<<<
  1683. * return list(order[keep])
  1684. */
  1685. __pyx_t_5 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_keep), 0, __pyx_v_num_out, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error)
  1686. __Pyx_GOTREF(__pyx_t_5);
  1687. if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 32, __pyx_L1_error)
  1688. __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  1689. {
  1690. __Pyx_BufFmt_StackElem __pyx_stack[1];
  1691. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_keep.rcbuffer->pybuffer);
  1692. __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_keep.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
  1693. if (unlikely(__pyx_t_11 < 0)) {
  1694. PyErr_Fetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
  1695. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_keep.rcbuffer->pybuffer, (PyObject*)__pyx_v_keep, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
  1696. Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17);
  1697. __Pyx_RaiseBufferFallbackError();
  1698. } else {
  1699. PyErr_Restore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
  1700. }
  1701. }
  1702. __pyx_pybuffernd_keep.diminfo[0].strides = __pyx_pybuffernd_keep.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_keep.diminfo[0].shape = __pyx_pybuffernd_keep.rcbuffer->pybuffer.shape[0];
  1703. if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 32, __pyx_L1_error)
  1704. }
  1705. __pyx_t_6 = 0;
  1706. __Pyx_DECREF_SET(__pyx_v_keep, ((PyArrayObject *)__pyx_t_5));
  1707. __pyx_t_5 = 0;
  1708. /* "nms/gpu_nms.pyx":33
  1709. * _nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id)
  1710. * keep = keep[:num_out]
  1711. * return list(order[keep]) # <<<<<<<<<<<<<<
  1712. */
  1713. __Pyx_XDECREF(__pyx_r);
  1714. __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_order), ((PyObject *)__pyx_v_keep)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 33, __pyx_L1_error)
  1715. __Pyx_GOTREF(__pyx_t_5);
  1716. __pyx_t_1 = PySequence_List(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  1717. __Pyx_GOTREF(__pyx_t_1);
  1718. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1719. __pyx_r = __pyx_t_1;
  1720. __pyx_t_1 = 0;
  1721. goto __pyx_L0;
  1722. /* "nms/gpu_nms.pyx":16
  1723. * void _nms(np.int32_t*, int*, np.float32_t*, int, int, float, int)
  1724. *
  1725. * def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh, # <<<<<<<<<<<<<<
  1726. * np.int32_t device_id=0):
  1727. * cdef int boxes_num = dets.shape[0]
  1728. */
  1729. /* function exit code */
  1730. __pyx_L1_error:;
  1731. __Pyx_XDECREF(__pyx_t_1);
  1732. __Pyx_XDECREF(__pyx_t_2);
  1733. __Pyx_XDECREF(__pyx_t_3);
  1734. __Pyx_XDECREF(__pyx_t_4);
  1735. __Pyx_XDECREF(__pyx_t_5);
  1736. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  1737. __Pyx_PyThreadState_declare
  1738. __Pyx_PyThreadState_assign
  1739. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  1740. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dets.rcbuffer->pybuffer);
  1741. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_keep.rcbuffer->pybuffer);
  1742. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer);
  1743. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  1744. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer);
  1745. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  1746. __Pyx_AddTraceback("nms.gpu_nms.gpu_nms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1747. __pyx_r = NULL;
  1748. goto __pyx_L2;
  1749. __pyx_L0:;
  1750. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dets.rcbuffer->pybuffer);
  1751. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_keep.rcbuffer->pybuffer);
  1752. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer);
  1753. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  1754. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sorted_dets.rcbuffer->pybuffer);
  1755. __pyx_L2:;
  1756. __Pyx_XDECREF((PyObject *)__pyx_v_keep);
  1757. __Pyx_XDECREF((PyObject *)__pyx_v_scores);
  1758. __Pyx_XDECREF((PyObject *)__pyx_v_order);
  1759. __Pyx_XDECREF((PyObject *)__pyx_v_sorted_dets);
  1760. __Pyx_XGIVEREF(__pyx_r);
  1761. __Pyx_RefNannyFinishContext();
  1762. return __pyx_r;
  1763. }
  1764. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":197
  1765. * # experimental exception made for __getbuffer__ and __releasebuffer__
  1766. * # -- the details of this may change.
  1767. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
  1768. * # This implementation of getbuffer is geared towards Cython
  1769. * # requirements, and does not yet fullfill the PEP.
  1770. */
  1771. /* Python wrapper */
  1772. static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
  1773. static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  1774. int __pyx_r;
  1775. __Pyx_RefNannyDeclarations
  1776. __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  1777. __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
  1778. /* function exit code */
  1779. __Pyx_RefNannyFinishContext();
  1780. return __pyx_r;
  1781. }
  1782. static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  1783. int __pyx_v_copy_shape;
  1784. int __pyx_v_i;
  1785. int __pyx_v_ndim;
  1786. int __pyx_v_endian_detector;
  1787. int __pyx_v_little_endian;
  1788. int __pyx_v_t;
  1789. char *__pyx_v_f;
  1790. PyArray_Descr *__pyx_v_descr = 0;
  1791. int __pyx_v_offset;
  1792. int __pyx_v_hasfields;
  1793. int __pyx_r;
  1794. __Pyx_RefNannyDeclarations
  1795. int __pyx_t_1;
  1796. int __pyx_t_2;
  1797. PyObject *__pyx_t_3 = NULL;
  1798. int __pyx_t_4;
  1799. int __pyx_t_5;
  1800. PyObject *__pyx_t_6 = NULL;
  1801. char *__pyx_t_7;
  1802. __Pyx_RefNannySetupContext("__getbuffer__", 0);
  1803. if (__pyx_v_info != NULL) {
  1804. __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
  1805. __Pyx_GIVEREF(__pyx_v_info->obj);
  1806. }
  1807. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":203
  1808. * # of flags
  1809. *
  1810. * if info == NULL: return # <<<<<<<<<<<<<<
  1811. *
  1812. * cdef int copy_shape, i, ndim
  1813. */
  1814. __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
  1815. if (__pyx_t_1) {
  1816. __pyx_r = 0;
  1817. goto __pyx_L0;
  1818. }
  1819. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":206
  1820. *
  1821. * cdef int copy_shape, i, ndim
  1822. * cdef int endian_detector = 1 # <<<<<<<<<<<<<<
  1823. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
  1824. *
  1825. */
  1826. __pyx_v_endian_detector = 1;
  1827. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":207
  1828. * cdef int copy_shape, i, ndim
  1829. * cdef int endian_detector = 1
  1830. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<<
  1831. *
  1832. * ndim = PyArray_NDIM(self)
  1833. */
  1834. __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
  1835. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":209
  1836. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
  1837. *
  1838. * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<<
  1839. *
  1840. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  1841. */
  1842. __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);
  1843. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":211
  1844. * ndim = PyArray_NDIM(self)
  1845. *
  1846. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  1847. * copy_shape = 1
  1848. * else:
  1849. */
  1850. __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  1851. if (__pyx_t_1) {
  1852. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":212
  1853. *
  1854. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  1855. * copy_shape = 1 # <<<<<<<<<<<<<<
  1856. * else:
  1857. * copy_shape = 0
  1858. */
  1859. __pyx_v_copy_shape = 1;
  1860. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":211
  1861. * ndim = PyArray_NDIM(self)
  1862. *
  1863. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  1864. * copy_shape = 1
  1865. * else:
  1866. */
  1867. goto __pyx_L4;
  1868. }
  1869. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":214
  1870. * copy_shape = 1
  1871. * else:
  1872. * copy_shape = 0 # <<<<<<<<<<<<<<
  1873. *
  1874. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  1875. */
  1876. /*else*/ {
  1877. __pyx_v_copy_shape = 0;
  1878. }
  1879. __pyx_L4:;
  1880. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":216
  1881. * copy_shape = 0
  1882. *
  1883. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
  1884. * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  1885. * raise ValueError(u"ndarray is not C contiguous")
  1886. */
  1887. __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  1888. if (__pyx_t_2) {
  1889. } else {
  1890. __pyx_t_1 = __pyx_t_2;
  1891. goto __pyx_L6_bool_binop_done;
  1892. }
  1893. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":217
  1894. *
  1895. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  1896. * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<<
  1897. * raise ValueError(u"ndarray is not C contiguous")
  1898. *
  1899. */
  1900. __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
  1901. __pyx_t_1 = __pyx_t_2;
  1902. __pyx_L6_bool_binop_done:;
  1903. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":216
  1904. * copy_shape = 0
  1905. *
  1906. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
  1907. * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  1908. * raise ValueError(u"ndarray is not C contiguous")
  1909. */
  1910. if (__pyx_t_1) {
  1911. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":218
  1912. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  1913. * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  1914. * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<<
  1915. *
  1916. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  1917. */
  1918. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error)
  1919. __Pyx_GOTREF(__pyx_t_3);
  1920. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  1921. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1922. __PYX_ERR(1, 218, __pyx_L1_error)
  1923. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":216
  1924. * copy_shape = 0
  1925. *
  1926. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
  1927. * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  1928. * raise ValueError(u"ndarray is not C contiguous")
  1929. */
  1930. }
  1931. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":220
  1932. * raise ValueError(u"ndarray is not C contiguous")
  1933. *
  1934. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
  1935. * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  1936. * raise ValueError(u"ndarray is not Fortran contiguous")
  1937. */
  1938. __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  1939. if (__pyx_t_2) {
  1940. } else {
  1941. __pyx_t_1 = __pyx_t_2;
  1942. goto __pyx_L9_bool_binop_done;
  1943. }
  1944. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":221
  1945. *
  1946. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  1947. * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<<
  1948. * raise ValueError(u"ndarray is not Fortran contiguous")
  1949. *
  1950. */
  1951. __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
  1952. __pyx_t_1 = __pyx_t_2;
  1953. __pyx_L9_bool_binop_done:;
  1954. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":220
  1955. * raise ValueError(u"ndarray is not C contiguous")
  1956. *
  1957. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
  1958. * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  1959. * raise ValueError(u"ndarray is not Fortran contiguous")
  1960. */
  1961. if (__pyx_t_1) {
  1962. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":222
  1963. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  1964. * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  1965. * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<<
  1966. *
  1967. * info.buf = PyArray_DATA(self)
  1968. */
  1969. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error)
  1970. __Pyx_GOTREF(__pyx_t_3);
  1971. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  1972. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1973. __PYX_ERR(1, 222, __pyx_L1_error)
  1974. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":220
  1975. * raise ValueError(u"ndarray is not C contiguous")
  1976. *
  1977. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
  1978. * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  1979. * raise ValueError(u"ndarray is not Fortran contiguous")
  1980. */
  1981. }
  1982. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":224
  1983. * raise ValueError(u"ndarray is not Fortran contiguous")
  1984. *
  1985. * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<<
  1986. * info.ndim = ndim
  1987. * if copy_shape:
  1988. */
  1989. __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);
  1990. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":225
  1991. *
  1992. * info.buf = PyArray_DATA(self)
  1993. * info.ndim = ndim # <<<<<<<<<<<<<<
  1994. * if copy_shape:
  1995. * # Allocate new buffer for strides and shape info.
  1996. */
  1997. __pyx_v_info->ndim = __pyx_v_ndim;
  1998. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":226
  1999. * info.buf = PyArray_DATA(self)
  2000. * info.ndim = ndim
  2001. * if copy_shape: # <<<<<<<<<<<<<<
  2002. * # Allocate new buffer for strides and shape info.
  2003. * # This is allocated as one block, strides first.
  2004. */
  2005. __pyx_t_1 = (__pyx_v_copy_shape != 0);
  2006. if (__pyx_t_1) {
  2007. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":229
  2008. * # Allocate new buffer for strides and shape info.
  2009. * # This is allocated as one block, strides first.
  2010. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2) # <<<<<<<<<<<<<<
  2011. * info.shape = info.strides + ndim
  2012. * for i in range(ndim):
  2013. */
  2014. __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));
  2015. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":230
  2016. * # This is allocated as one block, strides first.
  2017. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
  2018. * info.shape = info.strides + ndim # <<<<<<<<<<<<<<
  2019. * for i in range(ndim):
  2020. * info.strides[i] = PyArray_STRIDES(self)[i]
  2021. */
  2022. __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);
  2023. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":231
  2024. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
  2025. * info.shape = info.strides + ndim
  2026. * for i in range(ndim): # <<<<<<<<<<<<<<
  2027. * info.strides[i] = PyArray_STRIDES(self)[i]
  2028. * info.shape[i] = PyArray_DIMS(self)[i]
  2029. */
  2030. __pyx_t_4 = __pyx_v_ndim;
  2031. for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
  2032. __pyx_v_i = __pyx_t_5;
  2033. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":232
  2034. * info.shape = info.strides + ndim
  2035. * for i in range(ndim):
  2036. * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<<
  2037. * info.shape[i] = PyArray_DIMS(self)[i]
  2038. * else:
  2039. */
  2040. (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);
  2041. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":233
  2042. * for i in range(ndim):
  2043. * info.strides[i] = PyArray_STRIDES(self)[i]
  2044. * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<<
  2045. * else:
  2046. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  2047. */
  2048. (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
  2049. }
  2050. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":226
  2051. * info.buf = PyArray_DATA(self)
  2052. * info.ndim = ndim
  2053. * if copy_shape: # <<<<<<<<<<<<<<
  2054. * # Allocate new buffer for strides and shape info.
  2055. * # This is allocated as one block, strides first.
  2056. */
  2057. goto __pyx_L11;
  2058. }
  2059. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":235
  2060. * info.shape[i] = PyArray_DIMS(self)[i]
  2061. * else:
  2062. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) # <<<<<<<<<<<<<<
  2063. * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  2064. * info.suboffsets = NULL
  2065. */
  2066. /*else*/ {
  2067. __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));
  2068. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":236
  2069. * else:
  2070. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  2071. * info.shape = <Py_ssize_t*>PyArray_DIMS(self) # <<<<<<<<<<<<<<
  2072. * info.suboffsets = NULL
  2073. * info.itemsize = PyArray_ITEMSIZE(self)
  2074. */
  2075. __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  2076. }
  2077. __pyx_L11:;
  2078. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":237
  2079. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  2080. * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  2081. * info.suboffsets = NULL # <<<<<<<<<<<<<<
  2082. * info.itemsize = PyArray_ITEMSIZE(self)
  2083. * info.readonly = not PyArray_ISWRITEABLE(self)
  2084. */
  2085. __pyx_v_info->suboffsets = NULL;
  2086. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":238
  2087. * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  2088. * info.suboffsets = NULL
  2089. * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<<
  2090. * info.readonly = not PyArray_ISWRITEABLE(self)
  2091. *
  2092. */
  2093. __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);
  2094. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":239
  2095. * info.suboffsets = NULL
  2096. * info.itemsize = PyArray_ITEMSIZE(self)
  2097. * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<<
  2098. *
  2099. * cdef int t
  2100. */
  2101. __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));
  2102. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":242
  2103. *
  2104. * cdef int t
  2105. * cdef char* f = NULL # <<<<<<<<<<<<<<
  2106. * cdef dtype descr = self.descr
  2107. * cdef int offset
  2108. */
  2109. __pyx_v_f = NULL;
  2110. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":243
  2111. * cdef int t
  2112. * cdef char* f = NULL
  2113. * cdef dtype descr = self.descr # <<<<<<<<<<<<<<
  2114. * cdef int offset
  2115. *
  2116. */
  2117. __pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
  2118. __Pyx_INCREF(__pyx_t_3);
  2119. __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
  2120. __pyx_t_3 = 0;
  2121. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":246
  2122. * cdef int offset
  2123. *
  2124. * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<<
  2125. *
  2126. * if not hasfields and not copy_shape:
  2127. */
  2128. __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);
  2129. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":248
  2130. * cdef bint hasfields = PyDataType_HASFIELDS(descr)
  2131. *
  2132. * if not hasfields and not copy_shape: # <<<<<<<<<<<<<<
  2133. * # do not call releasebuffer
  2134. * info.obj = None
  2135. */
  2136. __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
  2137. if (__pyx_t_2) {
  2138. } else {
  2139. __pyx_t_1 = __pyx_t_2;
  2140. goto __pyx_L15_bool_binop_done;
  2141. }
  2142. __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0);
  2143. __pyx_t_1 = __pyx_t_2;
  2144. __pyx_L15_bool_binop_done:;
  2145. if (__pyx_t_1) {
  2146. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":250
  2147. * if not hasfields and not copy_shape:
  2148. * # do not call releasebuffer
  2149. * info.obj = None # <<<<<<<<<<<<<<
  2150. * else:
  2151. * # need to call releasebuffer
  2152. */
  2153. __Pyx_INCREF(Py_None);
  2154. __Pyx_GIVEREF(Py_None);
  2155. __Pyx_GOTREF(__pyx_v_info->obj);
  2156. __Pyx_DECREF(__pyx_v_info->obj);
  2157. __pyx_v_info->obj = Py_None;
  2158. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":248
  2159. * cdef bint hasfields = PyDataType_HASFIELDS(descr)
  2160. *
  2161. * if not hasfields and not copy_shape: # <<<<<<<<<<<<<<
  2162. * # do not call releasebuffer
  2163. * info.obj = None
  2164. */
  2165. goto __pyx_L14;
  2166. }
  2167. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":253
  2168. * else:
  2169. * # need to call releasebuffer
  2170. * info.obj = self # <<<<<<<<<<<<<<
  2171. *
  2172. * if not hasfields:
  2173. */
  2174. /*else*/ {
  2175. __Pyx_INCREF(((PyObject *)__pyx_v_self));
  2176. __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  2177. __Pyx_GOTREF(__pyx_v_info->obj);
  2178. __Pyx_DECREF(__pyx_v_info->obj);
  2179. __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
  2180. }
  2181. __pyx_L14:;
  2182. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":255
  2183. * info.obj = self
  2184. *
  2185. * if not hasfields: # <<<<<<<<<<<<<<
  2186. * t = descr.type_num
  2187. * if ((descr.byteorder == c'>' and little_endian) or
  2188. */
  2189. __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
  2190. if (__pyx_t_1) {
  2191. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":256
  2192. *
  2193. * if not hasfields:
  2194. * t = descr.type_num # <<<<<<<<<<<<<<
  2195. * if ((descr.byteorder == c'>' and little_endian) or
  2196. * (descr.byteorder == c'<' and not little_endian)):
  2197. */
  2198. __pyx_t_4 = __pyx_v_descr->type_num;
  2199. __pyx_v_t = __pyx_t_4;
  2200. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":257
  2201. * if not hasfields:
  2202. * t = descr.type_num
  2203. * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  2204. * (descr.byteorder == c'<' and not little_endian)):
  2205. * raise ValueError(u"Non-native byte order not supported")
  2206. */
  2207. __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
  2208. if (!__pyx_t_2) {
  2209. goto __pyx_L20_next_or;
  2210. } else {
  2211. }
  2212. __pyx_t_2 = (__pyx_v_little_endian != 0);
  2213. if (!__pyx_t_2) {
  2214. } else {
  2215. __pyx_t_1 = __pyx_t_2;
  2216. goto __pyx_L19_bool_binop_done;
  2217. }
  2218. __pyx_L20_next_or:;
  2219. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":258
  2220. * t = descr.type_num
  2221. * if ((descr.byteorder == c'>' and little_endian) or
  2222. * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<<
  2223. * raise ValueError(u"Non-native byte order not supported")
  2224. * if t == NPY_BYTE: f = "b"
  2225. */
  2226. __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
  2227. if (__pyx_t_2) {
  2228. } else {
  2229. __pyx_t_1 = __pyx_t_2;
  2230. goto __pyx_L19_bool_binop_done;
  2231. }
  2232. __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
  2233. __pyx_t_1 = __pyx_t_2;
  2234. __pyx_L19_bool_binop_done:;
  2235. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":257
  2236. * if not hasfields:
  2237. * t = descr.type_num
  2238. * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  2239. * (descr.byteorder == c'<' and not little_endian)):
  2240. * raise ValueError(u"Non-native byte order not supported")
  2241. */
  2242. if (__pyx_t_1) {
  2243. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":259
  2244. * if ((descr.byteorder == c'>' and little_endian) or
  2245. * (descr.byteorder == c'<' and not little_endian)):
  2246. * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
  2247. * if t == NPY_BYTE: f = "b"
  2248. * elif t == NPY_UBYTE: f = "B"
  2249. */
  2250. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error)
  2251. __Pyx_GOTREF(__pyx_t_3);
  2252. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  2253. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2254. __PYX_ERR(1, 259, __pyx_L1_error)
  2255. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":257
  2256. * if not hasfields:
  2257. * t = descr.type_num
  2258. * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  2259. * (descr.byteorder == c'<' and not little_endian)):
  2260. * raise ValueError(u"Non-native byte order not supported")
  2261. */
  2262. }
  2263. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":260
  2264. * (descr.byteorder == c'<' and not little_endian)):
  2265. * raise ValueError(u"Non-native byte order not supported")
  2266. * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<<
  2267. * elif t == NPY_UBYTE: f = "B"
  2268. * elif t == NPY_SHORT: f = "h"
  2269. */
  2270. switch (__pyx_v_t) {
  2271. case NPY_BYTE:
  2272. __pyx_v_f = ((char *)"b");
  2273. break;
  2274. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":261
  2275. * raise ValueError(u"Non-native byte order not supported")
  2276. * if t == NPY_BYTE: f = "b"
  2277. * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<<
  2278. * elif t == NPY_SHORT: f = "h"
  2279. * elif t == NPY_USHORT: f = "H"
  2280. */
  2281. case NPY_UBYTE:
  2282. __pyx_v_f = ((char *)"B");
  2283. break;
  2284. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":262
  2285. * if t == NPY_BYTE: f = "b"
  2286. * elif t == NPY_UBYTE: f = "B"
  2287. * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<<
  2288. * elif t == NPY_USHORT: f = "H"
  2289. * elif t == NPY_INT: f = "i"
  2290. */
  2291. case NPY_SHORT:
  2292. __pyx_v_f = ((char *)"h");
  2293. break;
  2294. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":263
  2295. * elif t == NPY_UBYTE: f = "B"
  2296. * elif t == NPY_SHORT: f = "h"
  2297. * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<<
  2298. * elif t == NPY_INT: f = "i"
  2299. * elif t == NPY_UINT: f = "I"
  2300. */
  2301. case NPY_USHORT:
  2302. __pyx_v_f = ((char *)"H");
  2303. break;
  2304. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":264
  2305. * elif t == NPY_SHORT: f = "h"
  2306. * elif t == NPY_USHORT: f = "H"
  2307. * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<<
  2308. * elif t == NPY_UINT: f = "I"
  2309. * elif t == NPY_LONG: f = "l"
  2310. */
  2311. case NPY_INT:
  2312. __pyx_v_f = ((char *)"i");
  2313. break;
  2314. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":265
  2315. * elif t == NPY_USHORT: f = "H"
  2316. * elif t == NPY_INT: f = "i"
  2317. * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<<
  2318. * elif t == NPY_LONG: f = "l"
  2319. * elif t == NPY_ULONG: f = "L"
  2320. */
  2321. case NPY_UINT:
  2322. __pyx_v_f = ((char *)"I");
  2323. break;
  2324. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":266
  2325. * elif t == NPY_INT: f = "i"
  2326. * elif t == NPY_UINT: f = "I"
  2327. * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<<
  2328. * elif t == NPY_ULONG: f = "L"
  2329. * elif t == NPY_LONGLONG: f = "q"
  2330. */
  2331. case NPY_LONG:
  2332. __pyx_v_f = ((char *)"l");
  2333. break;
  2334. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":267
  2335. * elif t == NPY_UINT: f = "I"
  2336. * elif t == NPY_LONG: f = "l"
  2337. * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<<
  2338. * elif t == NPY_LONGLONG: f = "q"
  2339. * elif t == NPY_ULONGLONG: f = "Q"
  2340. */
  2341. case NPY_ULONG:
  2342. __pyx_v_f = ((char *)"L");
  2343. break;
  2344. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":268
  2345. * elif t == NPY_LONG: f = "l"
  2346. * elif t == NPY_ULONG: f = "L"
  2347. * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<<
  2348. * elif t == NPY_ULONGLONG: f = "Q"
  2349. * elif t == NPY_FLOAT: f = "f"
  2350. */
  2351. case NPY_LONGLONG:
  2352. __pyx_v_f = ((char *)"q");
  2353. break;
  2354. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":269
  2355. * elif t == NPY_ULONG: f = "L"
  2356. * elif t == NPY_LONGLONG: f = "q"
  2357. * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<<
  2358. * elif t == NPY_FLOAT: f = "f"
  2359. * elif t == NPY_DOUBLE: f = "d"
  2360. */
  2361. case NPY_ULONGLONG:
  2362. __pyx_v_f = ((char *)"Q");
  2363. break;
  2364. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270
  2365. * elif t == NPY_LONGLONG: f = "q"
  2366. * elif t == NPY_ULONGLONG: f = "Q"
  2367. * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<<
  2368. * elif t == NPY_DOUBLE: f = "d"
  2369. * elif t == NPY_LONGDOUBLE: f = "g"
  2370. */
  2371. case NPY_FLOAT:
  2372. __pyx_v_f = ((char *)"f");
  2373. break;
  2374. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":271
  2375. * elif t == NPY_ULONGLONG: f = "Q"
  2376. * elif t == NPY_FLOAT: f = "f"
  2377. * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<<
  2378. * elif t == NPY_LONGDOUBLE: f = "g"
  2379. * elif t == NPY_CFLOAT: f = "Zf"
  2380. */
  2381. case NPY_DOUBLE:
  2382. __pyx_v_f = ((char *)"d");
  2383. break;
  2384. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":272
  2385. * elif t == NPY_FLOAT: f = "f"
  2386. * elif t == NPY_DOUBLE: f = "d"
  2387. * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<<
  2388. * elif t == NPY_CFLOAT: f = "Zf"
  2389. * elif t == NPY_CDOUBLE: f = "Zd"
  2390. */
  2391. case NPY_LONGDOUBLE:
  2392. __pyx_v_f = ((char *)"g");
  2393. break;
  2394. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":273
  2395. * elif t == NPY_DOUBLE: f = "d"
  2396. * elif t == NPY_LONGDOUBLE: f = "g"
  2397. * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<<
  2398. * elif t == NPY_CDOUBLE: f = "Zd"
  2399. * elif t == NPY_CLONGDOUBLE: f = "Zg"
  2400. */
  2401. case NPY_CFLOAT:
  2402. __pyx_v_f = ((char *)"Zf");
  2403. break;
  2404. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274
  2405. * elif t == NPY_LONGDOUBLE: f = "g"
  2406. * elif t == NPY_CFLOAT: f = "Zf"
  2407. * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<<
  2408. * elif t == NPY_CLONGDOUBLE: f = "Zg"
  2409. * elif t == NPY_OBJECT: f = "O"
  2410. */
  2411. case NPY_CDOUBLE:
  2412. __pyx_v_f = ((char *)"Zd");
  2413. break;
  2414. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":275
  2415. * elif t == NPY_CFLOAT: f = "Zf"
  2416. * elif t == NPY_CDOUBLE: f = "Zd"
  2417. * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<<
  2418. * elif t == NPY_OBJECT: f = "O"
  2419. * else:
  2420. */
  2421. case NPY_CLONGDOUBLE:
  2422. __pyx_v_f = ((char *)"Zg");
  2423. break;
  2424. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":276
  2425. * elif t == NPY_CDOUBLE: f = "Zd"
  2426. * elif t == NPY_CLONGDOUBLE: f = "Zg"
  2427. * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<<
  2428. * else:
  2429. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  2430. */
  2431. case NPY_OBJECT:
  2432. __pyx_v_f = ((char *)"O");
  2433. break;
  2434. default:
  2435. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":278
  2436. * elif t == NPY_OBJECT: f = "O"
  2437. * else:
  2438. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<<
  2439. * info.format = f
  2440. * return
  2441. */
  2442. __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
  2443. __Pyx_GOTREF(__pyx_t_3);
  2444. __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error)
  2445. __Pyx_GOTREF(__pyx_t_6);
  2446. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2447. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
  2448. __Pyx_GOTREF(__pyx_t_3);
  2449. __Pyx_GIVEREF(__pyx_t_6);
  2450. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
  2451. __pyx_t_6 = 0;
  2452. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error)
  2453. __Pyx_GOTREF(__pyx_t_6);
  2454. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2455. __Pyx_Raise(__pyx_t_6, 0, 0, 0);
  2456. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2457. __PYX_ERR(1, 278, __pyx_L1_error)
  2458. break;
  2459. }
  2460. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":279
  2461. * else:
  2462. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  2463. * info.format = f # <<<<<<<<<<<<<<
  2464. * return
  2465. * else:
  2466. */
  2467. __pyx_v_info->format = __pyx_v_f;
  2468. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":280
  2469. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  2470. * info.format = f
  2471. * return # <<<<<<<<<<<<<<
  2472. * else:
  2473. * info.format = <char*>stdlib.malloc(_buffer_format_string_len)
  2474. */
  2475. __pyx_r = 0;
  2476. goto __pyx_L0;
  2477. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":255
  2478. * info.obj = self
  2479. *
  2480. * if not hasfields: # <<<<<<<<<<<<<<
  2481. * t = descr.type_num
  2482. * if ((descr.byteorder == c'>' and little_endian) or
  2483. */
  2484. }
  2485. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":282
  2486. * return
  2487. * else:
  2488. * info.format = <char*>stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<<
  2489. * info.format[0] = c'^' # Native data types, manual alignment
  2490. * offset = 0
  2491. */
  2492. /*else*/ {
  2493. __pyx_v_info->format = ((char *)malloc(0xFF));
  2494. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":283
  2495. * else:
  2496. * info.format = <char*>stdlib.malloc(_buffer_format_string_len)
  2497. * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<<
  2498. * offset = 0
  2499. * f = _util_dtypestring(descr, info.format + 1,
  2500. */
  2501. (__pyx_v_info->format[0]) = '^';
  2502. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":284
  2503. * info.format = <char*>stdlib.malloc(_buffer_format_string_len)
  2504. * info.format[0] = c'^' # Native data types, manual alignment
  2505. * offset = 0 # <<<<<<<<<<<<<<
  2506. * f = _util_dtypestring(descr, info.format + 1,
  2507. * info.format + _buffer_format_string_len,
  2508. */
  2509. __pyx_v_offset = 0;
  2510. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":285
  2511. * info.format[0] = c'^' # Native data types, manual alignment
  2512. * offset = 0
  2513. * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<<
  2514. * info.format + _buffer_format_string_len,
  2515. * &offset)
  2516. */
  2517. __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error)
  2518. __pyx_v_f = __pyx_t_7;
  2519. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":288
  2520. * info.format + _buffer_format_string_len,
  2521. * &offset)
  2522. * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<<
  2523. *
  2524. * def __releasebuffer__(ndarray self, Py_buffer* info):
  2525. */
  2526. (__pyx_v_f[0]) = '\x00';
  2527. }
  2528. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":197
  2529. * # experimental exception made for __getbuffer__ and __releasebuffer__
  2530. * # -- the details of this may change.
  2531. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
  2532. * # This implementation of getbuffer is geared towards Cython
  2533. * # requirements, and does not yet fullfill the PEP.
  2534. */
  2535. /* function exit code */
  2536. __pyx_r = 0;
  2537. goto __pyx_L0;
  2538. __pyx_L1_error:;
  2539. __Pyx_XDECREF(__pyx_t_3);
  2540. __Pyx_XDECREF(__pyx_t_6);
  2541. __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2542. __pyx_r = -1;
  2543. if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
  2544. __Pyx_GOTREF(__pyx_v_info->obj);
  2545. __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  2546. }
  2547. goto __pyx_L2;
  2548. __pyx_L0:;
  2549. if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
  2550. __Pyx_GOTREF(Py_None);
  2551. __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  2552. }
  2553. __pyx_L2:;
  2554. __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  2555. __Pyx_RefNannyFinishContext();
  2556. return __pyx_r;
  2557. }
  2558. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":290
  2559. * f[0] = c'\0' # Terminate format string
  2560. *
  2561. * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
  2562. * if PyArray_HASFIELDS(self):
  2563. * stdlib.free(info.format)
  2564. */
  2565. /* Python wrapper */
  2566. static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
  2567. static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  2568. __Pyx_RefNannyDeclarations
  2569. __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  2570. __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));
  2571. /* function exit code */
  2572. __Pyx_RefNannyFinishContext();
  2573. }
  2574. static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  2575. __Pyx_RefNannyDeclarations
  2576. int __pyx_t_1;
  2577. __Pyx_RefNannySetupContext("__releasebuffer__", 0);
  2578. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":291
  2579. *
  2580. * def __releasebuffer__(ndarray self, Py_buffer* info):
  2581. * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
  2582. * stdlib.free(info.format)
  2583. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  2584. */
  2585. __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
  2586. if (__pyx_t_1) {
  2587. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":292
  2588. * def __releasebuffer__(ndarray self, Py_buffer* info):
  2589. * if PyArray_HASFIELDS(self):
  2590. * stdlib.free(info.format) # <<<<<<<<<<<<<<
  2591. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  2592. * stdlib.free(info.strides)
  2593. */
  2594. free(__pyx_v_info->format);
  2595. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":291
  2596. *
  2597. * def __releasebuffer__(ndarray self, Py_buffer* info):
  2598. * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
  2599. * stdlib.free(info.format)
  2600. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  2601. */
  2602. }
  2603. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":293
  2604. * if PyArray_HASFIELDS(self):
  2605. * stdlib.free(info.format)
  2606. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  2607. * stdlib.free(info.strides)
  2608. * # info.shape was stored after info.strides in the same block
  2609. */
  2610. __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  2611. if (__pyx_t_1) {
  2612. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":294
  2613. * stdlib.free(info.format)
  2614. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  2615. * stdlib.free(info.strides) # <<<<<<<<<<<<<<
  2616. * # info.shape was stored after info.strides in the same block
  2617. *
  2618. */
  2619. free(__pyx_v_info->strides);
  2620. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":293
  2621. * if PyArray_HASFIELDS(self):
  2622. * stdlib.free(info.format)
  2623. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  2624. * stdlib.free(info.strides)
  2625. * # info.shape was stored after info.strides in the same block
  2626. */
  2627. }
  2628. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":290
  2629. * f[0] = c'\0' # Terminate format string
  2630. *
  2631. * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
  2632. * if PyArray_HASFIELDS(self):
  2633. * stdlib.free(info.format)
  2634. */
  2635. /* function exit code */
  2636. __Pyx_RefNannyFinishContext();
  2637. }
  2638. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":770
  2639. * ctypedef npy_cdouble complex_t
  2640. *
  2641. * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
  2642. * return PyArray_MultiIterNew(1, <void*>a)
  2643. *
  2644. */
  2645. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  2646. PyObject *__pyx_r = NULL;
  2647. __Pyx_RefNannyDeclarations
  2648. PyObject *__pyx_t_1 = NULL;
  2649. __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
  2650. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":771
  2651. *
  2652. * cdef inline object PyArray_MultiIterNew1(a):
  2653. * return PyArray_MultiIterNew(1, <void*>a) # <<<<<<<<<<<<<<
  2654. *
  2655. * cdef inline object PyArray_MultiIterNew2(a, b):
  2656. */
  2657. __Pyx_XDECREF(__pyx_r);
  2658. __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error)
  2659. __Pyx_GOTREF(__pyx_t_1);
  2660. __pyx_r = __pyx_t_1;
  2661. __pyx_t_1 = 0;
  2662. goto __pyx_L0;
  2663. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":770
  2664. * ctypedef npy_cdouble complex_t
  2665. *
  2666. * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
  2667. * return PyArray_MultiIterNew(1, <void*>a)
  2668. *
  2669. */
  2670. /* function exit code */
  2671. __pyx_L1_error:;
  2672. __Pyx_XDECREF(__pyx_t_1);
  2673. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2674. __pyx_r = 0;
  2675. __pyx_L0:;
  2676. __Pyx_XGIVEREF(__pyx_r);
  2677. __Pyx_RefNannyFinishContext();
  2678. return __pyx_r;
  2679. }
  2680. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":773
  2681. * return PyArray_MultiIterNew(1, <void*>a)
  2682. *
  2683. * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
  2684. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  2685. *
  2686. */
  2687. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  2688. PyObject *__pyx_r = NULL;
  2689. __Pyx_RefNannyDeclarations
  2690. PyObject *__pyx_t_1 = NULL;
  2691. __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
  2692. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":774
  2693. *
  2694. * cdef inline object PyArray_MultiIterNew2(a, b):
  2695. * return PyArray_MultiIterNew(2, <void*>a, <void*>b) # <<<<<<<<<<<<<<
  2696. *
  2697. * cdef inline object PyArray_MultiIterNew3(a, b, c):
  2698. */
  2699. __Pyx_XDECREF(__pyx_r);
  2700. __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error)
  2701. __Pyx_GOTREF(__pyx_t_1);
  2702. __pyx_r = __pyx_t_1;
  2703. __pyx_t_1 = 0;
  2704. goto __pyx_L0;
  2705. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":773
  2706. * return PyArray_MultiIterNew(1, <void*>a)
  2707. *
  2708. * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
  2709. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  2710. *
  2711. */
  2712. /* function exit code */
  2713. __pyx_L1_error:;
  2714. __Pyx_XDECREF(__pyx_t_1);
  2715. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2716. __pyx_r = 0;
  2717. __pyx_L0:;
  2718. __Pyx_XGIVEREF(__pyx_r);
  2719. __Pyx_RefNannyFinishContext();
  2720. return __pyx_r;
  2721. }
  2722. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":776
  2723. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  2724. *
  2725. * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
  2726. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  2727. *
  2728. */
  2729. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  2730. PyObject *__pyx_r = NULL;
  2731. __Pyx_RefNannyDeclarations
  2732. PyObject *__pyx_t_1 = NULL;
  2733. __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
  2734. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":777
  2735. *
  2736. * cdef inline object PyArray_MultiIterNew3(a, b, c):
  2737. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) # <<<<<<<<<<<<<<
  2738. *
  2739. * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
  2740. */
  2741. __Pyx_XDECREF(__pyx_r);
  2742. __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error)
  2743. __Pyx_GOTREF(__pyx_t_1);
  2744. __pyx_r = __pyx_t_1;
  2745. __pyx_t_1 = 0;
  2746. goto __pyx_L0;
  2747. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":776
  2748. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  2749. *
  2750. * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
  2751. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  2752. *
  2753. */
  2754. /* function exit code */
  2755. __pyx_L1_error:;
  2756. __Pyx_XDECREF(__pyx_t_1);
  2757. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2758. __pyx_r = 0;
  2759. __pyx_L0:;
  2760. __Pyx_XGIVEREF(__pyx_r);
  2761. __Pyx_RefNannyFinishContext();
  2762. return __pyx_r;
  2763. }
  2764. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":779
  2765. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  2766. *
  2767. * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
  2768. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  2769. *
  2770. */
  2771. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  2772. PyObject *__pyx_r = NULL;
  2773. __Pyx_RefNannyDeclarations
  2774. PyObject *__pyx_t_1 = NULL;
  2775. __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
  2776. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":780
  2777. *
  2778. * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
  2779. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) # <<<<<<<<<<<<<<
  2780. *
  2781. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
  2782. */
  2783. __Pyx_XDECREF(__pyx_r);
  2784. __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error)
  2785. __Pyx_GOTREF(__pyx_t_1);
  2786. __pyx_r = __pyx_t_1;
  2787. __pyx_t_1 = 0;
  2788. goto __pyx_L0;
  2789. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":779
  2790. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  2791. *
  2792. * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
  2793. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  2794. *
  2795. */
  2796. /* function exit code */
  2797. __pyx_L1_error:;
  2798. __Pyx_XDECREF(__pyx_t_1);
  2799. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2800. __pyx_r = 0;
  2801. __pyx_L0:;
  2802. __Pyx_XGIVEREF(__pyx_r);
  2803. __Pyx_RefNannyFinishContext();
  2804. return __pyx_r;
  2805. }
  2806. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":782
  2807. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  2808. *
  2809. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
  2810. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  2811. *
  2812. */
  2813. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  2814. PyObject *__pyx_r = NULL;
  2815. __Pyx_RefNannyDeclarations
  2816. PyObject *__pyx_t_1 = NULL;
  2817. __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
  2818. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":783
  2819. *
  2820. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
  2821. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) # <<<<<<<<<<<<<<
  2822. *
  2823. * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
  2824. */
  2825. __Pyx_XDECREF(__pyx_r);
  2826. __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error)
  2827. __Pyx_GOTREF(__pyx_t_1);
  2828. __pyx_r = __pyx_t_1;
  2829. __pyx_t_1 = 0;
  2830. goto __pyx_L0;
  2831. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":782
  2832. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  2833. *
  2834. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
  2835. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  2836. *
  2837. */
  2838. /* function exit code */
  2839. __pyx_L1_error:;
  2840. __Pyx_XDECREF(__pyx_t_1);
  2841. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2842. __pyx_r = 0;
  2843. __pyx_L0:;
  2844. __Pyx_XGIVEREF(__pyx_r);
  2845. __Pyx_RefNannyFinishContext();
  2846. return __pyx_r;
  2847. }
  2848. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":785
  2849. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  2850. *
  2851. * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<<
  2852. * # Recursive utility function used in __getbuffer__ to get format
  2853. * # string. The new location in the format string is returned.
  2854. */
  2855. static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  2856. PyArray_Descr *__pyx_v_child = 0;
  2857. int __pyx_v_endian_detector;
  2858. int __pyx_v_little_endian;
  2859. PyObject *__pyx_v_fields = 0;
  2860. PyObject *__pyx_v_childname = NULL;
  2861. PyObject *__pyx_v_new_offset = NULL;
  2862. PyObject *__pyx_v_t = NULL;
  2863. char *__pyx_r;
  2864. __Pyx_RefNannyDeclarations
  2865. PyObject *__pyx_t_1 = NULL;
  2866. Py_ssize_t __pyx_t_2;
  2867. PyObject *__pyx_t_3 = NULL;
  2868. PyObject *__pyx_t_4 = NULL;
  2869. int __pyx_t_5;
  2870. int __pyx_t_6;
  2871. int __pyx_t_7;
  2872. long __pyx_t_8;
  2873. char *__pyx_t_9;
  2874. __Pyx_RefNannySetupContext("_util_dtypestring", 0);
  2875. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":790
  2876. *
  2877. * cdef dtype child
  2878. * cdef int endian_detector = 1 # <<<<<<<<<<<<<<
  2879. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
  2880. * cdef tuple fields
  2881. */
  2882. __pyx_v_endian_detector = 1;
  2883. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":791
  2884. * cdef dtype child
  2885. * cdef int endian_detector = 1
  2886. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<<
  2887. * cdef tuple fields
  2888. *
  2889. */
  2890. __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
  2891. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":794
  2892. * cdef tuple fields
  2893. *
  2894. * for childname in descr.names: # <<<<<<<<<<<<<<
  2895. * fields = descr.fields[childname]
  2896. * child, new_offset = fields
  2897. */
  2898. if (unlikely(__pyx_v_descr->names == Py_None)) {
  2899. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  2900. __PYX_ERR(1, 794, __pyx_L1_error)
  2901. }
  2902. __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  2903. for (;;) {
  2904. if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
  2905. #if CYTHON_COMPILING_IN_CPYTHON
  2906. __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error)
  2907. #else
  2908. __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error)
  2909. __Pyx_GOTREF(__pyx_t_3);
  2910. #endif
  2911. __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
  2912. __pyx_t_3 = 0;
  2913. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":795
  2914. *
  2915. * for childname in descr.names:
  2916. * fields = descr.fields[childname] # <<<<<<<<<<<<<<
  2917. * child, new_offset = fields
  2918. *
  2919. */
  2920. if (unlikely(__pyx_v_descr->fields == Py_None)) {
  2921. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  2922. __PYX_ERR(1, 795, __pyx_L1_error)
  2923. }
  2924. __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error)
  2925. __Pyx_GOTREF(__pyx_t_3);
  2926. if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error)
  2927. __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
  2928. __pyx_t_3 = 0;
  2929. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":796
  2930. * for childname in descr.names:
  2931. * fields = descr.fields[childname]
  2932. * child, new_offset = fields # <<<<<<<<<<<<<<
  2933. *
  2934. * if (end - f) - <int>(new_offset - offset[0]) < 15:
  2935. */
  2936. if (likely(__pyx_v_fields != Py_None)) {
  2937. PyObject* sequence = __pyx_v_fields;
  2938. #if CYTHON_COMPILING_IN_CPYTHON
  2939. Py_ssize_t size = Py_SIZE(sequence);
  2940. #else
  2941. Py_ssize_t size = PySequence_Size(sequence);
  2942. #endif
  2943. if (unlikely(size != 2)) {
  2944. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  2945. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  2946. __PYX_ERR(1, 796, __pyx_L1_error)
  2947. }
  2948. #if CYTHON_COMPILING_IN_CPYTHON
  2949. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
  2950. __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
  2951. __Pyx_INCREF(__pyx_t_3);
  2952. __Pyx_INCREF(__pyx_t_4);
  2953. #else
  2954. __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error)
  2955. __Pyx_GOTREF(__pyx_t_3);
  2956. __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error)
  2957. __Pyx_GOTREF(__pyx_t_4);
  2958. #endif
  2959. } else {
  2960. __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error)
  2961. }
  2962. if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error)
  2963. __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
  2964. __pyx_t_3 = 0;
  2965. __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
  2966. __pyx_t_4 = 0;
  2967. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":798
  2968. * child, new_offset = fields
  2969. *
  2970. * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<<
  2971. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  2972. *
  2973. */
  2974. __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error)
  2975. __Pyx_GOTREF(__pyx_t_4);
  2976. __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error)
  2977. __Pyx_GOTREF(__pyx_t_3);
  2978. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2979. __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error)
  2980. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2981. __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
  2982. if (__pyx_t_6) {
  2983. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":799
  2984. *
  2985. * if (end - f) - <int>(new_offset - offset[0]) < 15:
  2986. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<<
  2987. *
  2988. * if ((child.byteorder == c'>' and little_endian) or
  2989. */
  2990. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error)
  2991. __Pyx_GOTREF(__pyx_t_3);
  2992. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  2993. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2994. __PYX_ERR(1, 799, __pyx_L1_error)
  2995. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":798
  2996. * child, new_offset = fields
  2997. *
  2998. * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<<
  2999. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  3000. *
  3001. */
  3002. }
  3003. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801
  3004. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  3005. *
  3006. * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  3007. * (child.byteorder == c'<' and not little_endian)):
  3008. * raise ValueError(u"Non-native byte order not supported")
  3009. */
  3010. __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
  3011. if (!__pyx_t_7) {
  3012. goto __pyx_L8_next_or;
  3013. } else {
  3014. }
  3015. __pyx_t_7 = (__pyx_v_little_endian != 0);
  3016. if (!__pyx_t_7) {
  3017. } else {
  3018. __pyx_t_6 = __pyx_t_7;
  3019. goto __pyx_L7_bool_binop_done;
  3020. }
  3021. __pyx_L8_next_or:;
  3022. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":802
  3023. *
  3024. * if ((child.byteorder == c'>' and little_endian) or
  3025. * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<<
  3026. * raise ValueError(u"Non-native byte order not supported")
  3027. * # One could encode it in the format string and have Cython
  3028. */
  3029. __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
  3030. if (__pyx_t_7) {
  3031. } else {
  3032. __pyx_t_6 = __pyx_t_7;
  3033. goto __pyx_L7_bool_binop_done;
  3034. }
  3035. __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
  3036. __pyx_t_6 = __pyx_t_7;
  3037. __pyx_L7_bool_binop_done:;
  3038. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801
  3039. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  3040. *
  3041. * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  3042. * (child.byteorder == c'<' and not little_endian)):
  3043. * raise ValueError(u"Non-native byte order not supported")
  3044. */
  3045. if (__pyx_t_6) {
  3046. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":803
  3047. * if ((child.byteorder == c'>' and little_endian) or
  3048. * (child.byteorder == c'<' and not little_endian)):
  3049. * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
  3050. * # One could encode it in the format string and have Cython
  3051. * # complain instead, BUT: < and > in format strings also imply
  3052. */
  3053. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error)
  3054. __Pyx_GOTREF(__pyx_t_3);
  3055. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  3056. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3057. __PYX_ERR(1, 803, __pyx_L1_error)
  3058. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801
  3059. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  3060. *
  3061. * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  3062. * (child.byteorder == c'<' and not little_endian)):
  3063. * raise ValueError(u"Non-native byte order not supported")
  3064. */
  3065. }
  3066. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":813
  3067. *
  3068. * # Output padding bytes
  3069. * while offset[0] < new_offset: # <<<<<<<<<<<<<<
  3070. * f[0] = 120 # "x"; pad byte
  3071. * f += 1
  3072. */
  3073. while (1) {
  3074. __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error)
  3075. __Pyx_GOTREF(__pyx_t_3);
  3076. __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error)
  3077. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3078. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error)
  3079. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3080. if (!__pyx_t_6) break;
  3081. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":814
  3082. * # Output padding bytes
  3083. * while offset[0] < new_offset:
  3084. * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<<
  3085. * f += 1
  3086. * offset[0] += 1
  3087. */
  3088. (__pyx_v_f[0]) = 0x78;
  3089. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":815
  3090. * while offset[0] < new_offset:
  3091. * f[0] = 120 # "x"; pad byte
  3092. * f += 1 # <<<<<<<<<<<<<<
  3093. * offset[0] += 1
  3094. *
  3095. */
  3096. __pyx_v_f = (__pyx_v_f + 1);
  3097. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":816
  3098. * f[0] = 120 # "x"; pad byte
  3099. * f += 1
  3100. * offset[0] += 1 # <<<<<<<<<<<<<<
  3101. *
  3102. * offset[0] += child.itemsize
  3103. */
  3104. __pyx_t_8 = 0;
  3105. (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
  3106. }
  3107. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":818
  3108. * offset[0] += 1
  3109. *
  3110. * offset[0] += child.itemsize # <<<<<<<<<<<<<<
  3111. *
  3112. * if not PyDataType_HASFIELDS(child):
  3113. */
  3114. __pyx_t_8 = 0;
  3115. (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);
  3116. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":820
  3117. * offset[0] += child.itemsize
  3118. *
  3119. * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<<
  3120. * t = child.type_num
  3121. * if end - f < 5:
  3122. */
  3123. __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
  3124. if (__pyx_t_6) {
  3125. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":821
  3126. *
  3127. * if not PyDataType_HASFIELDS(child):
  3128. * t = child.type_num # <<<<<<<<<<<<<<
  3129. * if end - f < 5:
  3130. * raise RuntimeError(u"Format string allocated too short.")
  3131. */
  3132. __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error)
  3133. __Pyx_GOTREF(__pyx_t_4);
  3134. __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
  3135. __pyx_t_4 = 0;
  3136. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":822
  3137. * if not PyDataType_HASFIELDS(child):
  3138. * t = child.type_num
  3139. * if end - f < 5: # <<<<<<<<<<<<<<
  3140. * raise RuntimeError(u"Format string allocated too short.")
  3141. *
  3142. */
  3143. __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
  3144. if (__pyx_t_6) {
  3145. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":823
  3146. * t = child.type_num
  3147. * if end - f < 5:
  3148. * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<<
  3149. *
  3150. * # Until ticket #99 is fixed, use integers to avoid warnings
  3151. */
  3152. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error)
  3153. __Pyx_GOTREF(__pyx_t_4);
  3154. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  3155. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3156. __PYX_ERR(1, 823, __pyx_L1_error)
  3157. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":822
  3158. * if not PyDataType_HASFIELDS(child):
  3159. * t = child.type_num
  3160. * if end - f < 5: # <<<<<<<<<<<<<<
  3161. * raise RuntimeError(u"Format string allocated too short.")
  3162. *
  3163. */
  3164. }
  3165. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":826
  3166. *
  3167. * # Until ticket #99 is fixed, use integers to avoid warnings
  3168. * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<<
  3169. * elif t == NPY_UBYTE: f[0] = 66 #"B"
  3170. * elif t == NPY_SHORT: f[0] = 104 #"h"
  3171. */
  3172. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error)
  3173. __Pyx_GOTREF(__pyx_t_4);
  3174. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error)
  3175. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3176. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error)
  3177. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3178. if (__pyx_t_6) {
  3179. (__pyx_v_f[0]) = 98;
  3180. goto __pyx_L15;
  3181. }
  3182. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":827
  3183. * # Until ticket #99 is fixed, use integers to avoid warnings
  3184. * if t == NPY_BYTE: f[0] = 98 #"b"
  3185. * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<<
  3186. * elif t == NPY_SHORT: f[0] = 104 #"h"
  3187. * elif t == NPY_USHORT: f[0] = 72 #"H"
  3188. */
  3189. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error)
  3190. __Pyx_GOTREF(__pyx_t_3);
  3191. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error)
  3192. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3193. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error)
  3194. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3195. if (__pyx_t_6) {
  3196. (__pyx_v_f[0]) = 66;
  3197. goto __pyx_L15;
  3198. }
  3199. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":828
  3200. * if t == NPY_BYTE: f[0] = 98 #"b"
  3201. * elif t == NPY_UBYTE: f[0] = 66 #"B"
  3202. * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<<
  3203. * elif t == NPY_USHORT: f[0] = 72 #"H"
  3204. * elif t == NPY_INT: f[0] = 105 #"i"
  3205. */
  3206. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error)
  3207. __Pyx_GOTREF(__pyx_t_4);
  3208. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error)
  3209. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3210. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error)
  3211. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3212. if (__pyx_t_6) {
  3213. (__pyx_v_f[0]) = 0x68;
  3214. goto __pyx_L15;
  3215. }
  3216. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":829
  3217. * elif t == NPY_UBYTE: f[0] = 66 #"B"
  3218. * elif t == NPY_SHORT: f[0] = 104 #"h"
  3219. * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<<
  3220. * elif t == NPY_INT: f[0] = 105 #"i"
  3221. * elif t == NPY_UINT: f[0] = 73 #"I"
  3222. */
  3223. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error)
  3224. __Pyx_GOTREF(__pyx_t_3);
  3225. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error)
  3226. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3227. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error)
  3228. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3229. if (__pyx_t_6) {
  3230. (__pyx_v_f[0]) = 72;
  3231. goto __pyx_L15;
  3232. }
  3233. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":830
  3234. * elif t == NPY_SHORT: f[0] = 104 #"h"
  3235. * elif t == NPY_USHORT: f[0] = 72 #"H"
  3236. * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<<
  3237. * elif t == NPY_UINT: f[0] = 73 #"I"
  3238. * elif t == NPY_LONG: f[0] = 108 #"l"
  3239. */
  3240. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error)
  3241. __Pyx_GOTREF(__pyx_t_4);
  3242. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error)
  3243. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3244. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error)
  3245. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3246. if (__pyx_t_6) {
  3247. (__pyx_v_f[0]) = 0x69;
  3248. goto __pyx_L15;
  3249. }
  3250. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":831
  3251. * elif t == NPY_USHORT: f[0] = 72 #"H"
  3252. * elif t == NPY_INT: f[0] = 105 #"i"
  3253. * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<<
  3254. * elif t == NPY_LONG: f[0] = 108 #"l"
  3255. * elif t == NPY_ULONG: f[0] = 76 #"L"
  3256. */
  3257. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error)
  3258. __Pyx_GOTREF(__pyx_t_3);
  3259. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error)
  3260. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3261. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error)
  3262. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3263. if (__pyx_t_6) {
  3264. (__pyx_v_f[0]) = 73;
  3265. goto __pyx_L15;
  3266. }
  3267. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":832
  3268. * elif t == NPY_INT: f[0] = 105 #"i"
  3269. * elif t == NPY_UINT: f[0] = 73 #"I"
  3270. * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<<
  3271. * elif t == NPY_ULONG: f[0] = 76 #"L"
  3272. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  3273. */
  3274. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error)
  3275. __Pyx_GOTREF(__pyx_t_4);
  3276. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error)
  3277. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3278. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error)
  3279. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3280. if (__pyx_t_6) {
  3281. (__pyx_v_f[0]) = 0x6C;
  3282. goto __pyx_L15;
  3283. }
  3284. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":833
  3285. * elif t == NPY_UINT: f[0] = 73 #"I"
  3286. * elif t == NPY_LONG: f[0] = 108 #"l"
  3287. * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<<
  3288. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  3289. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  3290. */
  3291. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error)
  3292. __Pyx_GOTREF(__pyx_t_3);
  3293. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error)
  3294. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3295. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error)
  3296. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3297. if (__pyx_t_6) {
  3298. (__pyx_v_f[0]) = 76;
  3299. goto __pyx_L15;
  3300. }
  3301. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":834
  3302. * elif t == NPY_LONG: f[0] = 108 #"l"
  3303. * elif t == NPY_ULONG: f[0] = 76 #"L"
  3304. * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<<
  3305. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  3306. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  3307. */
  3308. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error)
  3309. __Pyx_GOTREF(__pyx_t_4);
  3310. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error)
  3311. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3312. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error)
  3313. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3314. if (__pyx_t_6) {
  3315. (__pyx_v_f[0]) = 0x71;
  3316. goto __pyx_L15;
  3317. }
  3318. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":835
  3319. * elif t == NPY_ULONG: f[0] = 76 #"L"
  3320. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  3321. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<<
  3322. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  3323. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  3324. */
  3325. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error)
  3326. __Pyx_GOTREF(__pyx_t_3);
  3327. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error)
  3328. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3329. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error)
  3330. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3331. if (__pyx_t_6) {
  3332. (__pyx_v_f[0]) = 81;
  3333. goto __pyx_L15;
  3334. }
  3335. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":836
  3336. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  3337. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  3338. * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<<
  3339. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  3340. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  3341. */
  3342. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error)
  3343. __Pyx_GOTREF(__pyx_t_4);
  3344. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error)
  3345. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3346. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error)
  3347. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3348. if (__pyx_t_6) {
  3349. (__pyx_v_f[0]) = 0x66;
  3350. goto __pyx_L15;
  3351. }
  3352. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":837
  3353. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  3354. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  3355. * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<<
  3356. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  3357. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  3358. */
  3359. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error)
  3360. __Pyx_GOTREF(__pyx_t_3);
  3361. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error)
  3362. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3363. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error)
  3364. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3365. if (__pyx_t_6) {
  3366. (__pyx_v_f[0]) = 0x64;
  3367. goto __pyx_L15;
  3368. }
  3369. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":838
  3370. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  3371. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  3372. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<<
  3373. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  3374. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  3375. */
  3376. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error)
  3377. __Pyx_GOTREF(__pyx_t_4);
  3378. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error)
  3379. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3380. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error)
  3381. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3382. if (__pyx_t_6) {
  3383. (__pyx_v_f[0]) = 0x67;
  3384. goto __pyx_L15;
  3385. }
  3386. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":839
  3387. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  3388. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  3389. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<<
  3390. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  3391. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  3392. */
  3393. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error)
  3394. __Pyx_GOTREF(__pyx_t_3);
  3395. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error)
  3396. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3397. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error)
  3398. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3399. if (__pyx_t_6) {
  3400. (__pyx_v_f[0]) = 90;
  3401. (__pyx_v_f[1]) = 0x66;
  3402. __pyx_v_f = (__pyx_v_f + 1);
  3403. goto __pyx_L15;
  3404. }
  3405. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":840
  3406. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  3407. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  3408. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<<
  3409. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  3410. * elif t == NPY_OBJECT: f[0] = 79 #"O"
  3411. */
  3412. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error)
  3413. __Pyx_GOTREF(__pyx_t_4);
  3414. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error)
  3415. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3416. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error)
  3417. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3418. if (__pyx_t_6) {
  3419. (__pyx_v_f[0]) = 90;
  3420. (__pyx_v_f[1]) = 0x64;
  3421. __pyx_v_f = (__pyx_v_f + 1);
  3422. goto __pyx_L15;
  3423. }
  3424. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":841
  3425. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  3426. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  3427. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<<
  3428. * elif t == NPY_OBJECT: f[0] = 79 #"O"
  3429. * else:
  3430. */
  3431. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error)
  3432. __Pyx_GOTREF(__pyx_t_3);
  3433. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error)
  3434. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3435. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error)
  3436. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3437. if (__pyx_t_6) {
  3438. (__pyx_v_f[0]) = 90;
  3439. (__pyx_v_f[1]) = 0x67;
  3440. __pyx_v_f = (__pyx_v_f + 1);
  3441. goto __pyx_L15;
  3442. }
  3443. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":842
  3444. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  3445. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  3446. * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<<
  3447. * else:
  3448. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  3449. */
  3450. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error)
  3451. __Pyx_GOTREF(__pyx_t_4);
  3452. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error)
  3453. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3454. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error)
  3455. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3456. if (__pyx_t_6) {
  3457. (__pyx_v_f[0]) = 79;
  3458. goto __pyx_L15;
  3459. }
  3460. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":844
  3461. * elif t == NPY_OBJECT: f[0] = 79 #"O"
  3462. * else:
  3463. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<<
  3464. * f += 1
  3465. * else:
  3466. */
  3467. /*else*/ {
  3468. __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error)
  3469. __Pyx_GOTREF(__pyx_t_3);
  3470. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error)
  3471. __Pyx_GOTREF(__pyx_t_4);
  3472. __Pyx_GIVEREF(__pyx_t_3);
  3473. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  3474. __pyx_t_3 = 0;
  3475. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error)
  3476. __Pyx_GOTREF(__pyx_t_3);
  3477. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3478. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  3479. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3480. __PYX_ERR(1, 844, __pyx_L1_error)
  3481. }
  3482. __pyx_L15:;
  3483. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":845
  3484. * else:
  3485. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  3486. * f += 1 # <<<<<<<<<<<<<<
  3487. * else:
  3488. * # Cython ignores struct boundary information ("T{...}"),
  3489. */
  3490. __pyx_v_f = (__pyx_v_f + 1);
  3491. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":820
  3492. * offset[0] += child.itemsize
  3493. *
  3494. * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<<
  3495. * t = child.type_num
  3496. * if end - f < 5:
  3497. */
  3498. goto __pyx_L13;
  3499. }
  3500. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":849
  3501. * # Cython ignores struct boundary information ("T{...}"),
  3502. * # so don't output it
  3503. * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<<
  3504. * return f
  3505. *
  3506. */
  3507. /*else*/ {
  3508. __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error)
  3509. __pyx_v_f = __pyx_t_9;
  3510. }
  3511. __pyx_L13:;
  3512. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":794
  3513. * cdef tuple fields
  3514. *
  3515. * for childname in descr.names: # <<<<<<<<<<<<<<
  3516. * fields = descr.fields[childname]
  3517. * child, new_offset = fields
  3518. */
  3519. }
  3520. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3521. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":850
  3522. * # so don't output it
  3523. * f = _util_dtypestring(child, f, end, offset)
  3524. * return f # <<<<<<<<<<<<<<
  3525. *
  3526. *
  3527. */
  3528. __pyx_r = __pyx_v_f;
  3529. goto __pyx_L0;
  3530. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":785
  3531. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  3532. *
  3533. * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<<
  3534. * # Recursive utility function used in __getbuffer__ to get format
  3535. * # string. The new location in the format string is returned.
  3536. */
  3537. /* function exit code */
  3538. __pyx_L1_error:;
  3539. __Pyx_XDECREF(__pyx_t_1);
  3540. __Pyx_XDECREF(__pyx_t_3);
  3541. __Pyx_XDECREF(__pyx_t_4);
  3542. __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3543. __pyx_r = NULL;
  3544. __pyx_L0:;
  3545. __Pyx_XDECREF((PyObject *)__pyx_v_child);
  3546. __Pyx_XDECREF(__pyx_v_fields);
  3547. __Pyx_XDECREF(__pyx_v_childname);
  3548. __Pyx_XDECREF(__pyx_v_new_offset);
  3549. __Pyx_XDECREF(__pyx_v_t);
  3550. __Pyx_RefNannyFinishContext();
  3551. return __pyx_r;
  3552. }
  3553. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":966
  3554. *
  3555. *
  3556. * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
  3557. * cdef PyObject* baseptr
  3558. * if base is None:
  3559. */
  3560. static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  3561. PyObject *__pyx_v_baseptr;
  3562. __Pyx_RefNannyDeclarations
  3563. int __pyx_t_1;
  3564. int __pyx_t_2;
  3565. __Pyx_RefNannySetupContext("set_array_base", 0);
  3566. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":968
  3567. * cdef inline void set_array_base(ndarray arr, object base):
  3568. * cdef PyObject* baseptr
  3569. * if base is None: # <<<<<<<<<<<<<<
  3570. * baseptr = NULL
  3571. * else:
  3572. */
  3573. __pyx_t_1 = (__pyx_v_base == Py_None);
  3574. __pyx_t_2 = (__pyx_t_1 != 0);
  3575. if (__pyx_t_2) {
  3576. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":969
  3577. * cdef PyObject* baseptr
  3578. * if base is None:
  3579. * baseptr = NULL # <<<<<<<<<<<<<<
  3580. * else:
  3581. * Py_INCREF(base) # important to do this before decref below!
  3582. */
  3583. __pyx_v_baseptr = NULL;
  3584. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":968
  3585. * cdef inline void set_array_base(ndarray arr, object base):
  3586. * cdef PyObject* baseptr
  3587. * if base is None: # <<<<<<<<<<<<<<
  3588. * baseptr = NULL
  3589. * else:
  3590. */
  3591. goto __pyx_L3;
  3592. }
  3593. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":971
  3594. * baseptr = NULL
  3595. * else:
  3596. * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<<
  3597. * baseptr = <PyObject*>base
  3598. * Py_XDECREF(arr.base)
  3599. */
  3600. /*else*/ {
  3601. Py_INCREF(__pyx_v_base);
  3602. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":972
  3603. * else:
  3604. * Py_INCREF(base) # important to do this before decref below!
  3605. * baseptr = <PyObject*>base # <<<<<<<<<<<<<<
  3606. * Py_XDECREF(arr.base)
  3607. * arr.base = baseptr
  3608. */
  3609. __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
  3610. }
  3611. __pyx_L3:;
  3612. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":973
  3613. * Py_INCREF(base) # important to do this before decref below!
  3614. * baseptr = <PyObject*>base
  3615. * Py_XDECREF(arr.base) # <<<<<<<<<<<<<<
  3616. * arr.base = baseptr
  3617. *
  3618. */
  3619. Py_XDECREF(__pyx_v_arr->base);
  3620. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":974
  3621. * baseptr = <PyObject*>base
  3622. * Py_XDECREF(arr.base)
  3623. * arr.base = baseptr # <<<<<<<<<<<<<<
  3624. *
  3625. * cdef inline object get_array_base(ndarray arr):
  3626. */
  3627. __pyx_v_arr->base = __pyx_v_baseptr;
  3628. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":966
  3629. *
  3630. *
  3631. * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
  3632. * cdef PyObject* baseptr
  3633. * if base is None:
  3634. */
  3635. /* function exit code */
  3636. __Pyx_RefNannyFinishContext();
  3637. }
  3638. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":976
  3639. * arr.base = baseptr
  3640. *
  3641. * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
  3642. * if arr.base is NULL:
  3643. * return None
  3644. */
  3645. static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  3646. PyObject *__pyx_r = NULL;
  3647. __Pyx_RefNannyDeclarations
  3648. int __pyx_t_1;
  3649. __Pyx_RefNannySetupContext("get_array_base", 0);
  3650. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":977
  3651. *
  3652. * cdef inline object get_array_base(ndarray arr):
  3653. * if arr.base is NULL: # <<<<<<<<<<<<<<
  3654. * return None
  3655. * else:
  3656. */
  3657. __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
  3658. if (__pyx_t_1) {
  3659. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":978
  3660. * cdef inline object get_array_base(ndarray arr):
  3661. * if arr.base is NULL:
  3662. * return None # <<<<<<<<<<<<<<
  3663. * else:
  3664. * return <object>arr.base
  3665. */
  3666. __Pyx_XDECREF(__pyx_r);
  3667. __Pyx_INCREF(Py_None);
  3668. __pyx_r = Py_None;
  3669. goto __pyx_L0;
  3670. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":977
  3671. *
  3672. * cdef inline object get_array_base(ndarray arr):
  3673. * if arr.base is NULL: # <<<<<<<<<<<<<<
  3674. * return None
  3675. * else:
  3676. */
  3677. }
  3678. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":980
  3679. * return None
  3680. * else:
  3681. * return <object>arr.base # <<<<<<<<<<<<<<
  3682. */
  3683. /*else*/ {
  3684. __Pyx_XDECREF(__pyx_r);
  3685. __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
  3686. __pyx_r = ((PyObject *)__pyx_v_arr->base);
  3687. goto __pyx_L0;
  3688. }
  3689. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":976
  3690. * arr.base = baseptr
  3691. *
  3692. * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
  3693. * if arr.base is NULL:
  3694. * return None
  3695. */
  3696. /* function exit code */
  3697. __pyx_L0:;
  3698. __Pyx_XGIVEREF(__pyx_r);
  3699. __Pyx_RefNannyFinishContext();
  3700. return __pyx_r;
  3701. }
  3702. static PyMethodDef __pyx_methods[] = {
  3703. {0, 0, 0, 0}
  3704. };
  3705. #if PY_MAJOR_VERSION >= 3
  3706. static struct PyModuleDef __pyx_moduledef = {
  3707. #if PY_VERSION_HEX < 0x03020000
  3708. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  3709. #else
  3710. PyModuleDef_HEAD_INIT,
  3711. #endif
  3712. "gpu_nms",
  3713. 0, /* m_doc */
  3714. -1, /* m_size */
  3715. __pyx_methods /* m_methods */,
  3716. NULL, /* m_reload */
  3717. NULL, /* m_traverse */
  3718. NULL, /* m_clear */
  3719. NULL /* m_free */
  3720. };
  3721. #endif
  3722. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  3723. {&__pyx_kp_s_D_v_zix_caffe_caffe_win_20160523, __pyx_k_D_v_zix_caffe_caffe_win_20160523, sizeof(__pyx_k_D_v_zix_caffe_caffe_win_20160523), 0, 0, 1, 0},
  3724. {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  3725. {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  3726. {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  3727. {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  3728. {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  3729. {&__pyx_n_s_argsort, __pyx_k_argsort, sizeof(__pyx_k_argsort), 0, 0, 1, 1},
  3730. {&__pyx_n_s_boxes_dim, __pyx_k_boxes_dim, sizeof(__pyx_k_boxes_dim), 0, 0, 1, 1},
  3731. {&__pyx_n_s_boxes_num, __pyx_k_boxes_num, sizeof(__pyx_k_boxes_num), 0, 0, 1, 1},
  3732. {&__pyx_n_s_dets, __pyx_k_dets, sizeof(__pyx_k_dets), 0, 0, 1, 1},
  3733. {&__pyx_n_s_device_id, __pyx_k_device_id, sizeof(__pyx_k_device_id), 0, 0, 1, 1},
  3734. {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  3735. {&__pyx_n_s_gpu_nms, __pyx_k_gpu_nms, sizeof(__pyx_k_gpu_nms), 0, 0, 1, 1},
  3736. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  3737. {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
  3738. {&__pyx_n_s_keep, __pyx_k_keep, sizeof(__pyx_k_keep), 0, 0, 1, 1},
  3739. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  3740. {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  3741. {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  3742. {&__pyx_n_s_nms_gpu_nms, __pyx_k_nms_gpu_nms, sizeof(__pyx_k_nms_gpu_nms), 0, 0, 1, 1},
  3743. {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  3744. {&__pyx_n_s_num_out, __pyx_k_num_out, sizeof(__pyx_k_num_out), 0, 0, 1, 1},
  3745. {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  3746. {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
  3747. {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  3748. {&__pyx_n_s_scores, __pyx_k_scores, sizeof(__pyx_k_scores), 0, 0, 1, 1},
  3749. {&__pyx_n_s_sorted_dets, __pyx_k_sorted_dets, sizeof(__pyx_k_sorted_dets), 0, 0, 1, 1},
  3750. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  3751. {&__pyx_n_s_thresh, __pyx_k_thresh, sizeof(__pyx_k_thresh), 0, 0, 1, 1},
  3752. {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  3753. {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  3754. {0, 0, 0, 0, 0, 0, 0}
  3755. };
  3756. static int __Pyx_InitCachedBuiltins(void) {
  3757. __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 218, __pyx_L1_error)
  3758. __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 231, __pyx_L1_error)
  3759. __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error)
  3760. return 0;
  3761. __pyx_L1_error:;
  3762. return -1;
  3763. }
  3764. static int __Pyx_InitCachedConstants(void) {
  3765. __Pyx_RefNannyDeclarations
  3766. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  3767. /* "nms/gpu_nms.pyx":24
  3768. * keep = np.zeros(boxes_num, dtype=np.int32)
  3769. * cdef np.ndarray[np.float32_t, ndim=1] \
  3770. * scores = dets[:, 4] # <<<<<<<<<<<<<<
  3771. * #cdef np.ndarray[np.int_t, ndim=1] \ // 20160601, by xzn
  3772. * # order = scores.argsort()[::-1]
  3773. */
  3774. __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 24, __pyx_L1_error)
  3775. __Pyx_GOTREF(__pyx_slice_);
  3776. __Pyx_GIVEREF(__pyx_slice_);
  3777. __pyx_tuple__2 = PyTuple_Pack(2, __pyx_slice_, __pyx_int_4); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 24, __pyx_L1_error)
  3778. __Pyx_GOTREF(__pyx_tuple__2);
  3779. __Pyx_GIVEREF(__pyx_tuple__2);
  3780. /* "nms/gpu_nms.pyx":28
  3781. * # order = scores.argsort()[::-1]
  3782. * cdef np.ndarray[np.intp_t, ndim=1] \
  3783. * order = scores.argsort()[::-1] # <<<<<<<<<<<<<<
  3784. * cdef np.ndarray[np.float32_t, ndim=2] \
  3785. * sorted_dets = dets[order, :]
  3786. */
  3787. __pyx_slice__3 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 28, __pyx_L1_error)
  3788. __Pyx_GOTREF(__pyx_slice__3);
  3789. __Pyx_GIVEREF(__pyx_slice__3);
  3790. /* "nms/gpu_nms.pyx":30
  3791. * order = scores.argsort()[::-1]
  3792. * cdef np.ndarray[np.float32_t, ndim=2] \
  3793. * sorted_dets = dets[order, :] # <<<<<<<<<<<<<<
  3794. * _nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id)
  3795. * keep = keep[:num_out]
  3796. */
  3797. __pyx_slice__4 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__4)) __PYX_ERR(0, 30, __pyx_L1_error)
  3798. __Pyx_GOTREF(__pyx_slice__4);
  3799. __Pyx_GIVEREF(__pyx_slice__4);
  3800. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":218
  3801. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  3802. * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  3803. * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<<
  3804. *
  3805. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  3806. */
  3807. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 218, __pyx_L1_error)
  3808. __Pyx_GOTREF(__pyx_tuple__5);
  3809. __Pyx_GIVEREF(__pyx_tuple__5);
  3810. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":222
  3811. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  3812. * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  3813. * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<<
  3814. *
  3815. * info.buf = PyArray_DATA(self)
  3816. */
  3817. __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 222, __pyx_L1_error)
  3818. __Pyx_GOTREF(__pyx_tuple__6);
  3819. __Pyx_GIVEREF(__pyx_tuple__6);
  3820. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":259
  3821. * if ((descr.byteorder == c'>' and little_endian) or
  3822. * (descr.byteorder == c'<' and not little_endian)):
  3823. * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
  3824. * if t == NPY_BYTE: f = "b"
  3825. * elif t == NPY_UBYTE: f = "B"
  3826. */
  3827. __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 259, __pyx_L1_error)
  3828. __Pyx_GOTREF(__pyx_tuple__7);
  3829. __Pyx_GIVEREF(__pyx_tuple__7);
  3830. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":799
  3831. *
  3832. * if (end - f) - <int>(new_offset - offset[0]) < 15:
  3833. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<<
  3834. *
  3835. * if ((child.byteorder == c'>' and little_endian) or
  3836. */
  3837. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 799, __pyx_L1_error)
  3838. __Pyx_GOTREF(__pyx_tuple__8);
  3839. __Pyx_GIVEREF(__pyx_tuple__8);
  3840. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":803
  3841. * if ((child.byteorder == c'>' and little_endian) or
  3842. * (child.byteorder == c'<' and not little_endian)):
  3843. * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
  3844. * # One could encode it in the format string and have Cython
  3845. * # complain instead, BUT: < and > in format strings also imply
  3846. */
  3847. __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 803, __pyx_L1_error)
  3848. __Pyx_GOTREF(__pyx_tuple__9);
  3849. __Pyx_GIVEREF(__pyx_tuple__9);
  3850. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":823
  3851. * t = child.type_num
  3852. * if end - f < 5:
  3853. * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<<
  3854. *
  3855. * # Until ticket #99 is fixed, use integers to avoid warnings
  3856. */
  3857. __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 823, __pyx_L1_error)
  3858. __Pyx_GOTREF(__pyx_tuple__10);
  3859. __Pyx_GIVEREF(__pyx_tuple__10);
  3860. /* "nms/gpu_nms.pyx":16
  3861. * void _nms(np.int32_t*, int*, np.float32_t*, int, int, float, int)
  3862. *
  3863. * def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh, # <<<<<<<<<<<<<<
  3864. * np.int32_t device_id=0):
  3865. * cdef int boxes_num = dets.shape[0]
  3866. */
  3867. __pyx_tuple__11 = PyTuple_Pack(10, __pyx_n_s_dets, __pyx_n_s_thresh, __pyx_n_s_device_id, __pyx_n_s_boxes_num, __pyx_n_s_boxes_dim, __pyx_n_s_num_out, __pyx_n_s_keep, __pyx_n_s_scores, __pyx_n_s_order, __pyx_n_s_sorted_dets); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 16, __pyx_L1_error)
  3868. __Pyx_GOTREF(__pyx_tuple__11);
  3869. __Pyx_GIVEREF(__pyx_tuple__11);
  3870. __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(3, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_D_v_zix_caffe_caffe_win_20160523, __pyx_n_s_gpu_nms, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 16, __pyx_L1_error)
  3871. __Pyx_RefNannyFinishContext();
  3872. return 0;
  3873. __pyx_L1_error:;
  3874. __Pyx_RefNannyFinishContext();
  3875. return -1;
  3876. }
  3877. static int __Pyx_InitGlobals(void) {
  3878. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  3879. __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  3880. __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  3881. return 0;
  3882. __pyx_L1_error:;
  3883. return -1;
  3884. }
  3885. #if PY_MAJOR_VERSION < 3
  3886. PyMODINIT_FUNC initgpu_nms(void); /*proto*/
  3887. PyMODINIT_FUNC initgpu_nms(void)
  3888. #else
  3889. PyMODINIT_FUNC PyInit_gpu_nms(void); /*proto*/
  3890. PyMODINIT_FUNC PyInit_gpu_nms(void)
  3891. #endif
  3892. {
  3893. PyObject *__pyx_t_1 = NULL;
  3894. __Pyx_RefNannyDeclarations
  3895. #if CYTHON_REFNANNY
  3896. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  3897. if (!__Pyx_RefNanny) {
  3898. PyErr_Clear();
  3899. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  3900. if (!__Pyx_RefNanny)
  3901. Py_FatalError("failed to import 'refnanny' module");
  3902. }
  3903. #endif
  3904. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_gpu_nms(void)", 0);
  3905. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3906. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  3907. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  3908. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  3909. #ifdef __Pyx_CyFunction_USED
  3910. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3911. #endif
  3912. #ifdef __Pyx_FusedFunction_USED
  3913. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3914. #endif
  3915. #ifdef __Pyx_Coroutine_USED
  3916. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3917. #endif
  3918. #ifdef __Pyx_Generator_USED
  3919. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3920. #endif
  3921. #ifdef __Pyx_StopAsyncIteration_USED
  3922. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3923. #endif
  3924. /*--- Library function declarations ---*/
  3925. /*--- Threads initialization code ---*/
  3926. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  3927. #ifdef WITH_THREAD /* Python build with threading support? */
  3928. PyEval_InitThreads();
  3929. #endif
  3930. #endif
  3931. /*--- Module creation code ---*/
  3932. #if PY_MAJOR_VERSION < 3
  3933. __pyx_m = Py_InitModule4("gpu_nms", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  3934. #else
  3935. __pyx_m = PyModule_Create(&__pyx_moduledef);
  3936. #endif
  3937. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  3938. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  3939. Py_INCREF(__pyx_d);
  3940. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  3941. #if CYTHON_COMPILING_IN_PYPY
  3942. Py_INCREF(__pyx_b);
  3943. #endif
  3944. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  3945. /*--- Initialize various global constants etc. ---*/
  3946. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3947. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  3948. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3949. #endif
  3950. if (__pyx_module_is_main_nms__gpu_nms) {
  3951. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3952. }
  3953. #if PY_MAJOR_VERSION >= 3
  3954. {
  3955. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  3956. if (!PyDict_GetItemString(modules, "nms.gpu_nms")) {
  3957. if (unlikely(PyDict_SetItemString(modules, "nms.gpu_nms", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  3958. }
  3959. }
  3960. #endif
  3961. /*--- Builtin init code ---*/
  3962. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3963. /*--- Constants init code ---*/
  3964. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3965. /*--- Global init code ---*/
  3966. /*--- Variable export code ---*/
  3967. /*--- Function export code ---*/
  3968. /*--- Type init code ---*/
  3969. /*--- Type import code ---*/
  3970. __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
  3971. #if CYTHON_COMPILING_IN_PYPY
  3972. sizeof(PyTypeObject),
  3973. #else
  3974. sizeof(PyHeapTypeObject),
  3975. #endif
  3976. 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error)
  3977. __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error)
  3978. __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error)
  3979. __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error)
  3980. __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error)
  3981. __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error)
  3982. /*--- Variable import code ---*/
  3983. /*--- Function import code ---*/
  3984. /*--- Execution code ---*/
  3985. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  3986. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3987. #endif
  3988. /* "nms/gpu_nms.pyx":8
  3989. * # --------------------------------------------------------
  3990. *
  3991. * import numpy as np # <<<<<<<<<<<<<<
  3992. * cimport numpy as np
  3993. *
  3994. */
  3995. __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  3996. __Pyx_GOTREF(__pyx_t_1);
  3997. if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  3998. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3999. /* "nms/gpu_nms.pyx":11
  4000. * cimport numpy as np
  4001. *
  4002. * assert sizeof(int) == sizeof(np.int32_t) # <<<<<<<<<<<<<<
  4003. *
  4004. * cdef extern from "gpu_nms.hpp":
  4005. */
  4006. #ifndef CYTHON_WITHOUT_ASSERTIONS
  4007. if (unlikely(!Py_OptimizeFlag)) {
  4008. if (unlikely(!(((sizeof(int)) == (sizeof(__pyx_t_5numpy_int32_t))) != 0))) {
  4009. PyErr_SetNone(PyExc_AssertionError);
  4010. __PYX_ERR(0, 11, __pyx_L1_error)
  4011. }
  4012. }
  4013. #endif
  4014. /* "nms/gpu_nms.pyx":16
  4015. * void _nms(np.int32_t*, int*, np.float32_t*, int, int, float, int)
  4016. *
  4017. * def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh, # <<<<<<<<<<<<<<
  4018. * np.int32_t device_id=0):
  4019. * cdef int boxes_num = dets.shape[0]
  4020. */
  4021. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3nms_7gpu_nms_1gpu_nms, NULL, __pyx_n_s_nms_gpu_nms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  4022. __Pyx_GOTREF(__pyx_t_1);
  4023. if (PyDict_SetItem(__pyx_d, __pyx_n_s_gpu_nms, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  4024. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4025. /* "nms/gpu_nms.pyx":1
  4026. * # -------------------------------------------------------- # <<<<<<<<<<<<<<
  4027. * # Faster R-CNN
  4028. * # Copyright (c) 2015 Microsoft
  4029. */
  4030. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  4031. __Pyx_GOTREF(__pyx_t_1);
  4032. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  4033. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4034. /* "C:/Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":976
  4035. * arr.base = baseptr
  4036. *
  4037. * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
  4038. * if arr.base is NULL:
  4039. * return None
  4040. */
  4041. /*--- Wrapped vars code ---*/
  4042. goto __pyx_L0;
  4043. __pyx_L1_error:;
  4044. __Pyx_XDECREF(__pyx_t_1);
  4045. if (__pyx_m) {
  4046. if (__pyx_d) {
  4047. __Pyx_AddTraceback("init nms.gpu_nms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4048. }
  4049. Py_DECREF(__pyx_m); __pyx_m = 0;
  4050. } else if (!PyErr_Occurred()) {
  4051. PyErr_SetString(PyExc_ImportError, "init nms.gpu_nms");
  4052. }
  4053. __pyx_L0:;
  4054. __Pyx_RefNannyFinishContext();
  4055. #if PY_MAJOR_VERSION < 3
  4056. return;
  4057. #else
  4058. return __pyx_m;
  4059. #endif
  4060. }
  4061. /* --- Runtime support code --- */
  4062. /* Refnanny */
  4063. #if CYTHON_REFNANNY
  4064. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  4065. PyObject *m = NULL, *p = NULL;
  4066. void *r = NULL;
  4067. m = PyImport_ImportModule((char *)modname);
  4068. if (!m) goto end;
  4069. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  4070. if (!p) goto end;
  4071. r = PyLong_AsVoidPtr(p);
  4072. end:
  4073. Py_XDECREF(p);
  4074. Py_XDECREF(m);
  4075. return (__Pyx_RefNannyAPIStruct *)r;
  4076. }
  4077. #endif
  4078. /* RaiseArgTupleInvalid */
  4079. static void __Pyx_RaiseArgtupleInvalid(
  4080. const char* func_name,
  4081. int exact,
  4082. Py_ssize_t num_min,
  4083. Py_ssize_t num_max,
  4084. Py_ssize_t num_found)
  4085. {
  4086. Py_ssize_t num_expected;
  4087. const char *more_or_less;
  4088. if (num_found < num_min) {
  4089. num_expected = num_min;
  4090. more_or_less = "at least";
  4091. } else {
  4092. num_expected = num_max;
  4093. more_or_less = "at most";
  4094. }
  4095. if (exact) {
  4096. more_or_less = "exactly";
  4097. }
  4098. PyErr_Format(PyExc_TypeError,
  4099. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  4100. func_name, more_or_less, num_expected,
  4101. (num_expected == 1) ? "" : "s", num_found);
  4102. }
  4103. /* RaiseDoubleKeywords */
  4104. static void __Pyx_RaiseDoubleKeywordsError(
  4105. const char* func_name,
  4106. PyObject* kw_name)
  4107. {
  4108. PyErr_Format(PyExc_TypeError,
  4109. #if PY_MAJOR_VERSION >= 3
  4110. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  4111. #else
  4112. "%s() got multiple values for keyword argument '%s'", func_name,
  4113. PyString_AsString(kw_name));
  4114. #endif
  4115. }
  4116. /* ParseKeywords */
  4117. static int __Pyx_ParseOptionalKeywords(
  4118. PyObject *kwds,
  4119. PyObject **argnames[],
  4120. PyObject *kwds2,
  4121. PyObject *values[],
  4122. Py_ssize_t num_pos_args,
  4123. const char* function_name)
  4124. {
  4125. PyObject *key = 0, *value = 0;
  4126. Py_ssize_t pos = 0;
  4127. PyObject*** name;
  4128. PyObject*** first_kw_arg = argnames + num_pos_args;
  4129. while (PyDict_Next(kwds, &pos, &key, &value)) {
  4130. name = first_kw_arg;
  4131. while (*name && (**name != key)) name++;
  4132. if (*name) {
  4133. values[name-argnames] = value;
  4134. continue;
  4135. }
  4136. name = first_kw_arg;
  4137. #if PY_MAJOR_VERSION < 3
  4138. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  4139. while (*name) {
  4140. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  4141. && _PyString_Eq(**name, key)) {
  4142. values[name-argnames] = value;
  4143. break;
  4144. }
  4145. name++;
  4146. }
  4147. if (*name) continue;
  4148. else {
  4149. PyObject*** argname = argnames;
  4150. while (argname != first_kw_arg) {
  4151. if ((**argname == key) || (
  4152. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  4153. && _PyString_Eq(**argname, key))) {
  4154. goto arg_passed_twice;
  4155. }
  4156. argname++;
  4157. }
  4158. }
  4159. } else
  4160. #endif
  4161. if (likely(PyUnicode_Check(key))) {
  4162. while (*name) {
  4163. int cmp = (**name == key) ? 0 :
  4164. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  4165. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  4166. #endif
  4167. PyUnicode_Compare(**name, key);
  4168. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  4169. if (cmp == 0) {
  4170. values[name-argnames] = value;
  4171. break;
  4172. }
  4173. name++;
  4174. }
  4175. if (*name) continue;
  4176. else {
  4177. PyObject*** argname = argnames;
  4178. while (argname != first_kw_arg) {
  4179. int cmp = (**argname == key) ? 0 :
  4180. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  4181. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  4182. #endif
  4183. PyUnicode_Compare(**argname, key);
  4184. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  4185. if (cmp == 0) goto arg_passed_twice;
  4186. argname++;
  4187. }
  4188. }
  4189. } else
  4190. goto invalid_keyword_type;
  4191. if (kwds2) {
  4192. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  4193. } else {
  4194. goto invalid_keyword;
  4195. }
  4196. }
  4197. return 0;
  4198. arg_passed_twice:
  4199. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  4200. goto bad;
  4201. invalid_keyword_type:
  4202. PyErr_Format(PyExc_TypeError,
  4203. "%.200s() keywords must be strings", function_name);
  4204. goto bad;
  4205. invalid_keyword:
  4206. PyErr_Format(PyExc_TypeError,
  4207. #if PY_MAJOR_VERSION < 3
  4208. "%.200s() got an unexpected keyword argument '%.200s'",
  4209. function_name, PyString_AsString(key));
  4210. #else
  4211. "%s() got an unexpected keyword argument '%U'",
  4212. function_name, key);
  4213. #endif
  4214. bad:
  4215. return -1;
  4216. }
  4217. /* ArgTypeTest */
  4218. static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
  4219. PyErr_Format(PyExc_TypeError,
  4220. "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
  4221. name, type->tp_name, Py_TYPE(obj)->tp_name);
  4222. }
  4223. static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
  4224. const char *name, int exact)
  4225. {
  4226. if (unlikely(!type)) {
  4227. PyErr_SetString(PyExc_SystemError, "Missing type object");
  4228. return 0;
  4229. }
  4230. if (none_allowed && obj == Py_None) return 1;
  4231. else if (exact) {
  4232. if (likely(Py_TYPE(obj) == type)) return 1;
  4233. #if PY_MAJOR_VERSION == 2
  4234. else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
  4235. #endif
  4236. }
  4237. else {
  4238. if (likely(PyObject_TypeCheck(obj, type))) return 1;
  4239. }
  4240. __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
  4241. return 0;
  4242. }
  4243. /* BufferFormatCheck */
  4244. static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
  4245. unsigned int n = 1;
  4246. return *(unsigned char*)(&n) != 0;
  4247. }
  4248. static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
  4249. __Pyx_BufFmt_StackElem* stack,
  4250. __Pyx_TypeInfo* type) {
  4251. stack[0].field = &ctx->root;
  4252. stack[0].parent_offset = 0;
  4253. ctx->root.type = type;
  4254. ctx->root.name = "buffer dtype";
  4255. ctx->root.offset = 0;
  4256. ctx->head = stack;
  4257. ctx->head->field = &ctx->root;
  4258. ctx->fmt_offset = 0;
  4259. ctx->head->parent_offset = 0;
  4260. ctx->new_packmode = '@';
  4261. ctx->enc_packmode = '@';
  4262. ctx->new_count = 1;
  4263. ctx->enc_count = 0;
  4264. ctx->enc_type = 0;
  4265. ctx->is_complex = 0;
  4266. ctx->is_valid_array = 0;
  4267. ctx->struct_alignment = 0;
  4268. while (type->typegroup == 'S') {
  4269. ++ctx->head;
  4270. ctx->head->field = type->fields;
  4271. ctx->head->parent_offset = 0;
  4272. type = type->fields->type;
  4273. }
  4274. }
  4275. static int __Pyx_BufFmt_ParseNumber(const char** ts) {
  4276. int count;
  4277. const char* t = *ts;
  4278. if (*t < '0' || *t > '9') {
  4279. return -1;
  4280. } else {
  4281. count = *t++ - '0';
  4282. while (*t >= '0' && *t < '9') {
  4283. count *= 10;
  4284. count += *t++ - '0';
  4285. }
  4286. }
  4287. *ts = t;
  4288. return count;
  4289. }
  4290. static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
  4291. int number = __Pyx_BufFmt_ParseNumber(ts);
  4292. if (number == -1)
  4293. PyErr_Format(PyExc_ValueError,\
  4294. "Does not understand character buffer dtype format string ('%c')", **ts);
  4295. return number;
  4296. }
  4297. static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  4298. PyErr_Format(PyExc_ValueError,
  4299. "Unexpected format string character: '%c'", ch);
  4300. }
  4301. static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  4302. switch (ch) {
  4303. case 'c': return "'char'";
  4304. case 'b': return "'signed char'";
  4305. case 'B': return "'unsigned char'";
  4306. case 'h': return "'short'";
  4307. case 'H': return "'unsigned short'";
  4308. case 'i': return "'int'";
  4309. case 'I': return "'unsigned int'";
  4310. case 'l': return "'long'";
  4311. case 'L': return "'unsigned long'";
  4312. case 'q': return "'long long'";
  4313. case 'Q': return "'unsigned long long'";
  4314. case 'f': return (is_complex ? "'complex float'" : "'float'");
  4315. case 'd': return (is_complex ? "'complex double'" : "'double'");
  4316. case 'g': return (is_complex ? "'complex long double'" : "'long double'");
  4317. case 'T': return "a struct";
  4318. case 'O': return "Python object";
  4319. case 'P': return "a pointer";
  4320. case 's': case 'p': return "a string";
  4321. case 0: return "end";
  4322. default: return "unparseable format string";
  4323. }
  4324. }
  4325. static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  4326. switch (ch) {
  4327. case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  4328. case 'h': case 'H': return 2;
  4329. case 'i': case 'I': case 'l': case 'L': return 4;
  4330. case 'q': case 'Q': return 8;
  4331. case 'f': return (is_complex ? 8 : 4);
  4332. case 'd': return (is_complex ? 16 : 8);
  4333. case 'g': {
  4334. PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
  4335. return 0;
  4336. }
  4337. case 'O': case 'P': return sizeof(void*);
  4338. default:
  4339. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  4340. return 0;
  4341. }
  4342. }
  4343. static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  4344. switch (ch) {
  4345. case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  4346. case 'h': case 'H': return sizeof(short);
  4347. case 'i': case 'I': return sizeof(int);
  4348. case 'l': case 'L': return sizeof(long);
  4349. #ifdef HAVE_LONG_LONG
  4350. case 'q': case 'Q': return sizeof(PY_LONG_LONG);
  4351. #endif
  4352. case 'f': return sizeof(float) * (is_complex ? 2 : 1);
  4353. case 'd': return sizeof(double) * (is_complex ? 2 : 1);
  4354. case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
  4355. case 'O': case 'P': return sizeof(void*);
  4356. default: {
  4357. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  4358. return 0;
  4359. }
  4360. }
  4361. }
  4362. typedef struct { char c; short x; } __Pyx_st_short;
  4363. typedef struct { char c; int x; } __Pyx_st_int;
  4364. typedef struct { char c; long x; } __Pyx_st_long;
  4365. typedef struct { char c; float x; } __Pyx_st_float;
  4366. typedef struct { char c; double x; } __Pyx_st_double;
  4367. typedef struct { char c; long double x; } __Pyx_st_longdouble;
  4368. typedef struct { char c; void *x; } __Pyx_st_void_p;
  4369. #ifdef HAVE_LONG_LONG
  4370. typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
  4371. #endif
  4372. static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  4373. switch (ch) {
  4374. case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  4375. case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
  4376. case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
  4377. case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
  4378. #ifdef HAVE_LONG_LONG
  4379. case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
  4380. #endif
  4381. case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
  4382. case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
  4383. case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
  4384. case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
  4385. default:
  4386. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  4387. return 0;
  4388. }
  4389. }
  4390. /* These are for computing the padding at the end of the struct to align
  4391. on the first member of the struct. This will probably the same as above,
  4392. but we don't have any guarantees.
  4393. */
  4394. typedef struct { short x; char c; } __Pyx_pad_short;
  4395. typedef struct { int x; char c; } __Pyx_pad_int;
  4396. typedef struct { long x; char c; } __Pyx_pad_long;
  4397. typedef struct { float x; char c; } __Pyx_pad_float;
  4398. typedef struct { double x; char c; } __Pyx_pad_double;
  4399. typedef struct { long double x; char c; } __Pyx_pad_longdouble;
  4400. typedef struct { void *x; char c; } __Pyx_pad_void_p;
  4401. #ifdef HAVE_LONG_LONG
  4402. typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
  4403. #endif
  4404. static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  4405. switch (ch) {
  4406. case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  4407. case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
  4408. case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
  4409. case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
  4410. #ifdef HAVE_LONG_LONG
  4411. case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
  4412. #endif
  4413. case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
  4414. case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
  4415. case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
  4416. case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
  4417. default:
  4418. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  4419. return 0;
  4420. }
  4421. }
  4422. static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  4423. switch (ch) {
  4424. case 'c':
  4425. return 'H';
  4426. case 'b': case 'h': case 'i':
  4427. case 'l': case 'q': case 's': case 'p':
  4428. return 'I';
  4429. case 'B': case 'H': case 'I': case 'L': case 'Q':
  4430. return 'U';
  4431. case 'f': case 'd': case 'g':
  4432. return (is_complex ? 'C' : 'R');
  4433. case 'O':
  4434. return 'O';
  4435. case 'P':
  4436. return 'P';
  4437. default: {
  4438. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  4439. return 0;
  4440. }
  4441. }
  4442. }
  4443. static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  4444. if (ctx->head == NULL || ctx->head->field == &ctx->root) {
  4445. const char* expected;
  4446. const char* quote;
  4447. if (ctx->head == NULL) {
  4448. expected = "end";
  4449. quote = "";
  4450. } else {
  4451. expected = ctx->head->field->type->name;
  4452. quote = "'";
  4453. }
  4454. PyErr_Format(PyExc_ValueError,
  4455. "Buffer dtype mismatch, expected %s%s%s but got %s",
  4456. quote, expected, quote,
  4457. __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  4458. } else {
  4459. __Pyx_StructField* field = ctx->head->field;
  4460. __Pyx_StructField* parent = (ctx->head - 1)->field;
  4461. PyErr_Format(PyExc_ValueError,
  4462. "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
  4463. field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
  4464. parent->type->name, field->name);
  4465. }
  4466. }
  4467. static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  4468. char group;
  4469. size_t size, offset, arraysize = 1;
  4470. if (ctx->enc_type == 0) return 0;
  4471. if (ctx->head->field->type->arraysize[0]) {
  4472. int i, ndim = 0;
  4473. if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
  4474. ctx->is_valid_array = ctx->head->field->type->ndim == 1;
  4475. ndim = 1;
  4476. if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
  4477. PyErr_Format(PyExc_ValueError,
  4478. "Expected a dimension of size %zu, got %zu",
  4479. ctx->head->field->type->arraysize[0], ctx->enc_count);
  4480. return -1;
  4481. }
  4482. }
  4483. if (!ctx->is_valid_array) {
  4484. PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
  4485. ctx->head->field->type->ndim, ndim);
  4486. return -1;
  4487. }
  4488. for (i = 0; i < ctx->head->field->type->ndim; i++) {
  4489. arraysize *= ctx->head->field->type->arraysize[i];
  4490. }
  4491. ctx->is_valid_array = 0;
  4492. ctx->enc_count = 1;
  4493. }
  4494. group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  4495. do {
  4496. __Pyx_StructField* field = ctx->head->field;
  4497. __Pyx_TypeInfo* type = field->type;
  4498. if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
  4499. size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
  4500. } else {
  4501. size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
  4502. }
  4503. if (ctx->enc_packmode == '@') {
  4504. size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
  4505. size_t align_mod_offset;
  4506. if (align_at == 0) return -1;
  4507. align_mod_offset = ctx->fmt_offset % align_at;
  4508. if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
  4509. if (ctx->struct_alignment == 0)
  4510. ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
  4511. ctx->is_complex);
  4512. }
  4513. if (type->size != size || type->typegroup != group) {
  4514. if (type->typegroup == 'C' && type->fields != NULL) {
  4515. size_t parent_offset = ctx->head->parent_offset + field->offset;
  4516. ++ctx->head;
  4517. ctx->head->field = type->fields;
  4518. ctx->head->parent_offset = parent_offset;
  4519. continue;
  4520. }
  4521. if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
  4522. } else {
  4523. __Pyx_BufFmt_RaiseExpected(ctx);
  4524. return -1;
  4525. }
  4526. }
  4527. offset = ctx->head->parent_offset + field->offset;
  4528. if (ctx->fmt_offset != offset) {
  4529. PyErr_Format(PyExc_ValueError,
  4530. "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
  4531. (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
  4532. return -1;
  4533. }
  4534. ctx->fmt_offset += size;
  4535. if (arraysize)
  4536. ctx->fmt_offset += (arraysize - 1) * size;
  4537. --ctx->enc_count;
  4538. while (1) {
  4539. if (field == &ctx->root) {
  4540. ctx->head = NULL;
  4541. if (ctx->enc_count != 0) {
  4542. __Pyx_BufFmt_RaiseExpected(ctx);
  4543. return -1;
  4544. }
  4545. break;
  4546. }
  4547. ctx->head->field = ++field;
  4548. if (field->type == NULL) {
  4549. --ctx->head;
  4550. field = ctx->head->field;
  4551. continue;
  4552. } else if (field->type->typegroup == 'S') {
  4553. size_t parent_offset = ctx->head->parent_offset + field->offset;
  4554. if (field->type->fields->type == NULL) continue;
  4555. field = field->type->fields;
  4556. ++ctx->head;
  4557. ctx->head->field = field;
  4558. ctx->head->parent_offset = parent_offset;
  4559. break;
  4560. } else {
  4561. break;
  4562. }
  4563. }
  4564. } while (ctx->enc_count);
  4565. ctx->enc_type = 0;
  4566. ctx->is_complex = 0;
  4567. return 0;
  4568. }
  4569. static CYTHON_INLINE PyObject *
  4570. __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
  4571. {
  4572. const char *ts = *tsp;
  4573. int i = 0, number;
  4574. int ndim = ctx->head->field->type->ndim;
  4575. ;
  4576. ++ts;
  4577. if (ctx->new_count != 1) {
  4578. PyErr_SetString(PyExc_ValueError,
  4579. "Cannot handle repeated arrays in format string");
  4580. return NULL;
  4581. }
  4582. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  4583. while (*ts && *ts != ')') {
  4584. switch (*ts) {
  4585. case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue;
  4586. default: break;
  4587. }
  4588. number = __Pyx_BufFmt_ExpectNumber(&ts);
  4589. if (number == -1) return NULL;
  4590. if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
  4591. return PyErr_Format(PyExc_ValueError,
  4592. "Expected a dimension of size %zu, got %d",
  4593. ctx->head->field->type->arraysize[i], number);
  4594. if (*ts != ',' && *ts != ')')
  4595. return PyErr_Format(PyExc_ValueError,
  4596. "Expected a comma in format string, got '%c'", *ts);
  4597. if (*ts == ',') ts++;
  4598. i++;
  4599. }
  4600. if (i != ndim)
  4601. return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
  4602. ctx->head->field->type->ndim, i);
  4603. if (!*ts) {
  4604. PyErr_SetString(PyExc_ValueError,
  4605. "Unexpected end of format string, expected ')'");
  4606. return NULL;
  4607. }
  4608. ctx->is_valid_array = 1;
  4609. ctx->new_count = 1;
  4610. *tsp = ++ts;
  4611. return Py_None;
  4612. }
  4613. static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  4614. int got_Z = 0;
  4615. while (1) {
  4616. switch(*ts) {
  4617. case 0:
  4618. if (ctx->enc_type != 0 && ctx->head == NULL) {
  4619. __Pyx_BufFmt_RaiseExpected(ctx);
  4620. return NULL;
  4621. }
  4622. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  4623. if (ctx->head != NULL) {
  4624. __Pyx_BufFmt_RaiseExpected(ctx);
  4625. return NULL;
  4626. }
  4627. return ts;
  4628. case ' ':
  4629. case '\r':
  4630. case '\n':
  4631. ++ts;
  4632. break;
  4633. case '<':
  4634. if (!__Pyx_IsLittleEndian()) {
  4635. PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
  4636. return NULL;
  4637. }
  4638. ctx->new_packmode = '=';
  4639. ++ts;
  4640. break;
  4641. case '>':
  4642. case '!':
  4643. if (__Pyx_IsLittleEndian()) {
  4644. PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
  4645. return NULL;
  4646. }
  4647. ctx->new_packmode = '=';
  4648. ++ts;
  4649. break;
  4650. case '=':
  4651. case '@':
  4652. case '^':
  4653. ctx->new_packmode = *ts++;
  4654. break;
  4655. case 'T':
  4656. {
  4657. const char* ts_after_sub;
  4658. size_t i, struct_count = ctx->new_count;
  4659. size_t struct_alignment = ctx->struct_alignment;
  4660. ctx->new_count = 1;
  4661. ++ts;
  4662. if (*ts != '{') {
  4663. PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
  4664. return NULL;
  4665. }
  4666. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  4667. ctx->enc_type = 0;
  4668. ctx->enc_count = 0;
  4669. ctx->struct_alignment = 0;
  4670. ++ts;
  4671. ts_after_sub = ts;
  4672. for (i = 0; i != struct_count; ++i) {
  4673. ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
  4674. if (!ts_after_sub) return NULL;
  4675. }
  4676. ts = ts_after_sub;
  4677. if (struct_alignment) ctx->struct_alignment = struct_alignment;
  4678. }
  4679. break;
  4680. case '}':
  4681. {
  4682. size_t alignment = ctx->struct_alignment;
  4683. ++ts;
  4684. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  4685. ctx->enc_type = 0;
  4686. if (alignment && ctx->fmt_offset % alignment) {
  4687. ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
  4688. }
  4689. }
  4690. return ts;
  4691. case 'x':
  4692. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  4693. ctx->fmt_offset += ctx->new_count;
  4694. ctx->new_count = 1;
  4695. ctx->enc_count = 0;
  4696. ctx->enc_type = 0;
  4697. ctx->enc_packmode = ctx->new_packmode;
  4698. ++ts;
  4699. break;
  4700. case 'Z':
  4701. got_Z = 1;
  4702. ++ts;
  4703. if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
  4704. __Pyx_BufFmt_RaiseUnexpectedChar('Z');
  4705. return NULL;
  4706. }
  4707. case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
  4708. case 'l': case 'L': case 'q': case 'Q':
  4709. case 'f': case 'd': case 'g':
  4710. case 'O': case 'p':
  4711. if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
  4712. ctx->enc_packmode == ctx->new_packmode) {
  4713. ctx->enc_count += ctx->new_count;
  4714. ctx->new_count = 1;
  4715. got_Z = 0;
  4716. ++ts;
  4717. break;
  4718. }
  4719. case 's':
  4720. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  4721. ctx->enc_count = ctx->new_count;
  4722. ctx->enc_packmode = ctx->new_packmode;
  4723. ctx->enc_type = *ts;
  4724. ctx->is_complex = got_Z;
  4725. ++ts;
  4726. ctx->new_count = 1;
  4727. got_Z = 0;
  4728. break;
  4729. case ':':
  4730. ++ts;
  4731. while(*ts != ':') ++ts;
  4732. ++ts;
  4733. break;
  4734. case '(':
  4735. if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
  4736. break;
  4737. default:
  4738. {
  4739. int number = __Pyx_BufFmt_ExpectNumber(&ts);
  4740. if (number == -1) return NULL;
  4741. ctx->new_count = (size_t)number;
  4742. }
  4743. }
  4744. }
  4745. }
  4746. static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  4747. buf->buf = NULL;
  4748. buf->obj = NULL;
  4749. buf->strides = __Pyx_zeros;
  4750. buf->shape = __Pyx_zeros;
  4751. buf->suboffsets = __Pyx_minusones;
  4752. }
  4753. static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
  4754. Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags,
  4755. int nd, int cast, __Pyx_BufFmt_StackElem* stack)
  4756. {
  4757. if (obj == Py_None || obj == NULL) {
  4758. __Pyx_ZeroBuffer(buf);
  4759. return 0;
  4760. }
  4761. buf->buf = NULL;
  4762. if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  4763. if (buf->ndim != nd) {
  4764. PyErr_Format(PyExc_ValueError,
  4765. "Buffer has wrong number of dimensions (expected %d, got %d)",
  4766. nd, buf->ndim);
  4767. goto fail;
  4768. }
  4769. if (!cast) {
  4770. __Pyx_BufFmt_Context ctx;
  4771. __Pyx_BufFmt_Init(&ctx, stack, dtype);
  4772. if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  4773. }
  4774. if ((unsigned)buf->itemsize != dtype->size) {
  4775. PyErr_Format(PyExc_ValueError,
  4776. "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
  4777. buf->itemsize, (buf->itemsize > 1) ? "s" : "",
  4778. dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
  4779. goto fail;
  4780. }
  4781. if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  4782. return 0;
  4783. fail:;
  4784. __Pyx_ZeroBuffer(buf);
  4785. return -1;
  4786. }
  4787. static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  4788. if (info->buf == NULL) return;
  4789. if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  4790. __Pyx_ReleaseBuffer(info);
  4791. }
  4792. /* GetBuiltinName */
  4793. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  4794. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  4795. if (unlikely(!result)) {
  4796. PyErr_Format(PyExc_NameError,
  4797. #if PY_MAJOR_VERSION >= 3
  4798. "name '%U' is not defined", name);
  4799. #else
  4800. "name '%.200s' is not defined", PyString_AS_STRING(name));
  4801. #endif
  4802. }
  4803. return result;
  4804. }
  4805. /* GetModuleGlobalName */
  4806. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  4807. PyObject *result;
  4808. #if CYTHON_COMPILING_IN_CPYTHON
  4809. result = PyDict_GetItem(__pyx_d, name);
  4810. if (likely(result)) {
  4811. Py_INCREF(result);
  4812. } else {
  4813. #else
  4814. result = PyObject_GetItem(__pyx_d, name);
  4815. if (!result) {
  4816. PyErr_Clear();
  4817. #endif
  4818. result = __Pyx_GetBuiltinName(name);
  4819. }
  4820. return result;
  4821. }
  4822. /* PyObjectCall */
  4823. #if CYTHON_COMPILING_IN_CPYTHON
  4824. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  4825. PyObject *result;
  4826. ternaryfunc call = func->ob_type->tp_call;
  4827. if (unlikely(!call))
  4828. return PyObject_Call(func, arg, kw);
  4829. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  4830. return NULL;
  4831. result = (*call)(func, arg, kw);
  4832. Py_LeaveRecursiveCall();
  4833. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  4834. PyErr_SetString(
  4835. PyExc_SystemError,
  4836. "NULL result without error in PyObject_Call");
  4837. }
  4838. return result;
  4839. }
  4840. #endif
  4841. /* ExtTypeTest */
  4842. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
  4843. if (unlikely(!type)) {
  4844. PyErr_SetString(PyExc_SystemError, "Missing type object");
  4845. return 0;
  4846. }
  4847. if (likely(PyObject_TypeCheck(obj, type)))
  4848. return 1;
  4849. PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
  4850. Py_TYPE(obj)->tp_name, type->tp_name);
  4851. return 0;
  4852. }
  4853. /* PyObjectCallMethO */
  4854. #if CYTHON_COMPILING_IN_CPYTHON
  4855. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  4856. PyObject *self, *result;
  4857. PyCFunction cfunc;
  4858. cfunc = PyCFunction_GET_FUNCTION(func);
  4859. self = PyCFunction_GET_SELF(func);
  4860. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  4861. return NULL;
  4862. result = cfunc(self, arg);
  4863. Py_LeaveRecursiveCall();
  4864. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  4865. PyErr_SetString(
  4866. PyExc_SystemError,
  4867. "NULL result without error in PyObject_Call");
  4868. }
  4869. return result;
  4870. }
  4871. #endif
  4872. /* PyObjectCallOneArg */
  4873. #if CYTHON_COMPILING_IN_CPYTHON
  4874. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4875. PyObject *result;
  4876. PyObject *args = PyTuple_New(1);
  4877. if (unlikely(!args)) return NULL;
  4878. Py_INCREF(arg);
  4879. PyTuple_SET_ITEM(args, 0, arg);
  4880. result = __Pyx_PyObject_Call(func, args, NULL);
  4881. Py_DECREF(args);
  4882. return result;
  4883. }
  4884. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4885. #ifdef __Pyx_CyFunction_USED
  4886. if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
  4887. #else
  4888. if (likely(PyCFunction_Check(func))) {
  4889. #endif
  4890. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  4891. return __Pyx_PyObject_CallMethO(func, arg);
  4892. }
  4893. }
  4894. return __Pyx__PyObject_CallOneArg(func, arg);
  4895. }
  4896. #else
  4897. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4898. PyObject *result;
  4899. PyObject *args = PyTuple_Pack(1, arg);
  4900. if (unlikely(!args)) return NULL;
  4901. result = __Pyx_PyObject_Call(func, args, NULL);
  4902. Py_DECREF(args);
  4903. return result;
  4904. }
  4905. #endif
  4906. /* PyObjectCallNoArg */
  4907. #if CYTHON_COMPILING_IN_CPYTHON
  4908. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  4909. #ifdef __Pyx_CyFunction_USED
  4910. if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
  4911. #else
  4912. if (likely(PyCFunction_Check(func))) {
  4913. #endif
  4914. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  4915. return __Pyx_PyObject_CallMethO(func, NULL);
  4916. }
  4917. }
  4918. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  4919. }
  4920. #endif
  4921. /* BufferIndexError */
  4922. static void __Pyx_RaiseBufferIndexError(int axis) {
  4923. PyErr_Format(PyExc_IndexError,
  4924. "Out of bounds on buffer access (axis %d)", axis);
  4925. }
  4926. /* SliceObject */
  4927. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
  4928. Py_ssize_t cstart, Py_ssize_t cstop,
  4929. PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
  4930. int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
  4931. #if CYTHON_COMPILING_IN_CPYTHON
  4932. PyMappingMethods* mp;
  4933. #if PY_MAJOR_VERSION < 3
  4934. PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
  4935. if (likely(ms && ms->sq_slice)) {
  4936. if (!has_cstart) {
  4937. if (_py_start && (*_py_start != Py_None)) {
  4938. cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
  4939. if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
  4940. } else
  4941. cstart = 0;
  4942. }
  4943. if (!has_cstop) {
  4944. if (_py_stop && (*_py_stop != Py_None)) {
  4945. cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
  4946. if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
  4947. } else
  4948. cstop = PY_SSIZE_T_MAX;
  4949. }
  4950. if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
  4951. Py_ssize_t l = ms->sq_length(obj);
  4952. if (likely(l >= 0)) {
  4953. if (cstop < 0) {
  4954. cstop += l;
  4955. if (cstop < 0) cstop = 0;
  4956. }
  4957. if (cstart < 0) {
  4958. cstart += l;
  4959. if (cstart < 0) cstart = 0;
  4960. }
  4961. } else {
  4962. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  4963. goto bad;
  4964. PyErr_Clear();
  4965. }
  4966. }
  4967. return ms->sq_slice(obj, cstart, cstop);
  4968. }
  4969. #endif
  4970. mp = Py_TYPE(obj)->tp_as_mapping;
  4971. if (likely(mp && mp->mp_subscript))
  4972. #endif
  4973. {
  4974. PyObject* result;
  4975. PyObject *py_slice, *py_start, *py_stop;
  4976. if (_py_slice) {
  4977. py_slice = *_py_slice;
  4978. } else {
  4979. PyObject* owned_start = NULL;
  4980. PyObject* owned_stop = NULL;
  4981. if (_py_start) {
  4982. py_start = *_py_start;
  4983. } else {
  4984. if (has_cstart) {
  4985. owned_start = py_start = PyInt_FromSsize_t(cstart);
  4986. if (unlikely(!py_start)) goto bad;
  4987. } else
  4988. py_start = Py_None;
  4989. }
  4990. if (_py_stop) {
  4991. py_stop = *_py_stop;
  4992. } else {
  4993. if (has_cstop) {
  4994. owned_stop = py_stop = PyInt_FromSsize_t(cstop);
  4995. if (unlikely(!py_stop)) {
  4996. Py_XDECREF(owned_start);
  4997. goto bad;
  4998. }
  4999. } else
  5000. py_stop = Py_None;
  5001. }
  5002. py_slice = PySlice_New(py_start, py_stop, Py_None);
  5003. Py_XDECREF(owned_start);
  5004. Py_XDECREF(owned_stop);
  5005. if (unlikely(!py_slice)) goto bad;
  5006. }
  5007. #if CYTHON_COMPILING_IN_CPYTHON
  5008. result = mp->mp_subscript(obj, py_slice);
  5009. #else
  5010. result = PyObject_GetItem(obj, py_slice);
  5011. #endif
  5012. if (!_py_slice) {
  5013. Py_DECREF(py_slice);
  5014. }
  5015. return result;
  5016. }
  5017. PyErr_Format(PyExc_TypeError,
  5018. "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
  5019. bad:
  5020. return NULL;
  5021. }
  5022. /* BufferFallbackError */
  5023. static void __Pyx_RaiseBufferFallbackError(void) {
  5024. PyErr_SetString(PyExc_ValueError,
  5025. "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
  5026. }
  5027. /* PyErrFetchRestore */
  5028. #if CYTHON_COMPILING_IN_CPYTHON
  5029. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  5030. PyObject *tmp_type, *tmp_value, *tmp_tb;
  5031. tmp_type = tstate->curexc_type;
  5032. tmp_value = tstate->curexc_value;
  5033. tmp_tb = tstate->curexc_traceback;
  5034. tstate->curexc_type = type;
  5035. tstate->curexc_value = value;
  5036. tstate->curexc_traceback = tb;
  5037. Py_XDECREF(tmp_type);
  5038. Py_XDECREF(tmp_value);
  5039. Py_XDECREF(tmp_tb);
  5040. }
  5041. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  5042. *type = tstate->curexc_type;
  5043. *value = tstate->curexc_value;
  5044. *tb = tstate->curexc_traceback;
  5045. tstate->curexc_type = 0;
  5046. tstate->curexc_value = 0;
  5047. tstate->curexc_traceback = 0;
  5048. }
  5049. #endif
  5050. /* RaiseException */
  5051. #if PY_MAJOR_VERSION < 3
  5052. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  5053. CYTHON_UNUSED PyObject *cause) {
  5054. __Pyx_PyThreadState_declare
  5055. Py_XINCREF(type);
  5056. if (!value || value == Py_None)
  5057. value = NULL;
  5058. else
  5059. Py_INCREF(value);
  5060. if (!tb || tb == Py_None)
  5061. tb = NULL;
  5062. else {
  5063. Py_INCREF(tb);
  5064. if (!PyTraceBack_Check(tb)) {
  5065. PyErr_SetString(PyExc_TypeError,
  5066. "raise: arg 3 must be a traceback or None");
  5067. goto raise_error;
  5068. }
  5069. }
  5070. if (PyType_Check(type)) {
  5071. #if CYTHON_COMPILING_IN_PYPY
  5072. if (!value) {
  5073. Py_INCREF(Py_None);
  5074. value = Py_None;
  5075. }
  5076. #endif
  5077. PyErr_NormalizeException(&type, &value, &tb);
  5078. } else {
  5079. if (value) {
  5080. PyErr_SetString(PyExc_TypeError,
  5081. "instance exception may not have a separate value");
  5082. goto raise_error;
  5083. }
  5084. value = type;
  5085. type = (PyObject*) Py_TYPE(type);
  5086. Py_INCREF(type);
  5087. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  5088. PyErr_SetString(PyExc_TypeError,
  5089. "raise: exception class must be a subclass of BaseException");
  5090. goto raise_error;
  5091. }
  5092. }
  5093. __Pyx_PyThreadState_assign
  5094. __Pyx_ErrRestore(type, value, tb);
  5095. return;
  5096. raise_error:
  5097. Py_XDECREF(value);
  5098. Py_XDECREF(type);
  5099. Py_XDECREF(tb);
  5100. return;
  5101. }
  5102. #else
  5103. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  5104. PyObject* owned_instance = NULL;
  5105. if (tb == Py_None) {
  5106. tb = 0;
  5107. } else if (tb && !PyTraceBack_Check(tb)) {
  5108. PyErr_SetString(PyExc_TypeError,
  5109. "raise: arg 3 must be a traceback or None");
  5110. goto bad;
  5111. }
  5112. if (value == Py_None)
  5113. value = 0;
  5114. if (PyExceptionInstance_Check(type)) {
  5115. if (value) {
  5116. PyErr_SetString(PyExc_TypeError,
  5117. "instance exception may not have a separate value");
  5118. goto bad;
  5119. }
  5120. value = type;
  5121. type = (PyObject*) Py_TYPE(value);
  5122. } else if (PyExceptionClass_Check(type)) {
  5123. PyObject *instance_class = NULL;
  5124. if (value && PyExceptionInstance_Check(value)) {
  5125. instance_class = (PyObject*) Py_TYPE(value);
  5126. if (instance_class != type) {
  5127. int is_subclass = PyObject_IsSubclass(instance_class, type);
  5128. if (!is_subclass) {
  5129. instance_class = NULL;
  5130. } else if (unlikely(is_subclass == -1)) {
  5131. goto bad;
  5132. } else {
  5133. type = instance_class;
  5134. }
  5135. }
  5136. }
  5137. if (!instance_class) {
  5138. PyObject *args;
  5139. if (!value)
  5140. args = PyTuple_New(0);
  5141. else if (PyTuple_Check(value)) {
  5142. Py_INCREF(value);
  5143. args = value;
  5144. } else
  5145. args = PyTuple_Pack(1, value);
  5146. if (!args)
  5147. goto bad;
  5148. owned_instance = PyObject_Call(type, args, NULL);
  5149. Py_DECREF(args);
  5150. if (!owned_instance)
  5151. goto bad;
  5152. value = owned_instance;
  5153. if (!PyExceptionInstance_Check(value)) {
  5154. PyErr_Format(PyExc_TypeError,
  5155. "calling %R should have returned an instance of "
  5156. "BaseException, not %R",
  5157. type, Py_TYPE(value));
  5158. goto bad;
  5159. }
  5160. }
  5161. } else {
  5162. PyErr_SetString(PyExc_TypeError,
  5163. "raise: exception class must be a subclass of BaseException");
  5164. goto bad;
  5165. }
  5166. #if PY_VERSION_HEX >= 0x03030000
  5167. if (cause) {
  5168. #else
  5169. if (cause && cause != Py_None) {
  5170. #endif
  5171. PyObject *fixed_cause;
  5172. if (cause == Py_None) {
  5173. fixed_cause = NULL;
  5174. } else if (PyExceptionClass_Check(cause)) {
  5175. fixed_cause = PyObject_CallObject(cause, NULL);
  5176. if (fixed_cause == NULL)
  5177. goto bad;
  5178. } else if (PyExceptionInstance_Check(cause)) {
  5179. fixed_cause = cause;
  5180. Py_INCREF(fixed_cause);
  5181. } else {
  5182. PyErr_SetString(PyExc_TypeError,
  5183. "exception causes must derive from "
  5184. "BaseException");
  5185. goto bad;
  5186. }
  5187. PyException_SetCause(value, fixed_cause);
  5188. }
  5189. PyErr_SetObject(type, value);
  5190. if (tb) {
  5191. #if CYTHON_COMPILING_IN_PYPY
  5192. PyObject *tmp_type, *tmp_value, *tmp_tb;
  5193. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  5194. Py_INCREF(tb);
  5195. PyErr_Restore(tmp_type, tmp_value, tb);
  5196. Py_XDECREF(tmp_tb);
  5197. #else
  5198. PyThreadState *tstate = PyThreadState_GET();
  5199. PyObject* tmp_tb = tstate->curexc_traceback;
  5200. if (tb != tmp_tb) {
  5201. Py_INCREF(tb);
  5202. tstate->curexc_traceback = tb;
  5203. Py_XDECREF(tmp_tb);
  5204. }
  5205. #endif
  5206. }
  5207. bad:
  5208. Py_XDECREF(owned_instance);
  5209. return;
  5210. }
  5211. #endif
  5212. /* RaiseTooManyValuesToUnpack */
  5213. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  5214. PyErr_Format(PyExc_ValueError,
  5215. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  5216. }
  5217. /* RaiseNeedMoreValuesToUnpack */
  5218. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  5219. PyErr_Format(PyExc_ValueError,
  5220. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  5221. index, (index == 1) ? "" : "s");
  5222. }
  5223. /* RaiseNoneIterError */
  5224. static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
  5225. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  5226. }
  5227. /* Import */
  5228. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  5229. PyObject *empty_list = 0;
  5230. PyObject *module = 0;
  5231. PyObject *global_dict = 0;
  5232. PyObject *empty_dict = 0;
  5233. PyObject *list;
  5234. #if PY_VERSION_HEX < 0x03030000
  5235. PyObject *py_import;
  5236. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  5237. if (!py_import)
  5238. goto bad;
  5239. #endif
  5240. if (from_list)
  5241. list = from_list;
  5242. else {
  5243. empty_list = PyList_New(0);
  5244. if (!empty_list)
  5245. goto bad;
  5246. list = empty_list;
  5247. }
  5248. global_dict = PyModule_GetDict(__pyx_m);
  5249. if (!global_dict)
  5250. goto bad;
  5251. empty_dict = PyDict_New();
  5252. if (!empty_dict)
  5253. goto bad;
  5254. {
  5255. #if PY_MAJOR_VERSION >= 3
  5256. if (level == -1) {
  5257. if (strchr(__Pyx_MODULE_NAME, '.')) {
  5258. #if PY_VERSION_HEX < 0x03030000
  5259. PyObject *py_level = PyInt_FromLong(1);
  5260. if (!py_level)
  5261. goto bad;
  5262. module = PyObject_CallFunctionObjArgs(py_import,
  5263. name, global_dict, empty_dict, list, py_level, NULL);
  5264. Py_DECREF(py_level);
  5265. #else
  5266. module = PyImport_ImportModuleLevelObject(
  5267. name, global_dict, empty_dict, list, 1);
  5268. #endif
  5269. if (!module) {
  5270. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  5271. goto bad;
  5272. PyErr_Clear();
  5273. }
  5274. }
  5275. level = 0;
  5276. }
  5277. #endif
  5278. if (!module) {
  5279. #if PY_VERSION_HEX < 0x03030000
  5280. PyObject *py_level = PyInt_FromLong(level);
  5281. if (!py_level)
  5282. goto bad;
  5283. module = PyObject_CallFunctionObjArgs(py_import,
  5284. name, global_dict, empty_dict, list, py_level, NULL);
  5285. Py_DECREF(py_level);
  5286. #else
  5287. module = PyImport_ImportModuleLevelObject(
  5288. name, global_dict, empty_dict, list, level);
  5289. #endif
  5290. }
  5291. }
  5292. bad:
  5293. #if PY_VERSION_HEX < 0x03030000
  5294. Py_XDECREF(py_import);
  5295. #endif
  5296. Py_XDECREF(empty_list);
  5297. Py_XDECREF(empty_dict);
  5298. return module;
  5299. }
  5300. /* CodeObjectCache */
  5301. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  5302. int start = 0, mid = 0, end = count - 1;
  5303. if (end >= 0 && code_line > entries[end].code_line) {
  5304. return count;
  5305. }
  5306. while (start < end) {
  5307. mid = start + (end - start) / 2;
  5308. if (code_line < entries[mid].code_line) {
  5309. end = mid;
  5310. } else if (code_line > entries[mid].code_line) {
  5311. start = mid + 1;
  5312. } else {
  5313. return mid;
  5314. }
  5315. }
  5316. if (code_line <= entries[mid].code_line) {
  5317. return mid;
  5318. } else {
  5319. return mid + 1;
  5320. }
  5321. }
  5322. static PyCodeObject *__pyx_find_code_object(int code_line) {
  5323. PyCodeObject* code_object;
  5324. int pos;
  5325. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  5326. return NULL;
  5327. }
  5328. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  5329. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  5330. return NULL;
  5331. }
  5332. code_object = __pyx_code_cache.entries[pos].code_object;
  5333. Py_INCREF(code_object);
  5334. return code_object;
  5335. }
  5336. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  5337. int pos, i;
  5338. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  5339. if (unlikely(!code_line)) {
  5340. return;
  5341. }
  5342. if (unlikely(!entries)) {
  5343. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  5344. if (likely(entries)) {
  5345. __pyx_code_cache.entries = entries;
  5346. __pyx_code_cache.max_count = 64;
  5347. __pyx_code_cache.count = 1;
  5348. entries[0].code_line = code_line;
  5349. entries[0].code_object = code_object;
  5350. Py_INCREF(code_object);
  5351. }
  5352. return;
  5353. }
  5354. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  5355. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  5356. PyCodeObject* tmp = entries[pos].code_object;
  5357. entries[pos].code_object = code_object;
  5358. Py_DECREF(tmp);
  5359. return;
  5360. }
  5361. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  5362. int new_max = __pyx_code_cache.max_count + 64;
  5363. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  5364. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  5365. if (unlikely(!entries)) {
  5366. return;
  5367. }
  5368. __pyx_code_cache.entries = entries;
  5369. __pyx_code_cache.max_count = new_max;
  5370. }
  5371. for (i=__pyx_code_cache.count; i>pos; i--) {
  5372. entries[i] = entries[i-1];
  5373. }
  5374. entries[pos].code_line = code_line;
  5375. entries[pos].code_object = code_object;
  5376. __pyx_code_cache.count++;
  5377. Py_INCREF(code_object);
  5378. }
  5379. /* AddTraceback */
  5380. #include "compile.h"
  5381. #include "frameobject.h"
  5382. #include "traceback.h"
  5383. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  5384. const char *funcname, int c_line,
  5385. int py_line, const char *filename) {
  5386. PyCodeObject *py_code = 0;
  5387. PyObject *py_srcfile = 0;
  5388. PyObject *py_funcname = 0;
  5389. #if PY_MAJOR_VERSION < 3
  5390. py_srcfile = PyString_FromString(filename);
  5391. #else
  5392. py_srcfile = PyUnicode_FromString(filename);
  5393. #endif
  5394. if (!py_srcfile) goto bad;
  5395. if (c_line) {
  5396. #if PY_MAJOR_VERSION < 3
  5397. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  5398. #else
  5399. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  5400. #endif
  5401. }
  5402. else {
  5403. #if PY_MAJOR_VERSION < 3
  5404. py_funcname = PyString_FromString(funcname);
  5405. #else
  5406. py_funcname = PyUnicode_FromString(funcname);
  5407. #endif
  5408. }
  5409. if (!py_funcname) goto bad;
  5410. py_code = __Pyx_PyCode_New(
  5411. 0,
  5412. 0,
  5413. 0,
  5414. 0,
  5415. 0,
  5416. __pyx_empty_bytes, /*PyObject *code,*/
  5417. __pyx_empty_tuple, /*PyObject *consts,*/
  5418. __pyx_empty_tuple, /*PyObject *names,*/
  5419. __pyx_empty_tuple, /*PyObject *varnames,*/
  5420. __pyx_empty_tuple, /*PyObject *freevars,*/
  5421. __pyx_empty_tuple, /*PyObject *cellvars,*/
  5422. py_srcfile, /*PyObject *filename,*/
  5423. py_funcname, /*PyObject *name,*/
  5424. py_line,
  5425. __pyx_empty_bytes /*PyObject *lnotab*/
  5426. );
  5427. Py_DECREF(py_srcfile);
  5428. Py_DECREF(py_funcname);
  5429. return py_code;
  5430. bad:
  5431. Py_XDECREF(py_srcfile);
  5432. Py_XDECREF(py_funcname);
  5433. return NULL;
  5434. }
  5435. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  5436. int py_line, const char *filename) {
  5437. PyCodeObject *py_code = 0;
  5438. PyFrameObject *py_frame = 0;
  5439. py_code = __pyx_find_code_object(c_line ? c_line : py_line);
  5440. if (!py_code) {
  5441. py_code = __Pyx_CreateCodeObjectForTraceback(
  5442. funcname, c_line, py_line, filename);
  5443. if (!py_code) goto bad;
  5444. __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
  5445. }
  5446. py_frame = PyFrame_New(
  5447. PyThreadState_GET(), /*PyThreadState *tstate,*/
  5448. py_code, /*PyCodeObject *code,*/
  5449. __pyx_d, /*PyObject *globals,*/
  5450. 0 /*PyObject *locals*/
  5451. );
  5452. if (!py_frame) goto bad;
  5453. py_frame->f_lineno = py_line;
  5454. PyTraceBack_Here(py_frame);
  5455. bad:
  5456. Py_XDECREF(py_code);
  5457. Py_XDECREF(py_frame);
  5458. }
  5459. #if PY_MAJOR_VERSION < 3
  5460. static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
  5461. if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
  5462. if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
  5463. PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
  5464. return -1;
  5465. }
  5466. static void __Pyx_ReleaseBuffer(Py_buffer *view) {
  5467. PyObject *obj = view->obj;
  5468. if (!obj) return;
  5469. if (PyObject_CheckBuffer(obj)) {
  5470. PyBuffer_Release(view);
  5471. return;
  5472. }
  5473. if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
  5474. Py_DECREF(obj);
  5475. view->obj = NULL;
  5476. }
  5477. #endif
  5478. /* CIntFromPyVerify */
  5479. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  5480. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  5481. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  5482. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  5483. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  5484. {\
  5485. func_type value = func_value;\
  5486. if (sizeof(target_type) < sizeof(func_type)) {\
  5487. if (unlikely(value != (func_type) (target_type) value)) {\
  5488. func_type zero = 0;\
  5489. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  5490. return (target_type) -1;\
  5491. if (is_unsigned && unlikely(value < zero))\
  5492. goto raise_neg_overflow;\
  5493. else\
  5494. goto raise_overflow;\
  5495. }\
  5496. }\
  5497. return (target_type) value;\
  5498. }
  5499. /* CIntToPy */
  5500. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  5501. const int neg_one = (int) -1, const_zero = (int) 0;
  5502. const int is_unsigned = neg_one > const_zero;
  5503. if (is_unsigned) {
  5504. if (sizeof(int) < sizeof(long)) {
  5505. return PyInt_FromLong((long) value);
  5506. } else if (sizeof(int) <= sizeof(unsigned long)) {
  5507. return PyLong_FromUnsignedLong((unsigned long) value);
  5508. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  5509. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  5510. }
  5511. } else {
  5512. if (sizeof(int) <= sizeof(long)) {
  5513. return PyInt_FromLong((long) value);
  5514. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  5515. return PyLong_FromLongLong((PY_LONG_LONG) value);
  5516. }
  5517. }
  5518. {
  5519. int one = 1; int little = (int)*(unsigned char *)&one;
  5520. unsigned char *bytes = (unsigned char *)&value;
  5521. return _PyLong_FromByteArray(bytes, sizeof(int),
  5522. little, !is_unsigned);
  5523. }
  5524. }
  5525. /* None */
  5526. #if CYTHON_CCOMPLEX
  5527. #ifdef __cplusplus
  5528. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
  5529. return ::std::complex< float >(x, y);
  5530. }
  5531. #else
  5532. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
  5533. return x + y*(__pyx_t_float_complex)_Complex_I;
  5534. }
  5535. #endif
  5536. #else
  5537. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
  5538. __pyx_t_float_complex z;
  5539. z.real = x;
  5540. z.imag = y;
  5541. return z;
  5542. }
  5543. #endif
  5544. /* None */
  5545. #if CYTHON_CCOMPLEX
  5546. #else
  5547. static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  5548. return (a.real == b.real) && (a.imag == b.imag);
  5549. }
  5550. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  5551. __pyx_t_float_complex z;
  5552. z.real = a.real + b.real;
  5553. z.imag = a.imag + b.imag;
  5554. return z;
  5555. }
  5556. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  5557. __pyx_t_float_complex z;
  5558. z.real = a.real - b.real;
  5559. z.imag = a.imag - b.imag;
  5560. return z;
  5561. }
  5562. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  5563. __pyx_t_float_complex z;
  5564. z.real = a.real * b.real - a.imag * b.imag;
  5565. z.imag = a.real * b.imag + a.imag * b.real;
  5566. return z;
  5567. }
  5568. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  5569. __pyx_t_float_complex z;
  5570. float denom = b.real * b.real + b.imag * b.imag;
  5571. z.real = (a.real * b.real + a.imag * b.imag) / denom;
  5572. z.imag = (a.imag * b.real - a.real * b.imag) / denom;
  5573. return z;
  5574. }
  5575. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
  5576. __pyx_t_float_complex z;
  5577. z.real = -a.real;
  5578. z.imag = -a.imag;
  5579. return z;
  5580. }
  5581. static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
  5582. return (a.real == 0) && (a.imag == 0);
  5583. }
  5584. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
  5585. __pyx_t_float_complex z;
  5586. z.real = a.real;
  5587. z.imag = -a.imag;
  5588. return z;
  5589. }
  5590. #if 1
  5591. static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
  5592. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  5593. return sqrtf(z.real*z.real + z.imag*z.imag);
  5594. #else
  5595. return hypotf(z.real, z.imag);
  5596. #endif
  5597. }
  5598. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  5599. __pyx_t_float_complex z;
  5600. float r, lnr, theta, z_r, z_theta;
  5601. if (b.imag == 0 && b.real == (int)b.real) {
  5602. if (b.real < 0) {
  5603. float denom = a.real * a.real + a.imag * a.imag;
  5604. a.real = a.real / denom;
  5605. a.imag = -a.imag / denom;
  5606. b.real = -b.real;
  5607. }
  5608. switch ((int)b.real) {
  5609. case 0:
  5610. z.real = 1;
  5611. z.imag = 0;
  5612. return z;
  5613. case 1:
  5614. return a;
  5615. case 2:
  5616. z = __Pyx_c_prodf(a, a);
  5617. return __Pyx_c_prodf(a, a);
  5618. case 3:
  5619. z = __Pyx_c_prodf(a, a);
  5620. return __Pyx_c_prodf(z, a);
  5621. case 4:
  5622. z = __Pyx_c_prodf(a, a);
  5623. return __Pyx_c_prodf(z, z);
  5624. }
  5625. }
  5626. if (a.imag == 0) {
  5627. if (a.real == 0) {
  5628. return a;
  5629. }
  5630. r = a.real;
  5631. theta = 0;
  5632. } else {
  5633. r = __Pyx_c_absf(a);
  5634. theta = atan2f(a.imag, a.real);
  5635. }
  5636. lnr = logf(r);
  5637. z_r = expf(lnr * b.real - theta * b.imag);
  5638. z_theta = theta * b.real + lnr * b.imag;
  5639. z.real = z_r * cosf(z_theta);
  5640. z.imag = z_r * sinf(z_theta);
  5641. return z;
  5642. }
  5643. #endif
  5644. #endif
  5645. /* None */
  5646. #if CYTHON_CCOMPLEX
  5647. #ifdef __cplusplus
  5648. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  5649. return ::std::complex< double >(x, y);
  5650. }
  5651. #else
  5652. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  5653. return x + y*(__pyx_t_double_complex)_Complex_I;
  5654. }
  5655. #endif
  5656. #else
  5657. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  5658. __pyx_t_double_complex z;
  5659. z.real = x;
  5660. z.imag = y;
  5661. return z;
  5662. }
  5663. #endif
  5664. /* None */
  5665. #if CYTHON_CCOMPLEX
  5666. #else
  5667. static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  5668. return (a.real == b.real) && (a.imag == b.imag);
  5669. }
  5670. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  5671. __pyx_t_double_complex z;
  5672. z.real = a.real + b.real;
  5673. z.imag = a.imag + b.imag;
  5674. return z;
  5675. }
  5676. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  5677. __pyx_t_double_complex z;
  5678. z.real = a.real - b.real;
  5679. z.imag = a.imag - b.imag;
  5680. return z;
  5681. }
  5682. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  5683. __pyx_t_double_complex z;
  5684. z.real = a.real * b.real - a.imag * b.imag;
  5685. z.imag = a.real * b.imag + a.imag * b.real;
  5686. return z;
  5687. }
  5688. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  5689. __pyx_t_double_complex z;
  5690. double denom = b.real * b.real + b.imag * b.imag;
  5691. z.real = (a.real * b.real + a.imag * b.imag) / denom;
  5692. z.imag = (a.imag * b.real - a.real * b.imag) / denom;
  5693. return z;
  5694. }
  5695. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
  5696. __pyx_t_double_complex z;
  5697. z.real = -a.real;
  5698. z.imag = -a.imag;
  5699. return z;
  5700. }
  5701. static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
  5702. return (a.real == 0) && (a.imag == 0);
  5703. }
  5704. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
  5705. __pyx_t_double_complex z;
  5706. z.real = a.real;
  5707. z.imag = -a.imag;
  5708. return z;
  5709. }
  5710. #if 1
  5711. static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
  5712. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  5713. return sqrt(z.real*z.real + z.imag*z.imag);
  5714. #else
  5715. return hypot(z.real, z.imag);
  5716. #endif
  5717. }
  5718. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  5719. __pyx_t_double_complex z;
  5720. double r, lnr, theta, z_r, z_theta;
  5721. if (b.imag == 0 && b.real == (int)b.real) {
  5722. if (b.real < 0) {
  5723. double denom = a.real * a.real + a.imag * a.imag;
  5724. a.real = a.real / denom;
  5725. a.imag = -a.imag / denom;
  5726. b.real = -b.real;
  5727. }
  5728. switch ((int)b.real) {
  5729. case 0:
  5730. z.real = 1;
  5731. z.imag = 0;
  5732. return z;
  5733. case 1:
  5734. return a;
  5735. case 2:
  5736. z = __Pyx_c_prod(a, a);
  5737. return __Pyx_c_prod(a, a);
  5738. case 3:
  5739. z = __Pyx_c_prod(a, a);
  5740. return __Pyx_c_prod(z, a);
  5741. case 4:
  5742. z = __Pyx_c_prod(a, a);
  5743. return __Pyx_c_prod(z, z);
  5744. }
  5745. }
  5746. if (a.imag == 0) {
  5747. if (a.real == 0) {
  5748. return a;
  5749. }
  5750. r = a.real;
  5751. theta = 0;
  5752. } else {
  5753. r = __Pyx_c_abs(a);
  5754. theta = atan2(a.imag, a.real);
  5755. }
  5756. lnr = log(r);
  5757. z_r = exp(lnr * b.real - theta * b.imag);
  5758. z_theta = theta * b.real + lnr * b.imag;
  5759. z.real = z_r * cos(z_theta);
  5760. z.imag = z_r * sin(z_theta);
  5761. return z;
  5762. }
  5763. #endif
  5764. #endif
  5765. /* CIntToPy */
  5766. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) {
  5767. const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0;
  5768. const int is_unsigned = neg_one > const_zero;
  5769. if (is_unsigned) {
  5770. if (sizeof(enum NPY_TYPES) < sizeof(long)) {
  5771. return PyInt_FromLong((long) value);
  5772. } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) {
  5773. return PyLong_FromUnsignedLong((unsigned long) value);
  5774. } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) {
  5775. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  5776. }
  5777. } else {
  5778. if (sizeof(enum NPY_TYPES) <= sizeof(long)) {
  5779. return PyInt_FromLong((long) value);
  5780. } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) {
  5781. return PyLong_FromLongLong((PY_LONG_LONG) value);
  5782. }
  5783. }
  5784. {
  5785. int one = 1; int little = (int)*(unsigned char *)&one;
  5786. unsigned char *bytes = (unsigned char *)&value;
  5787. return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES),
  5788. little, !is_unsigned);
  5789. }
  5790. }
  5791. /* CIntFromPy */
  5792. static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *x) {
  5793. const npy_int32 neg_one = (npy_int32) -1, const_zero = (npy_int32) 0;
  5794. const int is_unsigned = neg_one > const_zero;
  5795. #if PY_MAJOR_VERSION < 3
  5796. if (likely(PyInt_Check(x))) {
  5797. if (sizeof(npy_int32) < sizeof(long)) {
  5798. __PYX_VERIFY_RETURN_INT(npy_int32, long, PyInt_AS_LONG(x))
  5799. } else {
  5800. long val = PyInt_AS_LONG(x);
  5801. if (is_unsigned && unlikely(val < 0)) {
  5802. goto raise_neg_overflow;
  5803. }
  5804. return (npy_int32) val;
  5805. }
  5806. } else
  5807. #endif
  5808. if (likely(PyLong_Check(x))) {
  5809. if (is_unsigned) {
  5810. #if CYTHON_USE_PYLONG_INTERNALS
  5811. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5812. switch (Py_SIZE(x)) {
  5813. case 0: return (npy_int32) 0;
  5814. case 1: __PYX_VERIFY_RETURN_INT(npy_int32, digit, digits[0])
  5815. case 2:
  5816. if (8 * sizeof(npy_int32) > 1 * PyLong_SHIFT) {
  5817. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5818. __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5819. } else if (8 * sizeof(npy_int32) >= 2 * PyLong_SHIFT) {
  5820. return (npy_int32) (((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
  5821. }
  5822. }
  5823. break;
  5824. case 3:
  5825. if (8 * sizeof(npy_int32) > 2 * PyLong_SHIFT) {
  5826. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5827. __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5828. } else if (8 * sizeof(npy_int32) >= 3 * PyLong_SHIFT) {
  5829. return (npy_int32) (((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
  5830. }
  5831. }
  5832. break;
  5833. case 4:
  5834. if (8 * sizeof(npy_int32) > 3 * PyLong_SHIFT) {
  5835. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5836. __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5837. } else if (8 * sizeof(npy_int32) >= 4 * PyLong_SHIFT) {
  5838. return (npy_int32) (((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
  5839. }
  5840. }
  5841. break;
  5842. }
  5843. #endif
  5844. #if CYTHON_COMPILING_IN_CPYTHON
  5845. if (unlikely(Py_SIZE(x) < 0)) {
  5846. goto raise_neg_overflow;
  5847. }
  5848. #else
  5849. {
  5850. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  5851. if (unlikely(result < 0))
  5852. return (npy_int32) -1;
  5853. if (unlikely(result == 1))
  5854. goto raise_neg_overflow;
  5855. }
  5856. #endif
  5857. if (sizeof(npy_int32) <= sizeof(unsigned long)) {
  5858. __PYX_VERIFY_RETURN_INT_EXC(npy_int32, unsigned long, PyLong_AsUnsignedLong(x))
  5859. } else if (sizeof(npy_int32) <= sizeof(unsigned PY_LONG_LONG)) {
  5860. __PYX_VERIFY_RETURN_INT_EXC(npy_int32, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  5861. }
  5862. } else {
  5863. #if CYTHON_USE_PYLONG_INTERNALS
  5864. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5865. switch (Py_SIZE(x)) {
  5866. case 0: return (npy_int32) 0;
  5867. case -1: __PYX_VERIFY_RETURN_INT(npy_int32, sdigit, (sdigit) (-(sdigit)digits[0]))
  5868. case 1: __PYX_VERIFY_RETURN_INT(npy_int32, digit, +digits[0])
  5869. case -2:
  5870. if (8 * sizeof(npy_int32) - 1 > 1 * PyLong_SHIFT) {
  5871. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5872. __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5873. } else if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
  5874. return (npy_int32) (((npy_int32)-1)*(((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
  5875. }
  5876. }
  5877. break;
  5878. case 2:
  5879. if (8 * sizeof(npy_int32) > 1 * PyLong_SHIFT) {
  5880. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5881. __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5882. } else if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
  5883. return (npy_int32) ((((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
  5884. }
  5885. }
  5886. break;
  5887. case -3:
  5888. if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
  5889. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5890. __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5891. } else if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
  5892. return (npy_int32) (((npy_int32)-1)*(((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
  5893. }
  5894. }
  5895. break;
  5896. case 3:
  5897. if (8 * sizeof(npy_int32) > 2 * PyLong_SHIFT) {
  5898. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5899. __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5900. } else if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
  5901. return (npy_int32) ((((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
  5902. }
  5903. }
  5904. break;
  5905. case -4:
  5906. if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
  5907. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5908. __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5909. } else if (8 * sizeof(npy_int32) - 1 > 4 * PyLong_SHIFT) {
  5910. return (npy_int32) (((npy_int32)-1)*(((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
  5911. }
  5912. }
  5913. break;
  5914. case 4:
  5915. if (8 * sizeof(npy_int32) > 3 * PyLong_SHIFT) {
  5916. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5917. __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5918. } else if (8 * sizeof(npy_int32) - 1 > 4 * PyLong_SHIFT) {
  5919. return (npy_int32) ((((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
  5920. }
  5921. }
  5922. break;
  5923. }
  5924. #endif
  5925. if (sizeof(npy_int32) <= sizeof(long)) {
  5926. __PYX_VERIFY_RETURN_INT_EXC(npy_int32, long, PyLong_AsLong(x))
  5927. } else if (sizeof(npy_int32) <= sizeof(PY_LONG_LONG)) {
  5928. __PYX_VERIFY_RETURN_INT_EXC(npy_int32, PY_LONG_LONG, PyLong_AsLongLong(x))
  5929. }
  5930. }
  5931. {
  5932. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  5933. PyErr_SetString(PyExc_RuntimeError,
  5934. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  5935. #else
  5936. npy_int32 val;
  5937. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  5938. #if PY_MAJOR_VERSION < 3
  5939. if (likely(v) && !PyLong_Check(v)) {
  5940. PyObject *tmp = v;
  5941. v = PyNumber_Long(tmp);
  5942. Py_DECREF(tmp);
  5943. }
  5944. #endif
  5945. if (likely(v)) {
  5946. int one = 1; int is_little = (int)*(unsigned char *)&one;
  5947. unsigned char *bytes = (unsigned char *)&val;
  5948. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  5949. bytes, sizeof(val),
  5950. is_little, !is_unsigned);
  5951. Py_DECREF(v);
  5952. if (likely(!ret))
  5953. return val;
  5954. }
  5955. #endif
  5956. return (npy_int32) -1;
  5957. }
  5958. } else {
  5959. npy_int32 val;
  5960. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  5961. if (!tmp) return (npy_int32) -1;
  5962. val = __Pyx_PyInt_As_npy_int32(tmp);
  5963. Py_DECREF(tmp);
  5964. return val;
  5965. }
  5966. raise_overflow:
  5967. PyErr_SetString(PyExc_OverflowError,
  5968. "value too large to convert to npy_int32");
  5969. return (npy_int32) -1;
  5970. raise_neg_overflow:
  5971. PyErr_SetString(PyExc_OverflowError,
  5972. "can't convert negative value to npy_int32");
  5973. return (npy_int32) -1;
  5974. }
  5975. /* CIntFromPy */
  5976. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  5977. const int neg_one = (int) -1, const_zero = (int) 0;
  5978. const int is_unsigned = neg_one > const_zero;
  5979. #if PY_MAJOR_VERSION < 3
  5980. if (likely(PyInt_Check(x))) {
  5981. if (sizeof(int) < sizeof(long)) {
  5982. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  5983. } else {
  5984. long val = PyInt_AS_LONG(x);
  5985. if (is_unsigned && unlikely(val < 0)) {
  5986. goto raise_neg_overflow;
  5987. }
  5988. return (int) val;
  5989. }
  5990. } else
  5991. #endif
  5992. if (likely(PyLong_Check(x))) {
  5993. if (is_unsigned) {
  5994. #if CYTHON_USE_PYLONG_INTERNALS
  5995. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5996. switch (Py_SIZE(x)) {
  5997. case 0: return (int) 0;
  5998. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  5999. case 2:
  6000. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  6001. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6002. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6003. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  6004. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  6005. }
  6006. }
  6007. break;
  6008. case 3:
  6009. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  6010. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6011. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6012. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  6013. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  6014. }
  6015. }
  6016. break;
  6017. case 4:
  6018. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  6019. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6020. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6021. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  6022. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  6023. }
  6024. }
  6025. break;
  6026. }
  6027. #endif
  6028. #if CYTHON_COMPILING_IN_CPYTHON
  6029. if (unlikely(Py_SIZE(x) < 0)) {
  6030. goto raise_neg_overflow;
  6031. }
  6032. #else
  6033. {
  6034. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  6035. if (unlikely(result < 0))
  6036. return (int) -1;
  6037. if (unlikely(result == 1))
  6038. goto raise_neg_overflow;
  6039. }
  6040. #endif
  6041. if (sizeof(int) <= sizeof(unsigned long)) {
  6042. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  6043. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  6044. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  6045. }
  6046. } else {
  6047. #if CYTHON_USE_PYLONG_INTERNALS
  6048. const digit* digits = ((PyLongObject*)x)->ob_digit;
  6049. switch (Py_SIZE(x)) {
  6050. case 0: return (int) 0;
  6051. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  6052. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  6053. case -2:
  6054. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  6055. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6056. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6057. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  6058. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6059. }
  6060. }
  6061. break;
  6062. case 2:
  6063. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  6064. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6065. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6066. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  6067. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6068. }
  6069. }
  6070. break;
  6071. case -3:
  6072. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  6073. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6074. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6075. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  6076. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6077. }
  6078. }
  6079. break;
  6080. case 3:
  6081. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  6082. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6083. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6084. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  6085. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6086. }
  6087. }
  6088. break;
  6089. case -4:
  6090. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  6091. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6092. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6093. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  6094. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6095. }
  6096. }
  6097. break;
  6098. case 4:
  6099. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  6100. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6101. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6102. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  6103. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6104. }
  6105. }
  6106. break;
  6107. }
  6108. #endif
  6109. if (sizeof(int) <= sizeof(long)) {
  6110. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  6111. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  6112. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  6113. }
  6114. }
  6115. {
  6116. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  6117. PyErr_SetString(PyExc_RuntimeError,
  6118. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  6119. #else
  6120. int val;
  6121. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  6122. #if PY_MAJOR_VERSION < 3
  6123. if (likely(v) && !PyLong_Check(v)) {
  6124. PyObject *tmp = v;
  6125. v = PyNumber_Long(tmp);
  6126. Py_DECREF(tmp);
  6127. }
  6128. #endif
  6129. if (likely(v)) {
  6130. int one = 1; int is_little = (int)*(unsigned char *)&one;
  6131. unsigned char *bytes = (unsigned char *)&val;
  6132. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  6133. bytes, sizeof(val),
  6134. is_little, !is_unsigned);
  6135. Py_DECREF(v);
  6136. if (likely(!ret))
  6137. return val;
  6138. }
  6139. #endif
  6140. return (int) -1;
  6141. }
  6142. } else {
  6143. int val;
  6144. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  6145. if (!tmp) return (int) -1;
  6146. val = __Pyx_PyInt_As_int(tmp);
  6147. Py_DECREF(tmp);
  6148. return val;
  6149. }
  6150. raise_overflow:
  6151. PyErr_SetString(PyExc_OverflowError,
  6152. "value too large to convert to int");
  6153. return (int) -1;
  6154. raise_neg_overflow:
  6155. PyErr_SetString(PyExc_OverflowError,
  6156. "can't convert negative value to int");
  6157. return (int) -1;
  6158. }
  6159. /* CIntToPy */
  6160. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  6161. const long neg_one = (long) -1, const_zero = (long) 0;
  6162. const int is_unsigned = neg_one > const_zero;
  6163. if (is_unsigned) {
  6164. if (sizeof(long) < sizeof(long)) {
  6165. return PyInt_FromLong((long) value);
  6166. } else if (sizeof(long) <= sizeof(unsigned long)) {
  6167. return PyLong_FromUnsignedLong((unsigned long) value);
  6168. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  6169. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  6170. }
  6171. } else {
  6172. if (sizeof(long) <= sizeof(long)) {
  6173. return PyInt_FromLong((long) value);
  6174. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  6175. return PyLong_FromLongLong((PY_LONG_LONG) value);
  6176. }
  6177. }
  6178. {
  6179. int one = 1; int little = (int)*(unsigned char *)&one;
  6180. unsigned char *bytes = (unsigned char *)&value;
  6181. return _PyLong_FromByteArray(bytes, sizeof(long),
  6182. little, !is_unsigned);
  6183. }
  6184. }
  6185. /* CIntFromPy */
  6186. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  6187. const long neg_one = (long) -1, const_zero = (long) 0;
  6188. const int is_unsigned = neg_one > const_zero;
  6189. #if PY_MAJOR_VERSION < 3
  6190. if (likely(PyInt_Check(x))) {
  6191. if (sizeof(long) < sizeof(long)) {
  6192. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  6193. } else {
  6194. long val = PyInt_AS_LONG(x);
  6195. if (is_unsigned && unlikely(val < 0)) {
  6196. goto raise_neg_overflow;
  6197. }
  6198. return (long) val;
  6199. }
  6200. } else
  6201. #endif
  6202. if (likely(PyLong_Check(x))) {
  6203. if (is_unsigned) {
  6204. #if CYTHON_USE_PYLONG_INTERNALS
  6205. const digit* digits = ((PyLongObject*)x)->ob_digit;
  6206. switch (Py_SIZE(x)) {
  6207. case 0: return (long) 0;
  6208. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  6209. case 2:
  6210. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  6211. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6212. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6213. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  6214. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  6215. }
  6216. }
  6217. break;
  6218. case 3:
  6219. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  6220. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6221. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6222. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  6223. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  6224. }
  6225. }
  6226. break;
  6227. case 4:
  6228. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  6229. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6230. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6231. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  6232. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  6233. }
  6234. }
  6235. break;
  6236. }
  6237. #endif
  6238. #if CYTHON_COMPILING_IN_CPYTHON
  6239. if (unlikely(Py_SIZE(x) < 0)) {
  6240. goto raise_neg_overflow;
  6241. }
  6242. #else
  6243. {
  6244. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  6245. if (unlikely(result < 0))
  6246. return (long) -1;
  6247. if (unlikely(result == 1))
  6248. goto raise_neg_overflow;
  6249. }
  6250. #endif
  6251. if (sizeof(long) <= sizeof(unsigned long)) {
  6252. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  6253. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  6254. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  6255. }
  6256. } else {
  6257. #if CYTHON_USE_PYLONG_INTERNALS
  6258. const digit* digits = ((PyLongObject*)x)->ob_digit;
  6259. switch (Py_SIZE(x)) {
  6260. case 0: return (long) 0;
  6261. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  6262. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  6263. case -2:
  6264. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  6265. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6266. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6267. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  6268. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6269. }
  6270. }
  6271. break;
  6272. case 2:
  6273. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  6274. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6275. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6276. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  6277. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6278. }
  6279. }
  6280. break;
  6281. case -3:
  6282. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  6283. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6284. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6285. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  6286. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6287. }
  6288. }
  6289. break;
  6290. case 3:
  6291. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  6292. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6293. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6294. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  6295. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6296. }
  6297. }
  6298. break;
  6299. case -4:
  6300. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  6301. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6302. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6303. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  6304. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6305. }
  6306. }
  6307. break;
  6308. case 4:
  6309. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  6310. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6311. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6312. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  6313. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6314. }
  6315. }
  6316. break;
  6317. }
  6318. #endif
  6319. if (sizeof(long) <= sizeof(long)) {
  6320. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  6321. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  6322. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  6323. }
  6324. }
  6325. {
  6326. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  6327. PyErr_SetString(PyExc_RuntimeError,
  6328. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  6329. #else
  6330. long val;
  6331. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  6332. #if PY_MAJOR_VERSION < 3
  6333. if (likely(v) && !PyLong_Check(v)) {
  6334. PyObject *tmp = v;
  6335. v = PyNumber_Long(tmp);
  6336. Py_DECREF(tmp);
  6337. }
  6338. #endif
  6339. if (likely(v)) {
  6340. int one = 1; int is_little = (int)*(unsigned char *)&one;
  6341. unsigned char *bytes = (unsigned char *)&val;
  6342. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  6343. bytes, sizeof(val),
  6344. is_little, !is_unsigned);
  6345. Py_DECREF(v);
  6346. if (likely(!ret))
  6347. return val;
  6348. }
  6349. #endif
  6350. return (long) -1;
  6351. }
  6352. } else {
  6353. long val;
  6354. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  6355. if (!tmp) return (long) -1;
  6356. val = __Pyx_PyInt_As_long(tmp);
  6357. Py_DECREF(tmp);
  6358. return val;
  6359. }
  6360. raise_overflow:
  6361. PyErr_SetString(PyExc_OverflowError,
  6362. "value too large to convert to long");
  6363. return (long) -1;
  6364. raise_neg_overflow:
  6365. PyErr_SetString(PyExc_OverflowError,
  6366. "can't convert negative value to long");
  6367. return (long) -1;
  6368. }
  6369. /* CheckBinaryVersion */
  6370. static int __Pyx_check_binary_version(void) {
  6371. char ctversion[4], rtversion[4];
  6372. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  6373. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  6374. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  6375. char message[200];
  6376. PyOS_snprintf(message, sizeof(message),
  6377. "compiletime version %s of module '%.100s' "
  6378. "does not match runtime version %s",
  6379. ctversion, __Pyx_MODULE_NAME, rtversion);
  6380. return PyErr_WarnEx(NULL, message, 1);
  6381. }
  6382. return 0;
  6383. }
  6384. /* ModuleImport */
  6385. #ifndef __PYX_HAVE_RT_ImportModule
  6386. #define __PYX_HAVE_RT_ImportModule
  6387. static PyObject *__Pyx_ImportModule(const char *name) {
  6388. PyObject *py_name = 0;
  6389. PyObject *py_module = 0;
  6390. py_name = __Pyx_PyIdentifier_FromString(name);
  6391. if (!py_name)
  6392. goto bad;
  6393. py_module = PyImport_Import(py_name);
  6394. Py_DECREF(py_name);
  6395. return py_module;
  6396. bad:
  6397. Py_XDECREF(py_name);
  6398. return 0;
  6399. }
  6400. #endif
  6401. /* TypeImport */
  6402. #ifndef __PYX_HAVE_RT_ImportType
  6403. #define __PYX_HAVE_RT_ImportType
  6404. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
  6405. size_t size, int strict)
  6406. {
  6407. PyObject *py_module = 0;
  6408. PyObject *result = 0;
  6409. PyObject *py_name = 0;
  6410. char warning[200];
  6411. Py_ssize_t basicsize;
  6412. #ifdef Py_LIMITED_API
  6413. PyObject *py_basicsize;
  6414. #endif
  6415. py_module = __Pyx_ImportModule(module_name);
  6416. if (!py_module)
  6417. goto bad;
  6418. py_name = __Pyx_PyIdentifier_FromString(class_name);
  6419. if (!py_name)
  6420. goto bad;
  6421. result = PyObject_GetAttr(py_module, py_name);
  6422. Py_DECREF(py_name);
  6423. py_name = 0;
  6424. Py_DECREF(py_module);
  6425. py_module = 0;
  6426. if (!result)
  6427. goto bad;
  6428. if (!PyType_Check(result)) {
  6429. PyErr_Format(PyExc_TypeError,
  6430. "%.200s.%.200s is not a type object",
  6431. module_name, class_name);
  6432. goto bad;
  6433. }
  6434. #ifndef Py_LIMITED_API
  6435. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  6436. #else
  6437. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  6438. if (!py_basicsize)
  6439. goto bad;
  6440. basicsize = PyLong_AsSsize_t(py_basicsize);
  6441. Py_DECREF(py_basicsize);
  6442. py_basicsize = 0;
  6443. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  6444. goto bad;
  6445. #endif
  6446. if (!strict && (size_t)basicsize > size) {
  6447. PyOS_snprintf(warning, sizeof(warning),
  6448. "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
  6449. module_name, class_name, basicsize, size);
  6450. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  6451. }
  6452. else if ((size_t)basicsize != size) {
  6453. PyErr_Format(PyExc_ValueError,
  6454. "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
  6455. module_name, class_name, basicsize, size);
  6456. goto bad;
  6457. }
  6458. return (PyTypeObject *)result;
  6459. bad:
  6460. Py_XDECREF(py_module);
  6461. Py_XDECREF(result);
  6462. return NULL;
  6463. }
  6464. #endif
  6465. /* InitStrings */
  6466. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  6467. while (t->p) {
  6468. #if PY_MAJOR_VERSION < 3
  6469. if (t->is_unicode) {
  6470. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  6471. } else if (t->intern) {
  6472. *t->p = PyString_InternFromString(t->s);
  6473. } else {
  6474. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  6475. }
  6476. #else
  6477. if (t->is_unicode | t->is_str) {
  6478. if (t->intern) {
  6479. *t->p = PyUnicode_InternFromString(t->s);
  6480. } else if (t->encoding) {
  6481. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  6482. } else {
  6483. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  6484. }
  6485. } else {
  6486. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  6487. }
  6488. #endif
  6489. if (!*t->p)
  6490. return -1;
  6491. ++t;
  6492. }
  6493. return 0;
  6494. }
  6495. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  6496. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  6497. }
  6498. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
  6499. Py_ssize_t ignore;
  6500. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  6501. }
  6502. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  6503. #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  6504. if (
  6505. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  6506. __Pyx_sys_getdefaultencoding_not_ascii &&
  6507. #endif
  6508. PyUnicode_Check(o)) {
  6509. #if PY_VERSION_HEX < 0x03030000
  6510. char* defenc_c;
  6511. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  6512. if (!defenc) return NULL;
  6513. defenc_c = PyBytes_AS_STRING(defenc);
  6514. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  6515. {
  6516. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  6517. char* c;
  6518. for (c = defenc_c; c < end; c++) {
  6519. if ((unsigned char) (*c) >= 128) {
  6520. PyUnicode_AsASCIIString(o);
  6521. return NULL;
  6522. }
  6523. }
  6524. }
  6525. #endif
  6526. *length = PyBytes_GET_SIZE(defenc);
  6527. return defenc_c;
  6528. #else
  6529. if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
  6530. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  6531. if (PyUnicode_IS_ASCII(o)) {
  6532. *length = PyUnicode_GET_LENGTH(o);
  6533. return PyUnicode_AsUTF8(o);
  6534. } else {
  6535. PyUnicode_AsASCIIString(o);
  6536. return NULL;
  6537. }
  6538. #else
  6539. return PyUnicode_AsUTF8AndSize(o, length);
  6540. #endif
  6541. #endif
  6542. } else
  6543. #endif
  6544. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  6545. if (PyByteArray_Check(o)) {
  6546. *length = PyByteArray_GET_SIZE(o);
  6547. return PyByteArray_AS_STRING(o);
  6548. } else
  6549. #endif
  6550. {
  6551. char* result;
  6552. int r = PyBytes_AsStringAndSize(o, &result, length);
  6553. if (unlikely(r < 0)) {
  6554. return NULL;
  6555. } else {
  6556. return result;
  6557. }
  6558. }
  6559. }
  6560. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  6561. int is_true = x == Py_True;
  6562. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  6563. else return PyObject_IsTrue(x);
  6564. }
  6565. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  6566. PyNumberMethods *m;
  6567. const char *name = NULL;
  6568. PyObject *res = NULL;
  6569. #if PY_MAJOR_VERSION < 3
  6570. if (PyInt_Check(x) || PyLong_Check(x))
  6571. #else
  6572. if (PyLong_Check(x))
  6573. #endif
  6574. return __Pyx_NewRef(x);
  6575. m = Py_TYPE(x)->tp_as_number;
  6576. #if PY_MAJOR_VERSION < 3
  6577. if (m && m->nb_int) {
  6578. name = "int";
  6579. res = PyNumber_Int(x);
  6580. }
  6581. else if (m && m->nb_long) {
  6582. name = "long";
  6583. res = PyNumber_Long(x);
  6584. }
  6585. #else
  6586. if (m && m->nb_int) {
  6587. name = "int";
  6588. res = PyNumber_Long(x);
  6589. }
  6590. #endif
  6591. if (res) {
  6592. #if PY_MAJOR_VERSION < 3
  6593. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  6594. #else
  6595. if (!PyLong_Check(res)) {
  6596. #endif
  6597. PyErr_Format(PyExc_TypeError,
  6598. "__%.4s__ returned non-%.4s (type %.200s)",
  6599. name, name, Py_TYPE(res)->tp_name);
  6600. Py_DECREF(res);
  6601. return NULL;
  6602. }
  6603. }
  6604. else if (!PyErr_Occurred()) {
  6605. PyErr_SetString(PyExc_TypeError,
  6606. "an integer is required");
  6607. }
  6608. return res;
  6609. }
  6610. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  6611. Py_ssize_t ival;
  6612. PyObject *x;
  6613. #if PY_MAJOR_VERSION < 3
  6614. if (likely(PyInt_CheckExact(b))) {
  6615. if (sizeof(Py_ssize_t) >= sizeof(long))
  6616. return PyInt_AS_LONG(b);
  6617. else
  6618. return PyInt_AsSsize_t(x);
  6619. }
  6620. #endif
  6621. if (likely(PyLong_CheckExact(b))) {
  6622. #if CYTHON_USE_PYLONG_INTERNALS
  6623. const digit* digits = ((PyLongObject*)b)->ob_digit;
  6624. const Py_ssize_t size = Py_SIZE(b);
  6625. if (likely(__Pyx_sst_abs(size) <= 1)) {
  6626. ival = likely(size) ? digits[0] : 0;
  6627. if (size == -1) ival = -ival;
  6628. return ival;
  6629. } else {
  6630. switch (size) {
  6631. case 2:
  6632. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  6633. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6634. }
  6635. break;
  6636. case -2:
  6637. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  6638. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6639. }
  6640. break;
  6641. case 3:
  6642. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  6643. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6644. }
  6645. break;
  6646. case -3:
  6647. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  6648. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6649. }
  6650. break;
  6651. case 4:
  6652. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  6653. return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6654. }
  6655. break;
  6656. case -4:
  6657. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  6658. return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  6659. }
  6660. break;
  6661. }
  6662. }
  6663. #endif
  6664. return PyLong_AsSsize_t(b);
  6665. }
  6666. x = PyNumber_Index(b);
  6667. if (!x) return -1;
  6668. ival = PyInt_AsSsize_t(x);
  6669. Py_DECREF(x);
  6670. return ival;
  6671. }
  6672. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  6673. return PyInt_FromSize_t(ival);
  6674. }
  6675. #endif /* Py_PYTHON_H */