List of usage examples for org.apache.commons.math3.linear RRQRDecomposition RRQRDecomposition
public RRQRDecomposition(RealMatrix matrix)
From source file:edu.cmu.tetrad.util.ApacheTetradMatrix.java
public int rank() { return new RRQRDecomposition(apacheData).getRank(0.1); }
From source file:org.jgrasstools.hortonmachine.modules.geomorphology.curvatures.OmsCurvaturesBivariate.java
/** * Calculates the parameters of a bivariate quadratic equation. * /*from www . j av a 2 s . c o m*/ * @param elevationValues the window of points to use. * @return the parameters of the bivariate quadratic equation as [a, b, c, d, e, f] */ private static double[] calculateParameters(final double[][] elevationValues) { int rows = elevationValues.length; int cols = elevationValues[0].length; int pointsNum = rows * cols; final double[][] xyMatrix = new double[pointsNum][6]; final double[] valueArray = new double[pointsNum]; // TODO check on resolution int index = 0; for (int y = 0; y < rows; y++) { for (int x = 0; x < cols; x++) { xyMatrix[index][0] = x * x; // x^2 xyMatrix[index][1] = y * y; // y^2 xyMatrix[index][2] = x * y; // xy xyMatrix[index][3] = x; // x xyMatrix[index][4] = y; // y xyMatrix[index][5] = 1; valueArray[index] = elevationValues[y][x]; index++; } } RealMatrix A = MatrixUtils.createRealMatrix(xyMatrix); RealVector z = MatrixUtils.createRealVector(valueArray); DecompositionSolver solver = new RRQRDecomposition(A).getSolver(); RealVector solution = solver.solve(z); // start values for a, b, c, d, e, f, all set to 0.0 final double[] parameters = solution.toArray(); return parameters; }
From source file:org.jgrasstools.lesto.modules.raster.Las2BivariateRasterMosaic.java
private double[] calculateParameters(final List<LasRecord> pointsInGeometry) { int pointsNum = pointsInGeometry.size(); final double[][] xyMatrix = new double[pointsNum][6]; final double[] valueArray = new double[pointsNum]; for (int i = 0; i < pointsNum; i++) { LasRecord dot = pointsInGeometry.get(i); xyMatrix[i][0] = dot.x * dot.x; // x^2 xyMatrix[i][1] = dot.y * dot.y; // y^2 xyMatrix[i][2] = dot.x * dot.y; // xy xyMatrix[i][3] = dot.x; // x xyMatrix[i][4] = dot.y; // y xyMatrix[i][5] = 1;//from w w w.ja v a2 s .c o m if (doIntensity) { valueArray[i] = dot.intensity; } else { valueArray[i] = dot.z; } } RealMatrix A = MatrixUtils.createRealMatrix(xyMatrix); RealVector z = MatrixUtils.createRealVector(valueArray); DecompositionSolver solver = new RRQRDecomposition(A).getSolver(); RealVector solution = solver.solve(z); // start values for a, b, c, d, e, f, all set to 0.0 final double[] parameters = solution.toArray(); return parameters; }