Python Forum
Matlab to Python -- Parallel Computing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matlab to Python -- Parallel Computing
#1
Hello All,

I am new to Python programming, and I can probably write a for-loop in Python, but not much else.

I would like to test the performance of a job scheduler on a high performance computer using Python, and I'm posting here to find out if someone can convert my Matlab function into Python. I know there are a couple of online coverters, but they're not capable of getting the job done. Here is the code:

Quote:function total = matlab_prime (n,ncores)
% Returns the number of primes between 1 and n inclusive
tic;
total = 0;
parfor i = 2:n
total = total + isprime(i);
end
toc;

Thanks

Edit: Note that isprime is a Matlab function that returns 1 if its arugment is prime, and 0 otherwise
Reply
#2
Please use the proper code tag buttons - see BBCode to know more
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Computing GC Content uwl 3 942 Jun-26-2023, 09:37 PM
Last Post: Pedroski55
  parallel loop python caro 4 1,790 Jun-16-2022, 08:46 PM
Last Post: woooee
Photo Matlab to Python Sateesh 0 1,673 Nov-04-2020, 09:11 AM
Last Post: Sateesh
  From Matlab to Python erbab 1 2,000 Oct-27-2020, 02:16 PM
Last Post: jefsummers
  Arrays in MATLAB and PYTHON cokhuatlanyeuthuongconhetmuc 2 2,189 Jul-24-2020, 10:47 AM
Last Post: cokhuatlanyeuthuongconhetmuc
  Use dynamic variable from parallel running python script Sicksym 0 1,840 May-15-2020, 02:52 PM
Last Post: Sicksym
  Python v MatLab for graphs and plots CynthiaMoore 4 3,025 Apr-22-2020, 02:13 PM
Last Post: CynthiaMoore
  python equivalent to MATLAB xcov chai0404 2 3,873 Apr-02-2020, 10:29 PM
Last Post: chai0404
  Python equivalent of Matlab code kwokmaster 1 3,448 Mar-25-2020, 10:14 PM
Last Post: j.crater
  MATLAB to Python conversion stokd 10 5,008 Jan-19-2020, 09:14 PM
Last Post: stokd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020