455,513 Members | 1,629 Online Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

# valarray

 P: n/a I have a (9x9) valarray std::valarray va(81); va = 0; // fil all elements with zeros I am taking row slices like that: std::slice_array slr = va[std::slice(r-1,9,9)]; // r = row; a value between 1 and 9 std::valarray row = slr; and column slices like that: std::slice_array slc = va[std::slice((c-1)*9, 9, 1)]; // c = col; a value between 1 and 9 std::valarray col = slc; which does work without any problem. But when I try to extract a subarray: size_t len[] = {3,3}; size_t dist[] = {9, 1}; std::valarray lens(len, 2); std::valarray dists(dist, 2); int st_r = ((r-1)/3)*3+1; // r (s.o.) int st_c = ((c-1)/3)*3+1; // c (s.o.) int st_i = rc2i( st_r, st_c ); // int rc2i(int row, int col) { return (col-1) * 9 + (row-1); } std::gslice_array gslsa = va[std::gslice(st_i, lens, dists)]; std::valarray subarray = gslsa; the first element is always the value of element 0 of the valarray, even if my function rc2i calculates the correct values for st_i! Is it likely, that there is a bug in the sources of the library or did I just not fully understand the concept of gslice_array/gslice? I mean I'am sure I didn't understant it completely but I don't see the mistake I possibly make! :-) Hoping for some hints. bye, Oliver Nov 5 '05 #1 