Improving MATLAB's isprime performance without arbitrary-precision arithmetic
Travis Near

TL;DR
This paper presents optimized techniques for MATLAB's isprime function, significantly enhancing its speed for small and large integers by leveraging modular arithmetic, Miller-Rabin testing, vectorization, and division reduction strategies.
Contribution
It introduces novel MATLAB-specific optimizations for isprime, achieving substantial performance improvements over existing implementations.
Findings
5 to 10 times faster for small integers
Hundreds of times faster for large integers
Effective use of modular arithmetic and vectorization
Abstract
MATLAB is a numerical computing platform used by scientists, engineers, mathematicians, and students which contains many mathematical functions, including isprime. MATLAB's isprime function determines which elements of an input array are prime. This research details modular arithmetic techniques, the Miller-Rabin primality test, vectorized operations, and division-minimizing strategies which harness the power of MATLAB's capabilities to improve isprime's performance. The results are typically 5 to 10 times faster for small integers and many hundreds of times faster for large integers and long arrays.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNumerical Methods and Algorithms · Parallel Computing and Optimization Techniques · Embedded Systems Design Techniques
