package com.imsl.test.example.math; import com.imsl.math.*; /** *

* Converts a real matrix to a complex matrix.

* * The Complex class is used to convert a real matrix to a * complex matrix. An LU decomposition of the matrix is performed and the * determinant and condition number of the matrix are obtained. * * @see Code * @see Output */ public class ComplexEx1 { public static void main(String args[]) throws SingularMatrixException { double ar[][] = { {1, 3, 3}, {1, 3, 4}, {1, 4, 3} }; double br[] = {12, 13, 14}; Complex a[][] = new Complex[3][3]; Complex b[] = new Complex[3]; for (int i = 0; i < 3; i++) { b[i] = new Complex(br[i]); for (int j = 0; j < 3; j++) { a[i][j] = new Complex(ar[i][j]); } } // Compute the LU factorization of A ComplexLU clu = new ComplexLU(a); // Solve Ax = b Complex x[] = clu.solve(b); System.out.println("The solution is:"); System.out.println(" "); new PrintMatrix("x").print(x); // Find the condition number of A. double condition = clu.condition(a); System.out.println("The condition number = " + condition); System.out.println(); // Find the determinant of A. Complex determinant = clu.determinant(); System.out.println("The determinant = " + determinant); } }