本文整理了Java中Jama.Matrix.getRowDimension()
方法的一些代码示例,展示了Matrix.getRowDimension()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.getRowDimension()
方法的具体详情如下:
包路径:Jama.Matrix
类名称:Matrix
方法名:getRowDimension
暂无
代码示例来源:origin: marytts/marytts
public void printPricipalComponents(Vector<String> factors) {
System.out.println("PCs:");
for (int j = 0; j < PC.getColumnDimension(); j++) {
System.out.println("PC(" + j + ")");
for (int i = 0; i < PC.getRowDimension(); i++)
System.out.format(" %s %.5f\n", factors.elementAt(i), PC.get(i, j));
}
}
代码示例来源:origin: marytts/marytts
public void multipleLinearRegression(String fileName, boolean interceptTerm) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
Matrix indVar = data.getMatrix(0, rows, 0, 0); // dataVowels(:,0) -> col 0 is the independent variable
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
multipleLinearRegression(indVar, data, interceptTerm);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
public double[][] getDataProjected(Matrix data, boolean debug) {
// Project the original data set
Matrix dataProjected;
dataProjected = PC.transpose().times(data);
if (debug) {
System.out.println("Data projected:");
dataProjected.print(dataProjected.getRowDimension(), 3);
}
return dataProjected.getArray();
}
代码示例来源:origin: marytts/marytts
int M = data.getRowDimension();
int N = data.getColumnDimension();
data.set(i, j, ((data.get(i, j) - mn) / sd));
} else {
data.set(i, j, (data.get(i, j) - mn));
data.print(data.getRowDimension(), 3);
V = new double[svd.getS().getRowDimension()];
for (int i = 0; i < svd.getS().getRowDimension(); i++) {
V[i] = svd.getS().get(i, i);
if (debug)
System.out.println(V[i]);
if (debug) {
System.out.println("PC:");
PC.print(PC.getRowDimension(), 3);
varianceProportion = new double[covProjectedData.getColumnDimension()];
double sumPropVar = 0.0; // sum of the proportion of variance
for (int j = 0; j < covProjectedData.getColumnDimension(); j++) {
varianceProportion[j] = covProjectedData.get(j, j);
sumPropVar += varianceProportion[j];
代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit
private void copyArray(Matrix vectorIn, double[] out) {
for (int i = 0; i < vectorIn.getRowDimension(); i++) {
out[i] = vectorIn.get(i, 0);
}
}
代码示例来源:origin: org.openimaj/FaceTracker
void initShape(Rectangle r, Matrix shape) {
assert ((shape.getRowDimension() == _rshape.getRowDimension()) && (shape
.getColumnDimension() == _rshape.getColumnDimension()));
int n = _rshape.getRowDimension() / 2;
double a = r.width * Math.cos(_simil[1]) * _simil[0] + 1;
double b = r.width * Math.sin(_simil[1]) * _simil[0];
double tx = r.x + (int) (r.width / 2) + r.width * _simil[2];
double ty = r.y + (int) (r.height / 2) + r.height * _simil[3];
double[][] s = _rshape.getArray();
double[][] d = shape.getArray();
for (int i = 0; i < n; i++) {
d[i][0] = a * s[i][0] - b * s[i + n][0] + tx;
d[i + n][0] = b * s[i][0] + a * s[i + n][0] + ty;
}
}
代码示例来源:origin: marytts/marytts
public void multipleLinearRegression(Matrix datay, Matrix dataX, boolean interceptTerm) {
b0Term = interceptTerm;
if (interceptTerm) { // first column of X is filled with 1s if b_0 != 0
int row = dataX.getRowDimension();
int col = dataX.getColumnDimension();
Matrix B = new Matrix(row, col + 1);
Matrix ones = new Matrix(row, 1);
for (int i = 0; i < row; i++)
ones.set(i, 0, 1.0);
B.setMatrix(0, row - 1, 0, 0, ones);
B.setMatrix(0, row - 1, 1, col, dataX);
multipleLinearRegression(datay, B);
} else {
multipleLinearRegression(datay, dataX);
}
}
代码示例来源:origin: marytts/marytts
private int[] checkMeanColumns(String dataFile, int Y[], String[] features) {
try {
BufferedReader reader = new BufferedReader(new FileReader(dataFile));
Matrix data = Matrix.read(reader);
reader.close();
data = data.transpose(); // then I have easy access to the columns
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
int M = data.getRowDimension();
double mn;
for (int i = 0; i < M; i++) {
mn = MathUtils.mean(data.getArray()[i]);
if (mn == 0.0) {
System.out.println("Removing feature: " + features[i] + " from list of features because it has mean=0.0");
Y = MathUtils.removeIndex(Y, i);
}
}
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + dataFile, e);
}
System.out.println();
return Y;
}
代码示例来源:origin: marytts/marytts
y = datay;
b = X.solve(y);
coeffs = new double[b.getRowDimension()];
for (int j = 0; j < b.getRowDimension(); j++) {
coeffs[j] = b.get(j, 0);
代码示例来源:origin: marytts/marytts
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
if (b.getRowDimension() == numCoeff) {
int row = data.getRowDimension();
int col = data.getColumnDimension();
代码示例来源:origin: h2oai/h2o-3
model._output._v = svdJ.getU().getMatrix(0, atqJ.getRowDimension() - 1, 0, _parms._nv - 1).getArray();
代码示例来源:origin: sc.fiji/TrakEM2_
public void fit( final double x[][], final double y[][], final double lambda )
{
final double[][] expandedX = kernelExpandMatrixNormalize( x );
final Matrix phiX = new Matrix( expandedX, expandedX.length, length );
final Matrix phiXTransp = phiX.transpose();
final Matrix phiXProduct = phiXTransp.times( phiX );
final int l = phiXProduct.getRowDimension();
final double lambda2 = 2 * lambda;
for (int i = 0; i < l; ++i )
phiXProduct.set( i, i, phiXProduct.get( i, i ) + lambda2 );
final Matrix phiXPseudoInverse = phiXProduct.inverse();
final Matrix phiXProduct2 = phiXPseudoInverse.times( phiXTransp );
final Matrix betaMatrix = phiXProduct2.times( new Matrix( y, y.length, 2 ) );
setBeta( betaMatrix.getArray() );
}
代码示例来源:origin: marytts/marytts
public void printPricipalComponents(Vector<String> factors) {
System.out.println("PCs:");
for (int j = 0; j < PC.getColumnDimension(); j++) {
System.out.println("PC(" + j + ")");
for (int i = 0; i < PC.getRowDimension(); i++)
System.out.format(" %s %.5f\n", factors.elementAt(i), PC.get(i, j));
}
}
代码示例来源:origin: marytts/marytts
int M = data.getRowDimension();
int N = data.getColumnDimension();
data.set(i, j, ((data.get(i, j) - mn) / sd));
} else {
data.set(i, j, (data.get(i, j) - mn));
data.print(data.getRowDimension(), 3);
V = new double[svd.getS().getRowDimension()];
for (int i = 0; i < svd.getS().getRowDimension(); i++) {
V[i] = svd.getS().get(i, i);
if (debug)
System.out.println(V[i]);
if (debug) {
System.out.println("PC:");
PC.print(PC.getRowDimension(), 3);
varianceProportion = new double[covProjectedData.getColumnDimension()];
double sumPropVar = 0.0; // sum of the proportion of variance
for (int j = 0; j < covProjectedData.getColumnDimension(); j++) {
varianceProportion[j] = covProjectedData.get(j, j);
sumPropVar += varianceProportion[j];
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
private void copyArray(Matrix vectorIn, double[] out) {
for (int i = 0; i < vectorIn.getRowDimension(); i++) {
out[i] = vectorIn.get(i, 0);
}
}
代码示例来源:origin: openimaj/openimaj
static void writeMat(BufferedWriter s, Matrix M) throws IOException {
final int r = M.getRowDimension();
final int c = M.getColumnDimension();
s.write(r + " " + c + " 0"); // type always 0 for java version as its
// ignored
final double[][] Mv = M.getArray();
for (int rr = 0; rr < r; rr++)
for (int cc = 0; cc < c; cc++)
s.write(Mv[rr][cc] + " ");
}
代码示例来源:origin: marytts/marytts
public void multipleLinearRegression(Matrix datay, Matrix dataX, boolean interceptTerm) {
b0Term = interceptTerm;
if (interceptTerm) { // first column of X is filled with 1s if b_0 != 0
int row = dataX.getRowDimension();
int col = dataX.getColumnDimension();
Matrix B = new Matrix(row, col + 1);
Matrix ones = new Matrix(row, 1);
for (int i = 0; i < row; i++)
ones.set(i, 0, 1.0);
B.setMatrix(0, row - 1, 0, 0, ones);
B.setMatrix(0, row - 1, 1, col, dataX);
multipleLinearRegression(datay, B);
} else {
multipleLinearRegression(datay, dataX);
}
}
代码示例来源:origin: marytts/marytts
public void multipleLinearRegression(String fileName, boolean interceptTerm) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
reader.close();
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
Matrix indVar = data.getMatrix(0, rows, 0, 0); // dataVowels(:,0) -> col 0 is the independent variable
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
multipleLinearRegression(indVar, data, interceptTerm);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
public double[][] getDataProjected(Matrix data, boolean debug) {
// Project the original data set
Matrix dataProjected;
dataProjected = PC.transpose().times(data);
if (debug) {
System.out.println("Data projected:");
dataProjected.print(dataProjected.getRowDimension(), 3);
}
return dataProjected.getArray();
}
代码示例来源:origin: marytts/marytts
private int[] checkMeanColumns(String dataFile, int Y[], String[] features) {
try {
BufferedReader reader = new BufferedReader(new FileReader(dataFile));
Matrix data = Matrix.read(reader);
reader.close();
data = data.transpose(); // then I have easy access to the columns
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
int M = data.getRowDimension();
double mn;
for (int i = 0; i < M; i++) {
mn = MathUtils.mean(data.getArray()[i]);
if (mn == 0.0) {
System.out.println("Removing feature: " + features[i] + " from list of features because it has mean=0.0");
Y = MathUtils.removeIndex(Y, i);
}
}
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + dataFile, e);
}
System.out.println();
return Y;
}
内容来源于网络,如有侵权,请联系作者删除!