Sep 6, 2013, 02:14 PM  #26  
Quote:
You see, there is this little island in the North Sea, called Great Britain. And the people living on that little island speak proper English aka British English. And when the do maths, they do maths. Not math. 

1 
Sep 6, 2013, 04:14 PM  #27 
According to the dictionary "math" is a mid 19th century abbreviation of the word "mathematics" a plural noun usually treated as singular. So yes, I studied math and also English, but not British English slang.


0 
Sep 6, 2013, 10:20 PM  #28 
If the British speak English it is certainly not proper English.


0 
Sep 7, 2013, 09:01 AM  #29 
Back on topic, I did a quick test of vvsincos and vvsincosf on my mid2007 MBP, where I found the float version is about 34 times faster than the double version when processing the same number of values.
Does anyone with a more recent machine want to test the same thing? Last edited by Qaanol; Sep 7, 2013 at 09:48 AM. 

0 
Sep 7, 2013, 10:14 AM  #30  
Quote:


0 
Sep 7, 2013, 03:09 PM  #31 
Here’s my test code, written as a commandline utility (be sure to compile for “release”, not “debug”, so it will run at fullspeed in Terminal.) Be sure to link the Accelerate framework as well. There is one optional commandline argument to specify the size of the arrays. If omitted, the default is 10,000.
Code:
#include <stdlib.h> #include <stdio.h> #include <time.h> #include <vecLib/vecLib.h> int main (int argc, const char * argv[]) { int n = 10000; if (argc > 1) { n = atoi(argv[1]); if (n < 1) { printf("First argument must be positive\n"); return 1; } } time_t t[3]; float *f1 = malloc(n * sizeof(float)); float *f2 = malloc(n * sizeof(float)); double *d1 = malloc(n * sizeof(double)); double *d2 = malloc(n * sizeof(double)); srandomdev(); for (int ii = 0; ii < n; ii = ii + 1) { d1[ii] = (double)random(); f1[ii] = (float)random(); } t[0] = clock(); vvsincosf(f1, f2, f1, &n); t[1] = clock(); vvsincos(d1, d2, d1, &n); t[2] = clock(); double t1 = (double)(t[1]  t[0])/CLOCKS_PER_SEC; double t2 = (double)(t[2]  t[1])/CLOCKS_PER_SEC; printf("%f seconds for %i floats\n", t1, n); printf("%f seconds for %i doubles\n", t2, n); printf("float is %f times the speed of double\n", t2/t1); return 0; } Code:
0.577504 seconds for 16777216 floats 2.182337 seconds for 16777216 doubles float is 3.778912 times the speed of double Last edited by Qaanol; Sep 7, 2013 at 03:27 PM. 

0 
Sep 7, 2013, 05:31 PM  #32  
Quote:
You store the result of random () to be used as the argument of the sine and cosine functions. The values returned by random are in the range from about 0 to 2 billion. That's absolutely nontypical for the arguments of sine and cosine. Worse, when you store a value between 1 and 2 billion into a float, the resolution is 128. That means, the lowest bit has a value of 128, and the difference between two consecutive float numbers is 128. The period of sine and cosine is 2pi. 128 is more than 20 times that period, so for float the actual arguments are totally meaningless. vvsincosf might as well just return 0 and 1 for the sine and cosine for these large values. For double, that's not the case; the arguments even in that huge range still have a resolution of 1/8million radians. You'd get much more meaningful results if you scaled the values lets say into the interval [2, +2].  "Maths" hasn't been slang for the last 100 years. 

0 
Sep 7, 2013, 06:48 PM  #33  
Quote:
Code:
0.210407 seconds for 16777216 floats 0.773957 seconds for 16777216 doubles float is 3.678380 times the speed of double Code:
0.214049 seconds for 16777216 floats 0.782355 seconds for 16777216 doubles float is 3.655028 times the speed of double Code:
d1[ii] = 6.2832 * ((double)random() / RAND_MAX); f1[ii] = (float)(6.2832 * ((double)random() / RAND_MAX)); This is false. If you go to a major university, even in the USA, and spend some time in the math department graduate lounge, you’ll hear plenty of people refer to their subjects of study as ‘maths’. 

0 
Sep 10, 2013, 03:31 AM  #34  
Quote:
Blimy, colour me queer, it's as if the United States are not speaking the same language. (I apologize to all the Brits and Aussies in the room). For what it's worth: http://en.wikipedia.org/wiki/Compari...ritish_English http://www.dailywritingtips.com/mathormaths/ You're all correct. One thing that always bothers me when I hear British English is the treatment of collective noun  verb agreements. Jeremy Clarkson in particular likes to strongly inflect "have" for dramatic effect. I.e. (British) "Germany have won the competition." v.s. (US) "Germany has won the competition." Damn Brits, can't they speak their own language? Back to Math/Maths... It kinda makes sense when you look at the difference in subjectverb agreement between British and US english. (British) "Maths are difficult." (US) "Math is difficult." Both sound reasonable. Swapping our nation's respective agreements... "Math are difficult." "Maths is difficult" Not particularly poetic. 

0 
Sep 10, 2013, 04:17 AM  #35  
Quote:
The point was that you started with totally nontypical value, so you couldn't know whether your results applied to realworld use or not. Seems they do (which is disappointing, since I would have expected shortcuts to calculate sine / cosine faster for typical values), but it still needed verification. 

0 
Sep 11, 2013, 09:13 AM  #36  
Quote:
Quote:
Quote:


0 
Sep 11, 2013, 03:43 PM  #37  
Quote:
Every implementation of sine / cosine transforms the argument into the range from pi/4 to +pi/4. In the general case, you multiply the argument by pi/2, round to the nearest integer, multiply by pi/2 _very_ carefully to avoid rounding errors and subtract that from the argument. That's expensive. In the typical case, say 1.25 pi < x < 1.25 pi, all you do is add or subtract pi or pi/2 or leave the argument unchanged. A lot faster. But if you want to do this you _must_ check for the atypical case or get nonsense results. BTW. Lots of MacOS X / iOS graphics code uses the type CGFloat. On the iPhone 5s, they now use CGFloat = double. 

0 
«
Previous Thread

Next Thread
»
Thread Tools  Search this Thread 
Display Modes  
Similar Threads  
thread  Thread Starter  Forum  Replies  Last Post 
My sin is Pride. What is yours?  jack170794  iPhone and iPod touch Apps  0  Aug 6, 2013 10:53 PM 
The one Application nearly a SIN not to have on your Mac  MacGuru100  Mac Applications and Mac App Store  2  Jun 23, 2013 01:44 AM 

All times are GMT 5. The time now is 06:43 PM.