本文整理了Java中Jama.Matrix.getMatrix()
方法的一些代码示例,展示了Matrix.getMatrix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.getMatrix()
方法的具体详情如下:
包路径:Jama.Matrix
类名称:Matrix
方法名:getMatrix
暂无
代码示例来源: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 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
throw new RuntimeException("Problem reading file, rowIni < rowend" + rowIni + " < " + rowEnd);
Matrix indVar = data.getMatrix(rowIni, rowEnd, indVariable, indVariable); // dataVowels(:,0) -> last col is the
data = data.getMatrix(rowIni, rowEnd, c); // the dependent variables correspond to the column indices in c
multipleLinearRegression(indVar, data, interceptTerm);
} catch (Exception e) {
代码示例来源:origin: marytts/marytts
throw new RuntimeException("Problem reading file, rowIni < rowend" + rowIni + " < " + rowEnd);
Matrix indVar = data.getMatrix(rowIni, rowEnd, indVariable, indVariable); // dataVowels(:,0) -> last col is the
data = data.getMatrix(rowIni, rowEnd, c); // the dependent variables correspond to the column indices in c
multipleLinearRegression(indVar, data, interceptTerm);
} catch (Exception e) {
代码示例来源: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
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
/***
* PCA
*
* @param fileName
* data one column per dimension or linguistic factor
* @param eigen
* if true use eigenvalues, if false use svd (recomended)
* @param scale
* if true use z-normalisation (recomended), if false substract off the mean for ecah dimension
*/
public void principalComponentAnalysis(String fileName, boolean eigen, boolean scale) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
if (eigen)
eigenPCA(data.transpose(), scale, false);
else
svdPCA(data.transpose(), scale, false);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
/***
* PCA
*
* @param fileName
* data one column per dimension or linguistic factor
* @param eigen
* if true use eigenvalues, if false use svd (recomended)
* @param scale
* if true use z-normalisation (recomended), if false substract off the mean for ecah dimension
*/
public void principalComponentAnalysis(String fileName, boolean eigen, boolean scale) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Matrix data = Matrix.read(reader);
int rows = data.getRowDimension() - 1;
int cols = data.getColumnDimension() - 1;
data = data.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
if (eigen)
eigenPCA(data.transpose(), scale, false);
else
svdPCA(data.transpose(), scale, false);
} catch (Exception e) {
throw new RuntimeException("Problem reading file " + fileName, e);
}
}
代码示例来源:origin: marytts/marytts
int cols = dataVowels.getColumnDimension() - 1;
Matrix indVar = dataVowels.getMatrix(0, rows, 0, 0); // dataVowels(:,0) -> col 0 is the independent variable
dataVowels = dataVowels.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
代码示例来源:origin: marytts/marytts
int cols = dataVowels.getColumnDimension() - 1;
Matrix indVar = dataVowels.getMatrix(0, rows, 0, 0); // dataVowels(:,0) -> col 0 is the independent variable
dataVowels = dataVowels.getMatrix(0, rows, 1, cols); // dataVowels(:,1:cols) -> dependent variables
代码示例来源:origin: marytts/marytts
throw new RuntimeException("Problem reading file, rowIni < rowend" + rowIni + " < " + rowEnd);
Matrix indVar = data.getMatrix(rowIni, rowEnd, indVariable, indVariable); // dataVowels(:,0) -> last col is the
data = data.getMatrix(rowIni, rowEnd, c); // the dependent variables correspond to the column indices in c
代码示例来源:origin: marytts/marytts
throw new RuntimeException("Problem reading file, rowIni < rowend" + rowIni + " < " + rowEnd);
Matrix indVar = data.getMatrix(rowIni, rowEnd, indVariable, indVariable); // dataVowels(:,0) -> last col is the
data = data.getMatrix(rowIni, rowEnd, c); // the dependent variables correspond to the column indices in c
代码示例来源:origin: h2oai/h2o-3
public Frame makeUVec(SVDModel model, String u_name, Frame u, Frame qfrm, Matrix atqJ, SingularValueDecomposition svdJ ) {
model._output._u_key = Key.make(u_name);
double[][] svdJ_u = svdJ.getV().getMatrix(0, atqJ.getColumnDimension() - 1, 0,
_parms._nv - 1).getArray();
DataInfo qinfo = new DataInfo(qfrm, null, true, DataInfo.TransformType.NONE,
false, false, false);
DKV.put(qinfo._key, qinfo);
BMulTask btsk = new BMulTask(_job._key, qinfo, ArrayUtils.transpose(svdJ_u));
btsk.doAll(_parms._nv, Vec.T_NUM, qinfo._adaptedFrame);
qinfo.remove();
return btsk.outputFrame(model._output._u_key, null, null);
// DKV.remove(qinfo._key);
}
@Override
代码示例来源:origin: h2oai/h2o-3
model._output._v = svdJ.getU().getMatrix(0, atqJ.getRowDimension() - 1, 0, _parms._nv - 1).getArray();
代码示例来源:origin: openimaj/openimaj
/**
* Select a subset of the principal components. Calling this method throws
* away any extra basis vectors and eigenvalues.
*
* @param n
*/
public void selectSubset(int n) {
if (n >= eigenvalues.length)
return;
basis = basis.getMatrix(0, basis.getRowDimension() - 1, 0, n - 1);
eigenvalues = Arrays.copyOf(eigenvalues, n);
}
代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit
public static Matrix getRowNumber(int i, Matrix m)
{
Matrix ret = m.getMatrix(i, i, 0, m.getColumnDimension() - 1);
return ret;
}
代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit
public static Matrix getRowNumber(int i, Matrix m)
{
Matrix ret = m.getMatrix(i, i, 0, m.getColumnDimension() - 1);
return ret;
}
代码示例来源:origin: stackoverflow.com
Matrix matrix;
matrix = new Matrix();
matrix.set(3, 5, "You");
matrix.set(0, 0, "Hi");
for (ArrayList<String> list : matrix.getMatrix()) {
for (String value : list) {
System.out.print(value + "\t");
}
System.out.println();
}
代码示例来源:origin: cmu-phil/tetrad
private static Matrix sumColumns(Matrix a){
Matrix sum = new Matrix(1,a.getColumnDimension());
for(int i=0; i<a.getRowDimension(); i++)
sum.plusEquals(a.getMatrix(i,i,0,a.getColumnDimension()-1));
return sum;
}
代码示例来源:origin: cmu-phil/tetrad
/**
* Sums across the rows of the <code>Matrix</code> and return the result as a single column <code>MAtrix</code>
* @param A input <code>Matrix</code>
* @return result
*/
public static Matrix sumRows(Matrix A){
Matrix sum = new Matrix(A.getRowDimension(),1);
for(int i=0; i<A.getColumnDimension(); i++)
sum.plusEquals(A.getMatrix(0,A.getRowDimension()-1,i,i));
return sum;
}
内容来源于网络,如有侵权,请联系作者删除!