Home

On Sep 4, 2:56 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
> T. Crane wrote:
> > Hi all,
>
> > I have some data that I am using a vector<vector<double> > container
> > to hold. The data is n sets of (x,y,z,intensity) data points. I can
> > either group my data like this:
>
> > vector<vector<double> > v(n, vector<double>(4)); // method A
>
> > or like this:
>
> > vector<vector<double> > v(4, vector<double>(n)); // method B
>
> > This difference, of course, is that in the first method, I have n 4-
> > element vectors and in the second I have 4 n-element vectors.
>
> > Next, I want to find the (x,y,z) coordinates of the point that has the
> > highest intensity. Finding the highest intensity is easy when I use
> > method B to group the data.
>
> > All I have to do is:
>
> > vector<double>::iterator maxInt = max_element(v[3].begin(),
> > v[3].end());
>
> > The max intensity is found by dereferencing maxInt. However, at this
> > point I'm at a loss as to how to get the corresponding (x,y,z) values
> > for that max intensity.
>
> I believe you should be able to do
>
> size_t indMax = maxInt - v[3].begin();
> double x = v[0][indMax],
> y = v[1][indMax],
> z = v[2][indMax];
>
> > Alternatively, if I were to group the data using method A, once I have
> > a max intensity, it's trivial to find the (x,y,z) values, but I don't
> > know a good (i.e. easy, elegant, whatever) way to find the max
> > intensity short of writing a max_element-like function.
>
> ... = max_element(v.begin(), v.end(), my_compare());
>
> where 'my_compare' is this:
>
> struct my_compare {
> bool operator()(vector<double> const& v1, vector<double const& v2)
> {
> return v1[3] < v2[3]; // compare intensities
> }
> };
>
> V
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask- Hide quoted text -
>
> - Show quoted text -

Cool -- I was thinking of something along the lines of the latter
suggestion, but I hadn't thought of the former.

thanks for your help,
trevis

previous
next

How to do transparent (opaque) windows from Python
Re: C/C++ guidelines
Re: Try this
Re: FCGI app reloading on every request
Re: Question about proprietary software development using GNU C++
Fundacja Sloneczko
Kidprotect
Mam Marzenie
Mimo Wszystko
Krwinka