Posts

C++ How to create a map from two other maps -

how create map mymap3 as: std::map< vector<std::pair<int, int>>, int > mymap3 example: mymap3[0] = ((1,3) , (1,5), 7 ) // 5 = 4 + 3 mymap3[1] = ( (2,1) , (2,4), 6 ) // 6 = 1 + 5 where key = (vector of pairs) extract 'mymap1', and value = sum of pairs' values in 'mymap2'. i don't care pair order, (2,4) same (4,2) std::map <int, vector<pair<int, int>> > mymap1; std::map< std::pair< int, int>, int> mymap2; here example: mymap1[0] = (0, (1,3) , (1,5) ) mymap1[1] = (1, (2,1) , (2,4) ) mymap2[0] = ( (1,3) , 4 ) mymap2[1] = ( (1,5) , 3 ) mymap2[2] = ( (2,1) , 1 ) mymap2[3] = ( (4,2) , 5 ) i don't know how that, , try: std::map <int, vector<pair<int, int>> > ::iterator it1 = mymap1.begin(); std::map<std::pair< int, int>, int> ::iterator it2 = mymap2.begin(); // std::map< vector<pair<int, int> >, int> mymap3; std::map< pai...

sql - Reproduce certain rows in PostgreSQL -

i have table ids represent individuals (call id_table) , table characteristics individual can have (call char_table). now want add column id_table containing values char_table. difficulty, me, is, id shall 1 characteristic (simple case) , id shall several characteristics. reason rows these id several characteristics must reproduced until have matched every characteristic id. example: id '001' shall characteristics 'a', 'b', , 'c'. row id='001' must reproduced 2 times (to same row 3 times) , each of these rows shall 1 of these 3 characteristics. i hope explained intelligible enough. idea how this? thanks. in cases, want association or junction table. table like: create table individualcharacteristicsr ( individualid int not null, characterid int not null ); (it might have unique id itself.) each characteristic individual has on separate row. so, 3 characteristics mean 3 rows. typical query using information join ...

join - mysql error table cannot be used in global order clause -

(select dtable.* app_detailsvvv dtable inner join new_apps on new_apps.trackid=dtable.trackid primarygenrename='games' , composed='1' , new_apps.top>0) union (select * app_detailsvvv dtable primarygenrename='games') order new_apps.top asc, trackname asc limit 12 with query error: #1250 - table 'new_apps' 1 of selects cannot used in global order clause new_apps not used in second query, idea first top rank same table has listed id in new_apps table as docs says this kind of order cannot use column references include table name (that is, names in tbl_name.col_name format). instead, provide column alias in first select statement , refer alias in order by. so rewrite this ( select dtable.*, new_apps.top t1 app_detailsvvv dtable inner join new_apps on new_apps.trackid=dtable.trackid primarygenrename='games' , composed='1' , new_apps.top > 0 ) union ( select *, 0 app_detailsvvv dtable ...

python - Scipy Griddata Output Dimensions -

Image
i'm not sure i'm doing wrong. i'm attempting use scipy griddata interpolate data in irregular grid. from scipy.interpolate import griddata i have 2 lists, "x" , "y", represent axes of original, uninterpolated grid. both lists of length 8. then, make arrays represent axes of intended final, filled-in grid. ny = np.linspace(0.0, max(y), y[len(y)-1]/min_interval+1) nx = np.linspace(0.0, max(x), len(ny)) i've checked , both "ny" , "nx" of shape (61,). then, create 8 x 8 list "z". finally, attempt make final grid. z = griddata((np.array(x), np.array(y)), np.array(z), (nx, ny), method='nearest', fill_value=0) print z.shape the resulting 2d array has dimensions (61,8). tried using "x" , "y" lists , arrays - no change. why interpolating in 1 direction? expecting (61,61) array output. have included actual numbers if felt have been helpful, don't see how make difference. not unders...

javascript - jQuery remove duplicate row(s) on output loop -

im looking jquery script run when results output on screen. while running output loop, need jquery @ rows see if row similar id exists, if does, need remove current row output has duplicate id. i constructing tr "id" passing in unique value db call , appeding "row_". in end make id "row_6373" (6373 being unique value). <table> [while loop] // jquery script right here... <tr id="row_6373"><td></td></tr> <tr id="row_988732"><td></td></tr> <tr id="row_6435"><td></td></tr> <tr id="row_6373"><td></td></tr> row output [/while loop] </table> as loop running need jquery check see if row id "row_6373" exists, if need remove last instance of row_6373. happen several time in output loop. "row_6373" come check thousand times. right doing this: running @ beginni...

android - firemonkey xe5 save captured image with specified name -

in firemonkey xe5 there sample how capture image , show bitmap , possible change image name, right after capturing, source code? i've tried use code : image.savetofile(gethomepath + pathdelim + 'myimage.jpg') on procedure : procedure tform2.takephotofromcameraaction1didfinishtaking(image: tbitmap); begin end; but nothing happened.

jquery - Hide the excerpt and re show it when re toggled -

i have done best this,.. took me hours still cant work. when readmore clicked hides excerpt , shows full content, re names buttons hide, when hide clicked again, has show excerpt again , hide full content. here's fiddle jquery code jquery(document).ready(function () { jquery('.testi-more').click(function (e) { e.preventdefault(); var same = jquery(this).closest('.testi-wrapper'); jquery(this).closest('.testi-wrapper').children('.testi-full').slidetoggle('slow'); }); if (jquery('.testi-full').is(": hidden")) { jquery(this).closest('.testi-wrapper').children('.testi-excerpt').show(); jquery(this).closest('.testi-wrapper').children('.testi-more').html('read moar'); } else { jquery(this).closest('.testi-wrapper').children('.testi-excerpt').hide(); jquery(this).closest('.testi-wrapper...