Transforms on matrix (inversion, multiplications, etc.)
Source code name: "la4j_matrix_transf1.py"
Programming language: Python
Topic: Linear Algebra/Matrices
DMelt Version 1. Last modified: 07/23/2017. License: Pro
https://datamelt.org/code/cache/la4j_matrix_transf1_8918.py
To run this script using the DataMelt 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.matrix.functor import * from org.la4j.vector.sparse import * from org.la4j.vector.dense import * from org.la4j import * print "Create Dense matrix" a=Basic2DMatrix.from2DArray( [[1.0, 2.0, 3.0 ], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]) print "Create Sparse matrix" b=CRSMatrix.from2DArray( [[1.0, 2.0, 3.0 ], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]) print "Multiply 'a' by 'b'" c = a.multiply(b) print c.toString() print "Inner product of 2 vectors" a = BasicVector([1.0, 2.0, 3.0 ]) b = BasicVector([4.0, 5.0, 6.0 ]) d = a.innerProduct(b) # 1.0*4.0 + 2.0*5.0 + 3.0*6.0 = 32 print d

Ads help maintain this website.