So I realized last night, that you can probably find Hamiltonian circuits quickly, using vectorization / parallel computing, and tonight, I realized you can also test for whether a number is prime using vectorization, and the results are pretty impressive, and below is some command line code, together with the runtimes, which are in the fractions of a second until you hit the double digit millions, which took just over one second:
ostensible_prime = 7;
tic; [is_prime divisor_vector] = prime_test(ostensible_prime); toc
0.000156164 seconds.
ostensible_prime = 16127;
tic; [is_prime divisor_vector] = prime_test(ostensible_prime); toc
0.000491858 seconds.
ostensible_prime = 27644437;
tic; [is_prime divisor_vector] = prime_test(ostensible_prime); toc
1.00698 seconds.
The code is attached below.
Discover more from Information Overload
Subscribe to get the latest posts sent to your email.