[Development] QList
Shawn Rutledge
Shawn.Rutledge at qt.io
Mon Mar 27 11:27:59 CEST 2017
> On 27 Mar 2017, at 10:52, Martin Smith <Martin.Smith at qt.io> wrote:
>
> It was about whether QPolygon should inherit QVector, which means that a polygon is a vector. That is kind of jolting because people don't think of a polygon as being a vector. But back in the day, calling a sequential collection of items a vector was also a jolt, because at that time, a vector was a direction and a length to most people.
Well you may think of it that way geometrically, but usually need to do the calculations with vectors in component form.
> So given the 20 year history of vector being a sequential collection of items, it isn't really a problem for QPolygon to inherit QVector, because everyone will come to think of a polygon as a vector just as we came to think of a vector as a sequential collection of items.
But vector has been overloaded further: it could also be several values aligned in memory in such a way that SIMD (vector-processing) instructions can be used. (And the idea of hardware specialized for vector processing goes way back.) IMO it would have been better to reserve the word for that use in computer science, because it’s more aligned with the mathematical sense of a fixed set of components (one component per dimension), rather than an n-ary array that can be expanded and contracted on demand. If you are processing lots of mathematical vectors, you should probably use vector instructions too. But for some reason it’s not on the radar to worry about SIMD in most code; most of us basically pretend there is no such thing. Is that because compilers are really so good at auto-vectorization that we properly should neglect it, or because the linguistic clutter makes it too confusing, or something else? Should we concern ourselves more about it? Have some features in Qt to make it easier to vectorize code?
We have QVector2D, QVector3D and QVector4D, but those are mostly for geometric use cases, whereas float is not the only datatype to which SIMD instructions can be applied.
Still, if you have a QVector<frob> with 57 elements, you can think of it as a point in 57-dimensional frobspace, if you like. So our use of vector is not completely out of sync with the mathematical sense, even if adding and removing dimensions to our space all the time is kindof absurd.
More information about the Development
mailing list