Package Jama

Examples of Jama.Matrix


        { 0, 0, v2z, 0, 0, -v1z }, { 0, 0, 0, 0, 1, 0 } };

    double[][] arrayb = { { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 0 } };
    //t double[][] arrayb ={{1,1,1,0,0,0,0,0,0}};

    Matrix A = new Matrix(arraya);
    Matrix b = new Matrix(arrayb);
    Matrix x = A.solve(b);

    BetaVertex vf1 = new BetaVertex(x.get(0, 0), x.get(1, 0), x.get(2, 0));
    BetaVertex vf2 = new BetaVertex(x.get(3, 0), x.get(4, 0), x.get(5, 0));

    //BetaVertex v3 = new BetaVertex();
    //BetaVertex v4 = new BetaVertex();

    Sector3D out = new Sector3D(vf1, vf2, v1, v2, 2, st1, st2);
View Full Code Here


      q1 = templatePoints.get(r1);
      q2 = templatePoints.get(r2);
      q3 = templatePoints.get(r3);

      double[][] array1 = { { p1.x, p1.y, 1 }, { p2.x, p2.y, 1 }, { p3.x, p3.y, 1 } };
      Matrix matrix = new Matrix(array1);

      try {
        double[][] vector1_ = { { q1.x }, { q2.x }, { q3.x } };
        Matrix vector1 = new Matrix(vector1_);

        Matrix result1 = matrix.solve(vector1);
        double[][] zeile1 = result1.getArray();

        double[][] vector2_ = { { q1.y }, { q2.y }, { q3.y } };
        Matrix vector2 = new Matrix(vector2_);

        Matrix result2 = matrix.solve(vector2);
        double[][] zeile2 = result2.getArray();

        double a11 = zeile1[0][0];
        double a12 = zeile1[1][0];
        double a13 = zeile1[2][0];
View Full Code Here

          alfa[k][j] += poli[k] * poli[j];
        }
      }
    }

    Matrix mAlfa = new Matrix(alfa);
    Matrix mBeta = new Matrix(beta);
    Matrix mA = new Matrix(order + 1, 1);
    mA = mAlfa.solve(mBeta);
    beta = mA.getArrayCopy();
    for (int i = 0; i <= order; i++) {
      a[i] = beta[i][0];
    }
    return a;
  }
