Example usage for weka.core.matrix Matrix inverse

List of usage examples for weka.core.matrix Matrix inverse

Introduction

In this page you can find the example usage for weka.core.matrix Matrix inverse.

Prototype

public Matrix inverse() 

Source Link

Document

Matrix inverse or pseudoinverse

Usage

From source file:cyber009.ann.ANN.java

public void weightFindMatrix() {
    Matrix X = new Matrix(v.X);
    Matrix Y = new Matrix(v.D, 1);
    Matrix W = new Matrix(v.N, 1);

    for (int d = 0; d < v.D; d++) {
        Y.set(d, 0, v.TARGET[d]);/*from  ww w.  java2  s  .  co m*/
    }

    for (int n = 0; n < v.N; n++) {
        W.set(n, 0, 0.0);
        //W.set(n, 0, v.WEIGHT[n]);
    }

    Matrix temp = X.transpose().times(X);
    //        System.out.println(temp.toString());
    temp = temp.inverse().times(X.transpose());
    //        System.out.println(temp.toString());
    temp = temp.times(Y);
    //System.out.println(temp.toString());
    W = temp;
    for (int n = 0; n <= v.N; n++) {
        v.WEIGHT[n] = W.get(n, 0);
    }
    //System.out.println(YI.toString());

}