Linear solver for systems of the form A*x=b, where A and B are known and x is unknown
Code: "matrix_ejml_solve.py". Programming language: Python
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/matrix_ejml_solve_2067.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 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()
You see the box below because you did not login.