Re: linear algebric equations

2020-12-08 Thread Christian Gollwitzer

Am 07.12.20 um 17:59 schrieb Tito Sanò:

Regarding the solution of linear algebraic equations I noticed a big
difference in the computation

time in Python compared to the old fortran language.

I have compared both the linelg and lapack.dgesv-lapack.zgesv modules with
the fortan: dgelg and f04adf.

The difference in computation time is enormous:

for example for 430 degrees of freedom it is about 24 min in Python versus
about 1 sec in fortran.


There must be something seriously wrong. If I understand correctly, you 
want to solve an 430x430 matrix with LU decompositino (that is what 
dgesv from LAPACK does). The following code takes less than a second on 
my machine:


==430.py==
import numpy as np

# create a 430x430 random matrix
A = np.random.randn(430,430)

# right hand side
b = np.ones(430)

# solve it

x = np.linalg.solve(A, b)

print(x)



time python3 430.py
real0m0.318s
user0m0.292s
sys 0m0.046s

If it takes longer than 1s, there is something wrong with your system.

Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: linear algebric equations

2020-12-08 Thread Marco Sulla
On Mon, 7 Dec 2020 at 20:38, Tito Sanò  wrote:
> Is it possible to get better performance in Python?

Have you installed BLAS for Scipy? What OS do you have?
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: linear algebric equations

2020-12-08 Thread Schachner, Joseph
Yes.  Import os, and use  os.system( ) to call your Fortran (or C) executable.  
If the executable saves results in a file or files, Python can read them in an 
format a nice overall report.  In html or xml, if you like.

Using Python as glue,  the execution time will be exactly what it was for your 
executable, because Python will call it; and in a second of so after it 
finishes Python can read in results and format whatever report you like.

--- Joseph S.

-Original Message-
From: Tito Sanò  
Sent: Monday, December 7, 2020 11:59 AM
To: python-list@python.org
Subject: linear algebric equations

Regarding the solution of linear algebraic equations I noticed a big difference 
in the computation

time in Python compared to the old fortran language.

I have compared both the linelg and lapack.dgesv-lapack.zgesv modules with the 
fortan: dgelg and f04adf. 

The difference in computation time is enormous:

for example for 430 degrees of freedom it is about 24 min in Python versus 
about 1 sec in fortran.

Is it possible to get better performance in Python?

Thanks in advance  

Tito Sano' 

Roma Italy

Cell: 339 6903895

 


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: linear algebric equations

2020-12-07 Thread Dan Stromberg
On Mon, Dec 7, 2020 at 11:36 AM Tito Sanò  wrote:

> Regarding the solution of linear algebraic equations I noticed a big
> difference in the computation
>
> time in Python compared to the old fortran language.
>
> I have compared both the linelg and lapack.dgesv-lapack.zgesv modules with
> the fortan: dgelg and f04adf.
>
> The difference in computation time is enormous:
>
> for example for 430 degrees of freedom it is about 24 min in Python versus
> about 1 sec in fortran.
>
> Is it possible to get better performance in Python?
>

Can you make your test code available for examination?

If you are using CPython, are you also using numpy? Or numba?

If you are using pure Python, have you tried Pypy3?

HTH.
-- 
https://mail.python.org/mailman/listinfo/python-list


linear algebric equations

2020-12-07 Thread Tito Sanò
Regarding the solution of linear algebraic equations I noticed a big
difference in the computation

time in Python compared to the old fortran language.

I have compared both the linelg and lapack.dgesv-lapack.zgesv modules with
the fortan: dgelg and f04adf. 

The difference in computation time is enormous:

for example for 430 degrees of freedom it is about 24 min in Python versus
about 1 sec in fortran.

Is it possible to get better performance in Python?

Thanks in advance  

Tito Sano’ 

Roma Italy

Cell: 339 6903895

 

-- 
https://mail.python.org/mailman/listinfo/python-list