Java Code Examples for org.ejml.ops.CommonOps#transpose()
The following examples show how to use
org.ejml.ops.CommonOps#transpose() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleLinearRegressionModel.java From java-timeseries with MIT License | 6 votes |
private MatrixFormulation() { int numRows = response.length; int numCols = predictors.length + ((hasIntercept) ? 1 : 0); this.X = createMatrixA(numRows, numCols); this.Xt = new DenseMatrix64F(numCols, numRows); CommonOps.transpose(X, Xt); this.XtXInv = new DenseMatrix64F(numCols, numCols); this.b = new DenseMatrix64F(numCols, 1); this.y = new DenseMatrix64F(numRows, 1); solveSystem(numRows, numCols); this.fitted = computeFittedValues(); this.residuals = computeResiduals(); this.sigma2 = estimateSigma2(numCols); this.covarianceMatrix = new DenseMatrix64F(numCols, numCols); CommonOps.scale(sigma2, XtXInv, covarianceMatrix); }
Example 2
Source File: MissingOps.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
public static DenseMatrix64F wrapSpherical(final double[] source, final int offset, final int dim, final double[] buffer) { fillSpherical(source, offset, dim, buffer); DenseMatrix64F res = DenseMatrix64F.wrap(dim, dim, buffer); CommonOps.transpose(res); // Column major. return res; }
Example 3
Source File: EllipticalSliceOperator.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
private static void rotateNd(double[] x, int dim) { // Get first `dim` locations DenseMatrix64F matrix = new DenseMatrix64F(dim, dim); for (int row = 0; row < dim; ++row) { for (int col = 0; col < dim; ++col) { matrix.set(row, col, x[col * dim + row]); } } // Do a QR decomposition QRDecomposition<DenseMatrix64F> qr = DecompositionFactory.qr(dim, dim); qr.decompose(matrix); DenseMatrix64F qm = qr.getQ(null, true); DenseMatrix64F rm = qr.getR(null, true); // Reflection invariance if (rm.get(0,0) < 0) { CommonOps.scale(-1, rm); CommonOps.scale(-1, qm); } // Compute Q^{-1} DenseMatrix64F qInv = new DenseMatrix64F(dim, dim); CommonOps.transpose(qm, qInv); // Apply to each location for (int location = 0; location < x.length / dim; ++location) { WrappedVector locationVector = new WrappedVector.Raw(x, location * dim, dim); MissingOps.matrixVectorMultiple(qInv, locationVector, locationVector, dim); } }
Example 4
Source File: MissingOps.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
public static void forceSymmetric(DenseMatrix64F P) { DenseMatrix64F Ptrans = new DenseMatrix64F(P); CommonOps.transpose(P, Ptrans); CommonOps.addEquals(P, Ptrans); CommonOps.scale(0.5, P); }
Example 5
Source File: SafeMultivariateActualizedWithDriftIntegrator.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
private void computeIOUVarianceBranch(final int sourceOffset, final int destinationOffset, double branchLength, DenseMatrix64F inverseSelectionStrength) { DenseMatrix64F actualization = wrap(actualizations, destinationOffset, dimProcess, dimProcess); DenseMatrix64F stationaryVariance = wrap(stationaryVariances, sourceOffset, dimProcess, dimProcess); DenseMatrix64F invAS = new DenseMatrix64F(dimProcess, dimProcess); CommonOps.mult(inverseSelectionStrength, stationaryVariance, invAS); //// Variance YY DenseMatrix64F varianceYY = wrap(variances, destinationOffset, dimProcess, dimProcess); //// Variance XX DenseMatrix64F varianceXX = new DenseMatrix64F(dimProcess, dimProcess); // Variance 1 CommonOps.multTransB(invAS, inverseSelectionStrength, varianceXX); DenseMatrix64F temp = new DenseMatrix64F(dimProcess, dimProcess); CommonOps.multTransB(varianceXX, actualization, temp); CommonOps.multAdd(-1.0, actualization, temp, varianceXX); // Delta DenseMatrix64F delta = new DenseMatrix64F(dimProcess, dimProcess); addTrans(invAS, delta); // Variance 2 CommonOps.addEquals(varianceXX, branchLength, delta); // Variance 3 DenseMatrix64F temp2 = CommonOps.identity(dimProcess); CommonOps.addEquals(temp2, -1.0, actualization); DenseMatrix64F temp3 = new DenseMatrix64F(dimProcess, dimProcess); CommonOps.mult(temp2, inverseSelectionStrength, temp3); CommonOps.mult(temp3, delta, temp2); addTrans(temp2, temp); // All CommonOps.addEquals(varianceXX, -1.0, temp); //// Variance XY DenseMatrix64F varianceXY = new DenseMatrix64F(dimProcess, dimProcess); // Variance 1 CommonOps.multTransB(stationaryVariance, temp3, varianceXY); // Variance 2 CommonOps.mult(temp3, stationaryVariance, temp); CommonOps.multTransB(temp, actualization, temp2); // All CommonOps.addEquals(varianceXY, -1.0, temp2); //// Variance YX DenseMatrix64F varianceYX = new DenseMatrix64F(dimProcess, dimProcess); CommonOps.transpose(varianceXY, varianceYX); blockUnwrap(varianceYY, varianceXX, varianceXY, varianceYX, variances, destinationOffset); schurComplementInverse(varianceYY, varianceXX, varianceXY, varianceYX, precisions, destinationOffset); }
Example 6
Source File: SafeMultivariateActualizedWithDriftIntegrator.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
private void addTrans(DenseMatrix64F A, DenseMatrix64F B) { CommonOps.transpose(A, B); CommonOps.addEquals(B, A); }