import java.util.Scanner;
public class array
{
public static void main(String[] args) {
//deklarasi variabel array dan penciptaan
Double array[][]=new Double [2][2];
Scanner scan=new Scanner(System.in);
System.out.println("Masukkan nilai matriks baris 1 kolom 1: ");
array[0][0]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 1 kolom 2: ");
array[0][1]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 2 kolom 1: ");
array[1][0]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 2 kolom 2: ");
array[1][1]=scan.nextDouble();
System.out.println("Matriks input");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.print(array[i][j]+" ");
}
System.out.println();
}
Double transpose[][]={{array[0][0],array[1][0]},{array[0][1],array[1][1]}};
Double det=(array[0][0]*array[1][1])-(array[0][1]*array[1][0]);
Double invers[][]={{array[1][1]/det,array[0][1]/det*-1},{array[1][0]/det*-1,array[0][0]}};
if(transpose[0][0]==invers[0][0] && transpose[0][1]==invers[0][1] && transpose[1][0]==invers[1][0] && transpose[1][1]==invers[1][1])
{
System.out.println("Matriks ini orthogonal!");
}
else
{
System.out.println("Matriks ini bukan matriks orthogonal");
}
}
}
public class array
{
public static void main(String[] args) {
//deklarasi variabel array dan penciptaan
Double array[][]=new Double [2][2];
Scanner scan=new Scanner(System.in);
System.out.println("Masukkan nilai matriks baris 1 kolom 1: ");
array[0][0]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 1 kolom 2: ");
array[0][1]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 2 kolom 1: ");
array[1][0]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 2 kolom 2: ");
array[1][1]=scan.nextDouble();
System.out.println("Matriks input");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.print(array[i][j]+" ");
}
System.out.println();
}
Double transpose[][]={{array[0][0],array[1][0]},{array[0][1],array[1][1]}};
Double det=(array[0][0]*array[1][1])-(array[0][1]*array[1][0]);
Double invers[][]={{array[1][1]/det,array[0][1]/det*-1},{array[1][0]/det*-1,array[0][0]}};
if(transpose[0][0]==invers[0][0] && transpose[0][1]==invers[0][1] && transpose[1][0]==invers[1][0] && transpose[1][1]==invers[1][1])
{
System.out.println("Matriks ini orthogonal!");
}
else
{
System.out.println("Matriks ini bukan matriks orthogonal");
}
}
}
0 Response to "contoh matriks orthogonal "
Post a Comment