本文整理汇总了Java中org.ejml.data.DenseMatrix64F.getNumCols方法的典型用法代码示例。如果您正苦于以下问题:Java DenseMatrix64F.getNumCols方法的具体用法?Java DenseMatrix64F.getNumCols怎么用?Java DenseMatrix64F.getNumCols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ejml.data.DenseMatrix64F
的用法示例。
在下文中一共展示了DenseMatrix64F.getNumCols方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: det
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static double det(DenseMatrix64F mat) {
int numCol = mat.getNumCols();
int numRow = mat.getNumRows();
if(numCol != numRow) {
throw new IllegalArgumentException("Must be a square matrix.");
} else if(numCol <= 6) {
return numCol >= 2? UnrolledDeterminantFromMinor.det(mat):mat.get(0);
} else {
LUDecompositionAlt_D64 alg = new LUDecompositionAlt_D64();
if(alg.inputModified()) {
mat = mat.copy();
}
return !alg.decompose(mat)?0.0D:alg.computeDeterminant().real;
}
}
示例2: toArray
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static double[][] toArray(SimpleMatrix matrix) {
DenseMatrix64F m = matrix.getMatrix();
double array[][] = new double[m.getNumRows()][m.getNumCols()];
for (int r = 0; r < m.getNumRows(); r++) {
for (int c = 0; c < m.getNumCols(); c++) {
array[r][c] = m.get(r, c);
}
}
return array;
}
示例3: getXtXInverse
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
private double[][] getXtXInverse(MatrixFormulation matrixFormulation) {
DenseMatrix64F XtXInvMatrix = matrixFormulation.XtXInv.copy();
int dim = XtXInvMatrix.getNumCols();
double[][] XtXInvArray = new double[dim][dim];
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
XtXInvArray[i][j] = XtXInvMatrix.get(i, j);
}
}
return XtXInvArray;
}
示例4: denseMatrixToArray
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static float[][] denseMatrixToArray(DenseMatrix64F matrix) {
float array[][] = new float[matrix.getNumRows()][matrix.getNumCols()];
for (int row = 0; row < matrix.getNumRows(); row++)
for (int col = 0; col < matrix.getNumCols(); col++)
array[row][col] = (float) matrix.get(row,col);
return array;
}
示例5: anyDiagonalInfinities
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static boolean anyDiagonalInfinities(DenseMatrix64F source) {
boolean anyInfinities = false;
for (int i = 0; i < source.getNumCols() && !anyInfinities; ++i) {
if (Double.isInfinite(source.unsafe_get(i, i))) {
anyInfinities = true;
}
}
return anyInfinities;
}
示例6: allFiniteDiagonals
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static boolean allFiniteDiagonals(DenseMatrix64F source) {
boolean allFinite = true;
final int length = source.getNumCols();
for (int i = 0; i < length; ++i) {
allFinite &= !Double.isInfinite(source.unsafe_get(i, i));
}
return allFinite;
}
示例7: countFiniteDiagonals
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static int countFiniteDiagonals(DenseMatrix64F source) {
final int length = source.getNumCols();
int count = 0;
for (int i = 0; i < length; ++i) {
final double d = source.unsafe_get(i, i);
if (!Double.isInfinite(d)) {
++count;
}
}
return count;
}
示例8: countZeroDiagonals
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static int countZeroDiagonals(DenseMatrix64F source) {
final int length = source.getNumCols();
int count = 0;
for (int i = 0; i < length; ++i) {
final double d = source.unsafe_get(i, i);
if (d == 0.0) {
++count;
}
}
return count;
}
示例9: getFiniteDiagonalIndices
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static void getFiniteDiagonalIndices(final DenseMatrix64F source, final int[] indices) {
final int length = source.getNumCols();
int index = 0;
for (int i = 0; i < length; ++i) {
final double d = source.unsafe_get(i, i);
if (!Double.isInfinite(d)) {
indices[index] = i;
++index;
}
}
}
示例10: countFiniteNonZeroDiagonals
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static int countFiniteNonZeroDiagonals(DenseMatrix64F source) {
final int length = source.getNumCols();
int count = 0;
for (int i = 0; i < length; ++i) {
final double d = source.unsafe_get(i, i);
if (!Double.isInfinite(d) && d != 0.0) {
++count;
}
}
return count;
}
示例11: getFiniteNonZeroDiagonalIndices
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static void getFiniteNonZeroDiagonalIndices(final DenseMatrix64F source, final int[] indices) {
final int length = source.getNumCols();
int index = 0;
for (int i = 0; i < length; ++i) {
final double d = source.unsafe_get(i, i);
if (!Double.isInfinite(d) && d != 0.0) {
indices[index] = i;
++index;
}
}
}
示例12: invertAndGetDeterminant
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static double invertAndGetDeterminant(DenseMatrix64F mat, DenseMatrix64F result) {
final int numCol = mat.getNumCols();
final int numRow = mat.getNumRows();
if (numCol != numRow) {
throw new IllegalArgumentException("Must be a square matrix.");
}
if (numCol <= 5) {
if (numCol >= 2) {
UnrolledInverseFromMinor.inv(mat, result);
} else {
result.set(0, 1.0D / mat.get(0));
}
return numCol >= 2 ?
UnrolledDeterminantFromMinor.det(mat) :
mat.get(0);
} else {
LUDecompositionAlt_D64 alg = new LUDecompositionAlt_D64();
LinearSolverLu_D64 solver = new LinearSolverLu_D64(alg);
if (solver.modifiesA()) {
mat = mat.copy();
}
if (!solver.setA(mat)) {
return Double.NaN;
}
solver.invert(result);
return alg.computeDeterminant().real;
}
}
示例13: safeDeterminant
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static InversionResult safeDeterminant(DenseMatrix64F source, boolean invert) {
final int finiteCount = countFiniteNonZeroDiagonals(source);
InversionResult result;
if (finiteCount == 0) {
result = new InversionResult(NOT_OBSERVED, 0, 0);
} else {
LinearSolver<DenseMatrix64F> solver = LinearSolverFactory.pseudoInverse(true);
solver.setA(source);
SingularValueDecomposition<DenseMatrix64F> svd = solver.getDecomposition();
double[] values = svd.getSingularValues();
if (values == null) {
throw new RuntimeException("Unable to perform SVD");
}
int dim = 0;
double det = 1;
for (int i = 0; i < values.length; ++i) {
final double lambda = values[i];
if (lambda != 0.0) {
det *= lambda;
++dim;
}
}
if (invert) {
det = 1.0 / det;
}
result = new InversionResult(dim == source.getNumCols() ? FULLY_OBSERVED : PARTIALLY_OBSERVED, dim, det);
}
return result;
}
示例14: safeSolve
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static InversionResult safeSolve(DenseMatrix64F A, DenseMatrix64F B, DenseMatrix64F X, boolean getDeterminant) {
final int finiteCount = countFiniteNonZeroDiagonals(A);
InversionResult result;
if (finiteCount == 0) {
Arrays.fill(X.getData(), 0);
result = new InversionResult(NOT_OBSERVED, 0, 0);
} else {
LinearSolver<DenseMatrix64F> solver = LinearSolverFactory.pseudoInverse(true);
solver.setA(A);
solver.solve(B, X);
int dim = 0;
double det = 1;
if (getDeterminant) {
SingularValueDecomposition<DenseMatrix64F> svd = solver.getDecomposition();
double[] values = svd.getSingularValues();
for (int i = 0; i < values.length; ++i) {
final double lambda = values[i];
if (lambda != 0.0) {
det *= lambda;
++dim;
}
}
}
result = new InversionResult(dim == A.getNumCols() ? FULLY_OBSERVED : PARTIALLY_OBSERVED, dim, 1 / det);
}
return result;
}
示例15: safeInvert
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static InversionResult safeInvert(DenseMatrix64F source, DenseMatrix64F destination, boolean getDeterminant) {
final int dim = source.getNumCols();
final int finiteCount = countFiniteNonZeroDiagonals(source);
double det = 0;
if (finiteCount == dim) {
if (getDeterminant) {
det = invertAndGetDeterminant(source, destination);
} else {
CommonOps.invert(source, destination);
}
return new InversionResult(FULLY_OBSERVED, dim, det);
} else {
if (finiteCount == 0) {
Arrays.fill(destination.getData(), 0);
return new InversionResult(NOT_OBSERVED, 0, 0);
} else {
final int[] finiteIndices = new int[finiteCount];
getFiniteNonZeroDiagonalIndices(source, finiteIndices);
final DenseMatrix64F subSource = new DenseMatrix64F(finiteCount, finiteCount);
gatherRowsAndColumns(source, subSource, finiteIndices, finiteIndices);
final DenseMatrix64F inverseSubSource = new DenseMatrix64F(finiteCount, finiteCount);
if (getDeterminant) {
det = invertAndGetDeterminant(subSource, inverseSubSource);
} else {
CommonOps.invert(subSource, inverseSubSource);
}
scatterRowsAndColumns(inverseSubSource, destination, finiteIndices, finiteIndices, true);
return new InversionResult(PARTIALLY_OBSERVED, finiteCount, det);
}
}
}