How to resolve the algorithm Parallel calculations step by step in the J programming language
How to resolve the algorithm Parallel calculations step by step in the J programming language
Table of Contents
Problem Statement
Many programming languages allow you to specify computations to be run in parallel. While Concurrent computing is focused on concurrency, the purpose of this task is to distribute time-consuming calculations on as many CPUs as possible. Assume we have a collection of numbers, and want to find the one with the largest minimal prime factor (that is, the one that contains relatively large factors). To speed up the search, the factorization should be done in parallel using separate threads or processes, to take advantage of multi-core CPUs. Show how this can be formulated in your language. Parallelize the factorization of those numbers, then search the returned list of numbers and factors for the largest minimal factor, and return that number and its prime factors. For the prime number decomposition you may use the solution of the Prime decomposition task.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Parallel calculations step by step in the J programming language
Source code in the j programming language
numbers =. 12757923 12878611 12878893 12757923 15808973 15780709 197622519
factors =. q:&.> parallelize 2 numbers NB. q: is parallelized here
ind =. (i. >./) <./@> factors
ind { numbers ;"_1 factors
┌────────┬───────────┐
│12878611│47 101 2713│
└────────┴───────────┘
You may also check:How to resolve the algorithm Command-line arguments step by step in the Elena programming language
You may also check:How to resolve the algorithm Amicable pairs step by step in the R programming language
You may also check:How to resolve the algorithm QR decomposition step by step in the Ada programming language
You may also check:How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Range consolidation step by step in the Racket programming language