View Full Code Here

   */
  public static double[] fitSVD(int ndata, double[] x, double[] y, double[] sd, int order) {
    if ((y.length < ndata) || (x.length < ndata) || ((sd != null) && (sd.length < ndata))) {
      throw new IllegalArgumentException("data paramenters incorrect too short vector");
    }
    Matrix A = new Matrix(ndata, order + 1);
    double[] b = new double[ndata];
    SingularValueDecomposition SVD;
    double[] a = new double[order + 1];
    double xVal;
    double yVal;
    double small = 0.0000000001 * ndata;
    double[] coeff = new double[order + 1];
    double[][] U;
    double[][] V;
    double[] w;

    if (sd == null) {
      sd = new double[ndata];
      for (int i = 0; i < ndata; i++) {
        sd[i] = 1;
      }
    }

    for (int i = 0; i < ndata; i++) {
      A.set(i, 0, 1 / sd[i]);
    }
    for (int i = 0; i < ndata; i++) {
      xVal = 1;
      yVal = 1;
      for (int j = 1; j <= order; j++) {
        xVal *= x[i];
        yVal += xVal;
        A.set(i, j, xVal / sd[i]);
      }
      b[i] = yVal / sd[i];
    }
    SVD = A.svd();
    U = (SVD.getU()).getArray();
    V = (SVD.getV()).getArray();
    w = SVD.getSingularValues();

    for (int j = 0; j <= order; j++) {
View Full Code Here

  /**
   * computes the variance of the extimator of the variance
   */
  protected double calcExtimatorVar(int K, int polyOrder) {
    Matrix X = new Matrix(K, polyOrder + 1);
    Matrix Xt = new Matrix(polyOrder + 1, K);
    Matrix square = new Matrix(K, K);
    for (int i = 0; i < K; i++) {
      for (int j = 0; j <= polyOrder; j++) {
        X.set(i, j, (Math.pow((4 * ((double) i + 1) - 1) / (2 * (double) K), j)));
      }
    }
    Xt = X.transpose();
    square = Xt.times(X);
    square = square.inverse();
    //System.out.println("calcConst "+square.get(0,0));
    return (.645 * square.get(0, 0));
  }
View Full Code Here

   * Demands associati.
   */
  public Sector2D BetaCalc2D(newPoint p1, newPoint p2) {
    double[][] arraya = { { 1, 1, 0, 0 }, { 0, 0, 1, 1 }, { -p2.getX(), 0, p1.getX(), 0 }, { 0, p2.getY(), 0, -p1.getY() } };
    double[][] arrayb = { { 1 }, { 1 }, { 0 }, { 0 } };
    Matrix A = new Matrix(arraya);
    Matrix b = new Matrix(arrayb);
    Matrix x = A.solve(b);
    // Creo un nuovo settore con le soluzioni e i punti associati
    Sector2D out = new Sector2D(x.get(0, 0), x.get(1, 0), x.get(2, 0), x.get(3, 0), p1, p2);
    return out;
  }
View Full Code Here

      }
   
      logger.info("cijMatrix after normalization = " this.printMatrix(cijMatrix));
     
      //transpose and multiplication
      trustScores = new Matrix(cijMatrix);
      Matrix trans = trustScores.transpose();
     
      Matrix orig = new Matrix(trans.getArray());

      //trust everyone equally in the beginning
      double tempScore = 1.0/(double)numVertices;
      double[][] tk = new double[numVertices][numVertices];
      for(int i=0;i<numVertices;i++)
      {
        for(int j=0;j<numVertices;j++) tk[i][j] = tempScore;
      }
      Matrix tkMatrix = new Matrix(tk);
     
      double[][] p = new double[numVertices][numVertices];
      for(int i=0;i<numVertices;i++)
      {
        for(int j=0;j<numVertices;j++) p[i][j] = tempScore;
      }
      Matrix pMatrix = new Matrix(p); //preTrusted matrix
     
      double a=0.2; //TODO make this configurable
      Matrix tkplus1Matrix = null;
     
     
      for(int i=0;i<this.iterations;i++)
      {
        tkplus1Matrix = trans.times(tkMatrix);
        tkplus1Matrix = tkplus1Matrix.times(1-a);
        tkplus1Matrix = tkplus1Matrix.plus(pMatrix.times(a));
        tkMatrix = new Matrix(tkplus1Matrix.getArrayCopy());
        //System.out.println(printMatrix(tkplus1Matrix.getArray()));
        //System.out.println("row=" + tkplus1Matrix.getRowDimension() + " column="+tkplus1Matrix.getColumnDimension());
      }
     
      this.trustScores = tkMatrix;
View Full Code Here

    this.degreeToCCarrierMatrix = createMatrix(allCarriers);
   
    System.out.println("this.degreeToCCarrierMatrix");
    this.degreeToCCarrierMatrix.print(15, 5);

    Matrix usedToCCDirectMatrix = polyofdm.cc.full.FullCC.createCancellationMatrix(allCarriers, cancellationCarriers);
    this.usedToDegreeMatrix = this.degreeToCCarrierMatrix.transpose().times(usedToCCDirectMatrix);
           
  }
View Full Code Here

  }

  private Matrix createMatrix(int allCarriers) {
    double[] ccWeightings = createWeightings(cCarriers);

    Matrix cCarriersToCancelledDegrees = new Matrix(cCarriers.length, cCarriers.length);
    for (int degree = 0; degree < cCarriers.length; degree++) {
      for (int cCarrierIndex = 0; cCarrierIndex < cCarriers.length; cCarrierIndex++) {
        cCarriersToCancelledDegrees.set(degree, cCarrierIndex, power(cCarriers[cCarrierIndex] - ((usedCarriers.length+cCarriers.length-1)/2d), degree) * ccWeightings[cCarrierIndex]);
      }     
    }
    Utils.makeOrthoGramSchmidt(cCarriersToCancelledDegrees);
    System.out.println("cCarriersToCancelledDegrees0");
    cCarriersToCancelledDegrees.print(15, 15);
    cCarriersToCancelledDegrees = resort(cCarriersToCancelledDegrees);
    System.out.println("cCarriersToCancelledDegrees resorted");
    cCarriersToCancelledDegrees.print(15, 15);
   
   
    System.out.println("cCarriersToCancelledDegrees gram schmidt");
    cCarriersToCancelledDegrees.print(15, 15);
   
    return cCarriersToCancelledDegrees.transpose();
  }
View Full Code Here

    }
    return product;
  }
 
  private Matrix resort(Matrix matrix) {
    Matrix m = new Matrix(matrix.getRowDimension(), matrix.getColumnDimension());
    for (int i = 0; i < matrix.getRowDimension(); i++) {
      for (int j = 0; j < matrix.getColumnDimension(); j++) {
        m.set(matrix.getRowDimension()-1-i, j, matrix.get(i, j));
      }
    }
    return m;
  }
View Full Code Here

TOP

Related Classes of 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.