List of usage examples for org.apache.commons.math.linear RealMatrix getRowDimension
int getRowDimension();
From source file:math2605.gn_log.java
private static void setJ(List<String[]> pairs, double a, double b, double c, RealMatrix r, RealMatrix J) { for (int i = 0; i < r.getRowDimension(); i++) { double x = Double.parseDouble(pairs.get(i)[0]); for (int j = 0; j < 3; j++) { double entry = -1; if (j == 0) { entry = -(Math.log(x + b)); } else if (j == 1) { entry = -a / (x + b);/*from w ww . j a va2 s . c o m*/ } J.setEntry(i, j, entry); } } }
From source file:math2605.gn_rat.java
private static void setJ(List<String[]> pairs, double a, double b, double c, RealMatrix r, RealMatrix J) { for (int i = 0; i < r.getRowDimension(); i++) { double x = Double.parseDouble(pairs.get(i)[0]); for (int j = 0; j < 3; j++) { double entry = -1; if (j == 0) { entry = -x / (x + b);// ww w.j a va 2 s .c o m } else if (j == 1) { entry = (a * x) / Math.pow(x + b, 2); } J.setEntry(i, j, entry); } } }
From source file:math2605.gn_exp.java
private static void setJ(List<String[]> pairs, double a, double b, double c, RealMatrix r, RealMatrix J) { for (int i = 0; i < r.getRowDimension(); i++) { double x = Double.parseDouble(pairs.get(i)[0]); for (int j = 0; j < 3; j++) { double entry = -1; if (j == 0) { entry = -(Math.pow(Math.E, b * x)); } else if (j == 1) { entry = -a * x * Math.pow(Math.E, b * x); }//from www.j a v a2 s .com J.setEntry(i, j, entry); } } }
From source file:math2605.gn_qua.java
private static void setJ(List<String[]> pairs, double a, double b, double c, RealMatrix r, RealMatrix J) { for (int i = 0; i < r.getRowDimension(); i++) { double x = Double.parseDouble(pairs.get(i)[0]); for (int j = 0; j < 3; j++) { double entry = -1; if (j == 0) { entry = -x * x;// www .j av a 2 s .co m } else if (j == 1) { entry = -x; } J.setEntry(i, j, entry); } } }
From source file:juicebox.tools.utils.juicer.arrowhead.DynamicProgrammingUtils.java
/** * Calculate cumulative sums across upper right matrix * iterative result is entry to left + entry below + orig value - diagonal down (else we double count) * * @param matrix/*from w w w. j a v a 2s.c om*/ * @param superDiagonal * @return */ public static RealMatrix sum(RealMatrix matrix, int superDiagonal) { int n = Math.min(matrix.getRowDimension(), matrix.getColumnDimension()); RealMatrix diagMatrix = MatrixTools.cleanArray2DMatrix(matrix.getRowDimension(), matrix.getColumnDimension()); if (superDiagonal <= 0) { diagMatrix = MatrixTools.extractDiagonal(matrix); superDiagonal = 1; } // d = distance from diagonal for (int d = superDiagonal; d < n; d++) { // i = row, column is i +d; for (int i = 0; i < n - d; i++) { diagMatrix.setEntry(i, i + d, diagMatrix.getEntry(i, i + d - 1) + diagMatrix.getEntry(i + 1, i + d) + matrix.getEntry(i, i + d) - diagMatrix.getEntry(i + 1, i + d - 1)); } } return diagMatrix; }
From source file:juicebox.tools.utils.juicer.arrowhead.DynamicProgrammingUtils.java
/** * Dynamic programming to calculate "right" matrix * Initialize by setting the diagonal to the diagonal of original * Iterate to the right and up.//from ww w. j a va 2 s. com * * @param matrix * @param maxSize * @return rightMatrix */ public static RealMatrix right(RealMatrix matrix, int maxSize) { RealMatrix rightMatrix = MatrixTools.extractDiagonal(matrix); int n = rightMatrix.getRowDimension(); // j is column, i is row for (int j = 1; j < n; j++) { int endPoint = Math.max(j - 1 - maxSize, 0); for (int i = j - 1; i >= endPoint; i--) { rightMatrix.setEntry(i, j, matrix.getEntry(i, j) + rightMatrix.getEntry(i + 1, j)); } } return rightMatrix; }
From source file:juicebox.tools.utils.juicer.arrowhead.DynamicProgrammingUtils.java
/** * Dynamic programming to calculate "upper" matrix * Initialize by setting the diagonal to the diagonal of original * Iterate down (for each row) and to the left. * * @param matrix/*w ww.ja v a2s . co m*/ * @param maxSize * @return upperMatrix */ public static RealMatrix upper(RealMatrix matrix, int maxSize) { RealMatrix upperMatrix = MatrixTools.extractDiagonal(matrix); int n = upperMatrix.getRowDimension(); // j is column, i is row for (int i = 0; i < n; i++) { int endPoint = Math.min(i + 1 + maxSize, n - 1); for (int j = i + 1; j <= endPoint; j++) { upperMatrix.setEntry(i, j, matrix.getEntry(i, j) + upperMatrix.getEntry(i, j - 1)); } } return upperMatrix; }
From source file:juicebox.tools.utils.juicer.apa.APAUtils.java
public static double peakEnhancement(RealMatrix matrix) { int rows = matrix.getRowDimension(); int center = rows / 2; double centerVal = matrix.getEntry(center, center); double remainingSum = APARegionStatistics.sum(matrix.getData()) - centerVal; double remainingAverage = remainingSum / (rows * rows - 1); return centerVal / remainingAverage; }
From source file:juicebox.tools.utils.juicer.apa.APAUtils.java
public static RealMatrix centerNormalization(RealMatrix matrix) { int center = matrix.getRowDimension() / 2; double centerVal = matrix.getEntry(center, center); if (centerVal == 0) { centerVal = MatrixTools.minimumPositive(matrix); if (centerVal == 0) centerVal = 1;/*w w w. ja v a 2 s. c o m*/ } return matrix.copy().scalarMultiply(1. / centerVal); }
From source file:net.sf.maltcms.chromaui.features.spi.FeatureTable.java
public static RealMatrix normalize(RealMatrix sourceMatrix, boolean center, boolean normalize) { RealMatrix normalized = MatrixUtils.createRealMatrix(sourceMatrix.getRowDimension(), sourceMatrix.getColumnDimension()); for (int col = 0; col < sourceMatrix.getColumnDimension(); col++) { double[] columnVector = sourceMatrix.getColumn(col); double mean = StatUtils.mean(columnVector); double stdev = Math.sqrt(StatUtils.variance(columnVector, mean)); Logger.getLogger(FeatureTable.class.getName()).log(Level.INFO, "column {0}, mean={1} stdev={2}", new Object[] { col, mean, stdev }); for (int j = 0; j < columnVector.length; j++) { normalized.setEntry(j, col, (sourceMatrix.getEntry(j, col) - mean) / stdev); }/* ww w .jav a2 s . c o m*/ } return normalized; }