from org.ejml.data import DenseMatrix64F
from org.ejml.ops import RandomMatrices
from org.ejml.factory import LinearSolverFactory
from java.util import Random
rand =Random()
A=DenseMatrix64F(3,3, True, [5, 2, 3, 1.5, -2, 8, -3, 4.7, -0.5])
b=DenseMatrix64F(3,1, True, [18, 21.5, 4.9000])
x=RandomMatrices.createRandom(3,1,rand)
solver =LinearSolverFactory.linear(3)
if solver.setA(A) == False:
print "Singular matrix"
c=solver.solve(b,x)
x.print()
Ads help maintain this website.