Solving a system of linear equations using LU fact
Code: "jplasma_lu.py". Programming language: Python
DMelt Version 1.4. Last modified: 06/09/2018. License: Pro
https://datamelt.org/code/cache/jplasma_lu_4129.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from edu.emory.mathcs.jplasma.tdouble import Dplasma;
from edu.emory.mathcs.utils import ConcurrencyUtils;
from jarray import *
from java.lang import Math
M=15; N=10; NRHS=5;
A=zeros(M*N, 'd'); B=zeros(M*NRHS,'d')
for i in range(M):
for j in range(N):
A[M*j + i] = 0.5 - Math.random()
for i in range(M):
for j in range (NRHS):
B[M * j + i] = Math.random()
ConcurrencyUtils.setNumberOfThreads(2) # (Optional step) Set the maximum number of threads
Dplasma.plasma_Init(M, N, NRHS) # Plasma Initialize
Dplasma.plasma_set_int(Dplasma.PLASMA_CONCURRENCY, 2)
L=Dplasma.plasma_Allocate_L(N, N);
IPIV=Dplasma.plasma_Allocate_IPIV(N, N);
INFO = Dplasma.plasma_DGESV(N, NRHS, A, 0, N, L, 0, IPIV, 0, B, 0, N);
Dplasma.plasma_Finalize()
if INFO < 0:
print "-- Error in DgelsExample example !"
else:
print "-- Run successfull !"
print IPIV
You see the box below because you did not login.