# Thread: Is this array of dot products sorted?

1. ## Is this array of dot products sorted?

Hey guys my first post, I'm a newbie so sorry if it should have been posted in some other section

We consider an array named 'Pairs' of a big number of pairs of orthogonal vectors(so for instance Pairs[10] means 10th pair having two orthogonal vectors) that vectors of array have a vast diversity in length and real(real-number) components and in each pair there are vectors v and w , we sort array in ascending order based on v×w(meaning in sorted array: Pairs[i+b].(v×w)>Pairs[i].(v×w) ) then convert components into 32-bit floating point(here of course we'd have rounding), now we consider another array named 'dotProducts' that has double-precision elements and taking 'Pairs' array with floating-point data we have (using binary floating-point arithmetic operation and 80-bit extended-precision for intermediate calculations to have better accuracy)dotProducts[i]=Pairs[i].(v×w×cosθ), so now is 'dotProducts' array also sorted in some order or there's no reason to be any order?

2. ## Re: Is this array of dot products sorted?

Hello Pooria,
There is too much going on in your question and the notation used here is also ambiguous. Let me point out a few issues here

1) ||v|| and ||w|| denote magnitudes hence scalars so ||v||x||w|| (cross product) does not make any sense.
2) If we interpret them as a simple product, then all you are doing is arranging the Pairs array in ascending order of the product of magnitudes of the pairs in each element of the array.

I hope you meant case (2). In this case the dotProduct array should have all elements equal 0 as v and w are orthogonal hence v.w =0.
However since you have rounded the values and then have taken v.w the values will not exactly be zero but very close to zero due to cosθ.
Now there could be a chance that this array is as well sorted in the same order. Assuming that in each case 0 < cosθ <= k, where k is some real value. Since its just the magnitude that is effecting the sorting the order could be preserved as you have mentioned that there is a large variation in the magnitude values.

However if cosθ values are fluctuating say in the case like |cosθ| <= k where it taking some negative values also then we cannot argue that dotProduct is also arranged in the same way Pairs.

~Kalyan.

3. ## Re: Is this array of dot products sorted?

Hello Kalyan and thanks for answer

first of all regarding that notation I've used C++ assuming anyone should easily understand it maybe I should revise my assumption then and actually ||v||x||w|| can't be mistaken for cross product because norm produces a scalar(||SomeVector|| is a scalar), for 'OP1 x OP2' to be considered a cross product both OP1 and OP2 should be vectors, anyway even in case after converting to floating point in all pairs two vectors have a <=90 angle, since there'd be rounding involved in computing dot products using binary floating-point arithmetic operation, even although this rounding in our case doesn't generate a negative result instead of positive I can argue because I can't see any proof that rounding doesn't disturb the order, the array of dot products is not guaranteed to be sorted let alone in the case after converting to floating point in some pairs there are vectors with a >90 angle

respect