本文整理匯總了Java中org.apache.commons.math3.linear.Array2DRowRealMatrix.getColumnDimension方法的典型用法代碼示例。如果您正苦於以下問題:Java Array2DRowRealMatrix.getColumnDimension方法的具體用法?Java Array2DRowRealMatrix.getColumnDimension怎麽用?Java Array2DRowRealMatrix.getColumnDimension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.linear.Array2DRowRealMatrix
的用法示例。
在下文中一共展示了Array2DRowRealMatrix.getColumnDimension方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DataSet
import org.apache.commons.math3.linear.Array2DRowRealMatrix; //導入方法依賴的package包/類
public DataSet(Array2DRowRealMatrix data, int[] labels, String[] hdrz, MatrixFormatter formatter, boolean copyData) {
/*// we should allow this behavior...
if(null == labels)
throw new IllegalArgumentException("labels cannot be null");
*/
if(null == data)
throw new IllegalArgumentException("data cannot be null");
if(null == hdrz)
this.headers = genHeaders(data.getColumnDimension());
else
this.headers = VecUtils.copy(hdrz);
// Check to make sure dims match up...
if((null != labels) && labels.length != data.getRowDimension())
throw new DimensionMismatchException(labels.length, data.getRowDimension());
if(this.headers.length != data.getColumnDimension())
throw new DimensionMismatchException(this.headers.length, data.getColumnDimension());
this.data = copyData ? (Array2DRowRealMatrix)data.copy() : data;
this.labels = VecUtils.copy(labels);
this.formatter = null == formatter ? DEF_FORMATTER : formatter;
}
示例2: computeMatrixInverse
import org.apache.commons.math3.linear.Array2DRowRealMatrix; //導入方法依賴的package包/類
/**
* Function to compute matrix inverse via matrix decomposition.
*
* @param in commons-math3 Array2DRowRealMatrix
* @return matrix block
* @throws DMLRuntimeException if DMLRuntimeException occurs
*/
private static MatrixBlock computeMatrixInverse(Array2DRowRealMatrix in)
throws DMLRuntimeException
{
if ( !in.isSquare() )
throw new DMLRuntimeException("Input to inv() must be square matrix -- given: a " + in.getRowDimension() + "x" + in.getColumnDimension() + " matrix.");
QRDecomposition qrdecompose = new QRDecomposition(in);
DecompositionSolver solver = qrdecompose.getSolver();
RealMatrix inverseMatrix = solver.getInverse();
return DataConverter.convertToMatrixBlock(inverseMatrix.getData());
}
示例3: computeCholesky
import org.apache.commons.math3.linear.Array2DRowRealMatrix; //導入方法依賴的package包/類
/**
* Function to compute Cholesky decomposition of the given input matrix.
* The input must be a real symmetric positive-definite matrix.
*
* @param in commons-math3 Array2DRowRealMatrix
* @return matrix block
* @throws DMLRuntimeException if DMLRuntimeException occurs
*/
private static MatrixBlock computeCholesky(Array2DRowRealMatrix in)
throws DMLRuntimeException
{
if ( !in.isSquare() )
throw new DMLRuntimeException("Input to cholesky() must be square matrix -- given: a " + in.getRowDimension() + "x" + in.getColumnDimension() + " matrix.");
CholeskyDecomposition cholesky = new CholeskyDecomposition(in, 1e-14,
CholeskyDecomposition.DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD);
RealMatrix rmL = cholesky.getL();
return DataConverter.convertToMatrixBlock(rmL.getData());
}
示例4: initializeHighOrderDerivatives
import org.apache.commons.math3.linear.Array2DRowRealMatrix; //導入方法依賴的package包/類
/** Initialize the high order scaled derivatives at step start.
* @param h step size to use for scaling
* @param t first steps times
* @param y first steps states
* @param yDot first steps derivatives
* @return Nordieck vector at start of first step (h<sup>2</sup>/2 y''<sub>n</sub>,
* h<sup>3</sup>/6 y'''<sub>n</sub> ... h<sup>k</sup>/k! y<sup>(k)</sup><sub>n</sub>)
*/
public Array2DRowRealMatrix initializeHighOrderDerivatives(final double h, final double[] t,
final double[][] y,
final double[][] yDot) {
// using Taylor series with di = ti - t0, we get:
// y(ti) - y(t0) - di y'(t0) = di^2 / h^2 s2 + ... + di^k / h^k sk + O(h^k)
// y'(ti) - y'(t0) = 2 di / h^2 s2 + ... + k di^(k-1) / h^k sk + O(h^(k-1))
// we write these relations for i = 1 to i= 1+n/2 as a set of n + 2 linear
// equations depending on the Nordsieck vector [s2 ... sk rk], so s2 to sk correspond
// to the appropriately truncated Taylor expansion, and rk is the Taylor remainder.
// The goal is to have s2 to sk as accurate as possible considering the fact the sum is
// truncated and we don't want the error terms to be included in s2 ... sk, so we need
// to solve also for the remainder
final double[][] a = new double[c1.length + 1][c1.length + 1];
final double[][] b = new double[c1.length + 1][y[0].length];
final double[] y0 = y[0];
final double[] yDot0 = yDot[0];
for (int i = 1; i < y.length; ++i) {
final double di = t[i] - t[0];
final double ratio = di / h;
double dikM1Ohk = 1 / h;
// linear coefficients of equations
// y(ti) - y(t0) - di y'(t0) and y'(ti) - y'(t0)
final double[] aI = a[2 * i - 2];
final double[] aDotI = (2 * i - 1) < a.length ? a[2 * i - 1] : null;
for (int j = 0; j < aI.length; ++j) {
dikM1Ohk *= ratio;
aI[j] = di * dikM1Ohk;
if (aDotI != null) {
aDotI[j] = (j + 2) * dikM1Ohk;
}
}
// expected value of the previous equations
final double[] yI = y[i];
final double[] yDotI = yDot[i];
final double[] bI = b[2 * i - 2];
final double[] bDotI = (2 * i - 1) < b.length ? b[2 * i - 1] : null;
for (int j = 0; j < yI.length; ++j) {
bI[j] = yI[j] - y0[j] - di * yDot0[j];
if (bDotI != null) {
bDotI[j] = yDotI[j] - yDot0[j];
}
}
}
// solve the linear system to get the best estimate of the Nordsieck vector [s2 ... sk],
// with the additional terms s(k+1) and c grabbing the parts after the truncated Taylor expansion
final QRDecomposition decomposition = new QRDecomposition(new Array2DRowRealMatrix(a, false));
final RealMatrix x = decomposition.getSolver().solve(new Array2DRowRealMatrix(b, false));
// extract just the Nordsieck vector [s2 ... sk]
final Array2DRowRealMatrix truncatedX = new Array2DRowRealMatrix(x.getRowDimension() - 1, x.getColumnDimension());
for (int i = 0; i < truncatedX.getRowDimension(); ++i) {
for (int j = 0; j < truncatedX.getColumnDimension(); ++j) {
truncatedX.setEntry(i, j, x.getEntry(i, j));
}
}
return truncatedX;
}