To write a program to find the LU Decomposition of a matrix.
- Hardware – PCs
- Anaconda – Python 3.7 Installation / Moodle-Code Runner
- import numpy library using import statement.
- From scipy package import lu().
- Get input from user and pass it as an array.
- Get P, L U martix using lu().
- print L and U matrix.
/*
Program to find the LU Decomposition of a matrix.
Developed by: Aakash S
RegisterNumber: 21500657
*/
import numpy as np from scipy.linalg import lu A=np.array(eval(input())) P,L,U=lu(A) print(L) print(U)
Thus the program to find the LU Decomposition of a matrix is written and verified using python programming.
To write a program to find the LU Decomposition of a matrix.
- Hardware – PCs
- Anaconda – Python 3.7 Installation / Moodle-Code Runner
- import numpy library using import statement.
- From scipy package import lu_factor() and lu_solve().
- Get two inputs from user and pass it as matrix array.
- find lu and pivot value of first marix using lu_factor().
- find solution of the matrix by using lu_solve() by passing lu, pivot values as first argument and second matrix as second argument.
- print the solution.
/*
Program to find the LU Decomposition of a matrix.
Developed by: Aakash S
RegisterNumber: 21500657
*/
import numpy library using import statement. From scipy package import lu_factor() and lu_solve(). Get two inputs from user and pass it as matrix array. find lu and pivot value of first marix using lu_factor(). find solution of the matrix by using lu_solve() by passing lu, pivot values as first argument and second matrix as second argument. print the solution.
Thus the program to find the LU Decomposition of a matrix is written and verified using python programming.