Algoritma dan Pemrograman : Implementasi Eigen Value Menggunakan Metode Power

Berikut algoritma Eigen Value menggunakan Metode Power dalam bentuk flowchart :

Pelengkap flowchart utama diatas : 


Implementasi dalam pemrograman java :
/**
 *
 * @author ABD. CHARIS FAUZAN
 */
public class EigenValue_MetodePower {
    
    private double matriks[][];

    public EigenValue_MetodePower() {
        int row, col;
        double ea = 100;
        double es = 5;
        double max, lamda = 0, oldLamda;
        double x0[];
        double mul[], abs[], x[];
        double A[][] = {
            {2, 8, 10},
            {8, 4, 5},
            {10, 5, 7}
        };
        row = A.length;
        col = A[0].length;
        matriks = new double[row][col];
        x0 = new double[row];
        abs = new double[row];
        x = new double[row];
        
        for (int i = 0; i < row; i++) {
            x0[i] = 1;
            for (int j = 0; j < col; j++) {
                matriks[i][j] = A[i][j];
            }

        }
        do {
            mul = MMULT(matriks, x0);
            for (int i = 0; i < mul.length; i++) {
                abs[i] = Math.abs(mul[i]);
            }
            max = getMax(abs);
            oldLamda = lamda;
            lamda = max;
            for (int i = 0; i < mul.length; i++) {
                x[i] = mul[i] / max;
                x0[i]=x[i];
            }
            ea = Math.abs((lamda - oldLamda) / lamda) * 100;
            
            System.out.println("Lamda = " + lamda);
            System.out.println("Ea = " + ea);
            System.out.println("--------------------------");
        } while (es<=ea);
        System.out.println("Lamda : "+lamda);
    }

    private double getMax(double[] tmp) {
        double max = tmp[0];
        for (int i = 0; i < tmp.length; i++) {
            if (max < tmp[i]) {
                max = tmp[i];
            }
        }
        return max;
    }

    // perkalian matrik
    double[] MMULT(double A[][], double x[]) {
        double[] result = new double[x.length];

        for (int i = 0; i < A.length; i++) {
            double temp = 0;
            for (int j = 0; j < A.length; j++) {
                temp += A[i][j] * x[j];
            }
            result[i] = temp;
        }
        return result;
    }

    public static void main(String[] args) {
        new EigenValue_MetodePower();
    }

}
Hasil program ketika dijalankan


0 Response to "Algoritma dan Pemrograman : Implementasi Eigen Value Menggunakan Metode Power"

Post a Comment

Terima Kasih Telah Berkunjung, Silakan Berkomentar...
Kritik dan Saran Teman-Teman Sangat Memotivasi Saya (^_^)

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel