Package edu.gmu.seor.prognos.unbbayesplugin.cps.Jama

Examples of edu.gmu.seor.prognos.unbbayesplugin.cps.Jama.Matrix



  private CoVarMatrix opCoVarMatComponents(CoVarMatrix coVarMatrix,
      CoVarMatrix coVarMatrix2, int Operator) {
    CoVarMatrix res = new CoVarMatrix();
    Matrix one = new Matrix(coVarMatrix.getCoVarMatrix());
    Matrix two = new Matrix(coVarMatrix2.getCoVarMatrix());
    if(Operator == PLUS_OPERATOR){
      res.setCoVarMatrix(one.plus(two).getArray());
    }else if(Operator == MINUS_OPERATOR){
      res.setCoVarMatrix(one.minus(two).getArray());
    }
View Full Code Here


  }

  private MeanMatrix opMMComponents(MeanMatrix meanMatrix,
      MeanMatrix meanMatrix2, int Operator) {
    MeanMatrix res = new MeanMatrix();
    Matrix one = new Matrix(meanMatrix.getMeanMatrix());
    Matrix two = new Matrix(meanMatrix2.getMeanMatrix());
    if(Operator == PLUS_OPERATOR){
      res.setMeanMatrix(one.plus(two).getArray());
    }else if(Operator == MINUS_OPERATOR){
      res.setMeanMatrix(one.minus(two).getArray());
    }
View Full Code Here

  }

 
  private double[][] getK21(double mat[][], GHKPotentialTable ghkPot) {
    double res[][] = new double[mat.length][mat[0].length];
    Matrix M = new Matrix(res);
    boolean valueSet[][] = new boolean[mat.length][mat[0].length];
    initBooleanToFalse(valueSet);
    for (Node n1 : y2) {
      for (Node n2 : y1) {
        M.set(ghkPot.getContinuousNodeList().indexOf(n1), ghkPot.getContinuousNodeList()
            .indexOf(n2), mat[ghkPot.getContinuousNodeList().indexOf(n1)][ghkPot
            .getContinuousNodeList().indexOf(n2)]);
        valueSet[ghkPot.getContinuousNodeList().indexOf(n1)][ghkPot.getContinuousNodeList().indexOf(n2)] = true;
        // res[ghk.getContinuousNodeList().indexOf(n1)][ghk.getContinuousNodeList().indexOf(n2)]
        // =
        // mat[ghk.getContinuousNodeList().indexOf(n1)][ghk.getContinuousNodeList().indexOf(n2)];
      }
    }
    res = reduceMatrix(valueSet,M.getArray());
    return res;
  }
View Full Code Here

    return res;
  }

  private double[][] getH1(double mat[][], GHKPotentialTable ghkPot) {
    double res[][] = new double[mat.length][mat[0].length];
    Matrix M = new Matrix(res);
    boolean valueSet[][] = new boolean[mat.length][mat[0].length];
    initBooleanToFalse(valueSet);
    for (Node n1 : y1) {
      M.set(ghkPot.getContinuousNodeList().indexOf(n1), 0, mat[ghkPot.getContinuousNodeList()
          .indexOf(n1)][0]);
      valueSet[ghkPot.getContinuousNodeList().indexOf(n1)][0]=true;
    }
    System.out.println("Sending "); printMatrix(M.getArray());
    res = reduceMatrix(valueSet,M.getArray());
    return res;
  }
View Full Code Here

    return res;
  }

  private double[][] getK11(double mat[][], GHKPotentialTable ghkPot) {
    double res[][] = new double[mat.length][mat[0].length];
    Matrix M = new Matrix(res);
    boolean valueSet[][] = new boolean[mat.length][mat[0].length];
    initBooleanToFalse(valueSet);
    for (Node n1 : y1) {
      for (Node n2 : y1) {
        M.set(ghkPot.getContinuousNodeList().indexOf(n1), ghkPot.getContinuousNodeList()
            .indexOf(n2), mat[ghkPot.getContinuousNodeList().indexOf(n1)][ghkPot
            .getContinuousNodeList().indexOf(n2)]);
        valueSet[ghkPot.getContinuousNodeList().indexOf(n1)][ghkPot.getContinuousNodeList().indexOf(n2)] = true;
        // res[ghk.getContinuousNodeList().indexOf(n1)][ghk.getContinuousNodeList().indexOf(n2)]
        // =
        // mat[ghk.getContinuousNodeList().indexOf(n1)][ghk.getContinuousNodeList().indexOf(n2)];
      }
    }
    res = reduceMatrix(valueSet,M.getArray());
    return res;
  }
View Full Code Here

   
    return temp;
  }
   
    public Matrix matInverse(Matrix m){
      Matrix temp;
      try{
        temp = m.inverse();
      }catch(Exception e){
        temp = m;
      }
View Full Code Here

    printGHK(ghk);
   
  }

  private void adjustValues(ContinuousNode continuousNode, double d,ContinuousNode currentNode) {
    Matrix hx = null,hy = null,kxx = null,kxy = null,kyy = null;
    double g;
    HComponent hc = new HComponent();
    KComponent kc = new KComponent();
   
    if(hasNoParents(continuousNode)){ // special case when it is a root node
      Matrix h = new Matrix(continuousNode.getGHK().getGhkPot().getH().gethMatrix());
      Matrix k = new Matrix(continuousNode.getGHK().getGhkPot().getK().getkMatrix());
     
      g = continuousNode.getGHK().getGhkPot().getG() + h.transpose().times(d).det() - (k.times(d).times(d).times(0.5)).det();
      continuousNode.getGHK().getGhkPot().setG(g);
     
      double[][] hMat = new double[1][1];
      hMat[0][0]=0;
      hc.sethMatrix(hMat);
      continuousNode.getGHK().getGhkPot().setH(hc);
     
      double[][] kMat = new double[1][1];
      kMat[0][0]=0;
      kc.setkMatrix(kMat);
      continuousNode.getGHK().getGhkPot().setK(kc);
     
      return;
    }
   
    if(continuousNode.getGHK().hasNoDescreteStates){
      GHKPotential ghk = new GHKPotential();

        hx = new Matrix(getHX(currentNode.getGHK().getGhkPot().getH().gethMatrix(),currentNode.getGHK(),continuousNode));
        hy = new Matrix(getHy(currentNode.getGHK().getGhkPot().getH().gethMatrix(),currentNode.getGHK(),continuousNode));
        kxx = new Matrix(getKXX(currentNode.getGHK().getGhkPot().getK().getkMatrix(),currentNode.getGHK(),continuousNode));
        kxy = new Matrix(getKXY(currentNode.getGHK().getGhkPot().getK().getkMatrix(),currentNode.getGHK(),continuousNode));
        kyy = new Matrix(getKYY(currentNode.getGHK().getGhkPot().getK().getkMatrix(),currentNode.getGHK(),continuousNode));
       
        g = currentNode.getGHK().getGhkPot().getG() + hy.transpose().times(d).det() - (kyy.times(Math.pow(d, 2)).times(0.5)).det();
        ghk.setG(g);
       
        hc = new HComponent();
        hc.sethMatrix(extendAndOPMatrices(hx.getArray(),kxy.times(d).getArray(), MINUS_OPERATOR));
        ghk.setH(hc);
       
        kc = new KComponent();
        kc.setkMatrix(kxx.getArray());
        ghk.setK(kc);
       
        currentNode.getGHK().setGhkPot(ghk);
     
    }else{
     
      for(int i=0;i<currentNode.getGHK().tableSize();i++){
       
        hc = new HComponent();
        kc = new KComponent();
       
          hx = new Matrix(getHX(currentNode.getGHK().getHValue(i).gethMatrix(),currentNode.getGHK(),continuousNode));
          hy = new Matrix(getHy(currentNode.getGHK().getHValue(i).gethMatrix(),currentNode.getGHK(),continuousNode));
          kxx = new Matrix(getKXX(currentNode.getGHK().getKValue(i).getkMatrix(),currentNode.getGHK(),continuousNode));
          kxy = new Matrix(getKXY(currentNode.getGHK().getKValue(i).getkMatrix(),currentNode.getGHK(),continuousNode));
          kyy = new Matrix(getKYY(currentNode.getGHK().getKValue(i).getkMatrix(),currentNode.getGHK(),continuousNode));     
       
        g = currentNode.getGHK().getGValue(i)+ hy.transpose().times(d).det() - (kyy.times(Math.pow(d, 2)).times(0.5)).det();
        currentNode.getGHK().setGValue(i, g);
       
        hc = new HComponent();
View Full Code Here

    for(Node n:continuousNodes){
      if(n.getIndex()!=continuousNode.getIndex())
        restOfNodes.add(n);
    }
    double res[][] = new double[mat.length][mat[0].length];
    Matrix M = new Matrix(res);
    boolean valueSet[][] = new boolean[mat.length][mat[0].length];
    initBooleanToFalse(valueSet);
      for (Node n2 : restOfNodes) {
        M.set(continuousNodes.indexOf(continuousNode), continuousNodes
            .indexOf(n2), mat[continuousNodes.indexOf(continuousNode)][continuousNodes.indexOf(n2)]);
        valueSet[continuousNodes.indexOf(continuousNode)][continuousNodes.indexOf(n2)] = true;
        // res[ghk.getContinuousNodeList().indexOf(n1)][ghk.getContinuousNodeList().indexOf(n2)]
        // =
        // mat[ghk.getContinuousNodeList().indexOf(n1)][ghk.getContinuousNodeList().indexOf(n2)];
      }
    res = reduceMatrix(valueSet,M.getArray());
    return res;
  }
View Full Code Here

  }

  private double[][] getK11X(double[][] mat, GHKPotentialTable ghkPot, ContinuousNode continuousNode) {
    ArrayList<Node> continuousNodes = removeDuplicates((ArrayList<Node>) ghkPot.getContinuousNodeList());
    double res[][] = new double[mat.length][mat[0].length];
    Matrix M = new Matrix(res);
    boolean valueSet[][] = new boolean[mat.length][mat[0].length];
    initBooleanToFalse(valueSet);
    M.set(continuousNodes.indexOf(continuousNode), continuousNodes.indexOf(continuousNode), mat[continuousNodes.indexOf(continuousNode)][continuousNodes.indexOf(continuousNode)]);
    valueSet[continuousNodes.indexOf(continuousNode)][continuousNodes.indexOf(continuousNode)] = true;
    res = reduceMatrix(valueSet,M.getArray());
    return res;
  }
View Full Code Here

    for(Node n:continuousNodes){
      if(n.getIndex()!=continuousNode.getIndex())
        restOfNodes.add(n);
    }
    double res[][] = new double[mat.length][mat[0].length];
    Matrix M = new Matrix(res);
    boolean valueSet[][] = new boolean[mat.length][mat[0].length];
    initBooleanToFalse(valueSet);
    for (Node n1 : restOfNodes) {
        M.set(continuousNodes.indexOf(n1), continuousNodes
            .indexOf(continuousNode), mat[continuousNodes.indexOf(n1)][continuousNodes.indexOf(continuousNode)]);
        valueSet[continuousNodes.indexOf(n1)][continuousNodes.indexOf(continuousNode)] = true;
    }
    res = reduceMatrix(valueSet,M.getArray());
    return res;
  }
View Full Code Here

TOP

Related Classes of edu.gmu.seor.prognos.unbbayesplugin.cps.Jama.Matrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.