Solving linear equitions and decomposition
Code: "la4j_matrix_lin_eq.py". Programming language: Python DMelt Version 1. Last modified: 07/23/2017. License: Pro
https://datamelt.org/code/cache/la4j_matrix_lin_eq_3296.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.


"""

Lightweight Java sparse/dense matrix library

The La4j is open source and 100% Java library that provides Linear Algebra primitives (matrices and vectors) and algorithms. The la4j was initially designed to be lightweight and simple tool for passionate Java developers. It has been started as student project and turned into one of the most popular Java packages for matrices and vectors. """ from org.la4j.matrix.dense import * from org.la4j.matrix.sparse import * from org.la4j.matrix import * from org.la4j.vector.sparse import * from org.la4j.vector.dense import * from org.la4j import * a=Basic1DMatrix.from2DArray([ [1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ], [ 7.0, 8.0, 9.0 ], [ 10.0, 11.0, 12.0 ], [ 13.0, 14.0, 15.0 ] ]) # A right hand side vector, which is simple dense vector b = BasicVector([1.0, 2.0, 3.0,4,5]) # We will use Least Squares method, # which is based on QR decomposition and can be used with overdetermined systems solver = a.withSolver(LinearAlgebra.SOLVER) # The 'x' vector will be sparse x = solver.solve(b) print "Solution=",x.toString()

Ads help maintain this website.