Examples of LUDecomposition


Examples of org.apache.commons.math3.linear.LUDecomposition

     */
    @Override
    protected RealMatrix calculateBetaVariance() {
        int p = getX().getColumnDimension();
        RealMatrix Raug = qr.getR().getSubMatrix(0, p - 1 , 0, p - 1);
        RealMatrix Rinv = new LUDecomposition(Raug).getSolver().getInverse();
        return Rinv.multiply(Rinv.transpose());
    }
View Full Code Here

Examples of org.apache.commons.math3.linear.LUDecomposition

     * <p>The inverse of the covariance matrix is lazily evaluated and cached.</p>
     * @return inverse of the covariance
     */
    protected RealMatrix getOmegaInverse() {
        if (OmegaInverse == null) {
            OmegaInverse = new LUDecomposition(Omega).getSolver().getInverse();
        }
        return OmegaInverse;
    }
View Full Code Here

Examples of org.apache.commons.math3.linear.LUDecomposition

    @Override
    protected RealVector calculateBeta() {
        RealMatrix OI = getOmegaInverse();
        RealMatrix XT = getX().transpose();
        RealMatrix XTOIX = XT.multiply(OI).multiply(getX());
        RealMatrix inverse = new LUDecomposition(XTOIX).getSolver().getInverse();
        return inverse.multiply(XT).multiply(OI).operate(getY());
    }
View Full Code Here

Examples of org.apache.commons.math3.linear.LUDecomposition

     */
    @Override
    protected RealMatrix calculateBetaVariance() {
        RealMatrix OI = getOmegaInverse();
        RealMatrix XTOIX = getX().transpose().multiply(OI).multiply(getX());
        return new LUDecomposition(XTOIX).getSolver().getInverse();
    }
View Full Code Here

Examples of org.apache.commons.math3.linear.LUDecomposition

                this.As[c][i] = new float[len][len];
                this.Bs[c][i] = new float[len];

                for (int j = 0; j < len; ++j) {
                    coef = new Array2DRowRealMatrix(regLs[c][i][j], false);
                    solver = new LUDecomposition(coef).getSolver();
                    vect = new ArrayRealVector(regRs[c][i][j], false);
                    ABloc = solver.solve(vect);

                    for (int k = 0; k < len; ++k) {
                        this.As[c][i][j][k] = (float) ABloc.getEntry(k);
View Full Code Here

Examples of org.ejml.factory.LUDecomposition

    @Test
    public void testSingular(){
        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 1, 2, 3, 2, 4, 6, 4, 4, 0);

        LUDecomposition alg = create(3,3);
        assertTrue(alg.decompose(A));
        assertTrue(alg.isSingular());
    }
View Full Code Here

Examples of org.ejml.factory.LUDecomposition

    @Test
    public void testNearlySingular(){
        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 1, 2, 3, 2, 4, 6.1, 4, 4, 0);

        LUDecomposition alg = create(3,3);
        assertTrue(alg.decompose(A));
        assertFalse(alg.isSingular());
    }
View Full Code Here

Examples of org.encog.mathutil.matrices.decomposition.LUDecomposition

   *            right hand side.
   * @return Solution if A is square, least squares solution otherwise.
   */
  public final Matrix solve(final Matrix b) {
    if (getRows() == getCols()) {
      return (new LUDecomposition(this)).solve(b);
    } else {
      return (new QRDecomposition(this)).solve(b);
    }
  }
View Full Code Here

Examples of org.encog.mathutil.matrices.decomposition.LUDecomposition

   * Perform one iteration.
   */
  @Override
  public void iteration() {

    LUDecomposition decomposition = null;
    preIteration();

    this.weights = NetworkCODEC.networkToArray(this.network);

    double sumOfSquaredErrors = jacobianByFiniteDifference();

    // this.setError(j.getError());
    calculateHessian();

    // Define the objective function
    // bayesian regularization objective function
    final double objective = this.beta * sumOfSquaredErrors;
    double current = objective + 1.0;

    // Start the main Levenberg-Macquardt method
    this.lambda /= LevenbergMarquardtTraining.SCALE_LAMBDA;

    // We'll try to find a direction with less error
    // (or where the objective function is smaller)
    while ((current >= objective)
        && (this.lambda < LevenbergMarquardtTraining.LAMBDA_MAX)) {
      this.lambda *= LevenbergMarquardtTraining.SCALE_LAMBDA;

      // Update diagonal (Levenberg-Marquardt formula)
      for (int i = 0; i < this.parametersLength; i++) {
        this.hessian[i][i] = this.diagonal[i] + this.lambda;
      }

      // Decompose to solve the linear system
      decomposition = new LUDecomposition(this.hessianMatrix);

      // Check if the Jacobian has become non-invertible
      if (!decomposition.isNonsingular()) {
        continue;
      }

      // Solve using LU (or SVD) decomposition
      this.deltas = decomposition.Solve(this.gradient);

      // Update weights using the calculated deltas
      updateWeights();

      // Calculate the new error
View Full Code Here

Examples of org.encog.mathutil.matrices.decomposition.LUDecomposition

   *            right hand side.
   * @return Solution if A is square, least squares solution otherwise.
   */
  public Matrix solve(final Matrix b) {
    if (getRows() == getCols()) {
      return (new LUDecomposition(this)).solve(b);
    } else {
      return (new QRDecomposition(this)).solve(b);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.