本文整理匯總了Java中org.apache.commons.math3.linear.RealMatrix.getSubMatrix方法的典型用法代碼示例。如果您正苦於以下問題:Java RealMatrix.getSubMatrix方法的具體用法?Java RealMatrix.getSubMatrix怎麽用?Java RealMatrix.getSubMatrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.linear.RealMatrix
的用法示例。
在下文中一共展示了RealMatrix.getSubMatrix方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: OneClassKNFST
import org.apache.commons.math3.linear.RealMatrix; //導入方法依賴的package包/類
public OneClassKNFST(final RealMatrix kernelMatrix) throws KNFSTException {
final int n = kernelMatrix.getRowDimension();
// include dot products of training samples and the origin in feature
// space (these dot products are always zero!)
final RealMatrix k = MatrixFunctions.concatVertically(
MatrixFunctions.concatHorizontally(kernelMatrix,
MatrixUtils.createRealMatrix(
kernelMatrix.getRowDimension(), 1)),
MatrixUtils.createRealMatrix(1,
kernelMatrix.getColumnDimension() + 1));
// create one-class labels + a different label for the origin
final String[] labels = new String[n + 1];
for (int l = 0; l <= n; l++) {
labels[l] = (l == n) ? "0" : "1";
}
// get model parameters
final RealMatrix projection = projection(k, labels);
final int[] indices = new int[n];
for (int i = 0; i < n; i++) {
indices[i] = i;
}
m_targetPoints =
MatrixUtils
.createRowRealMatrix(
MatrixFunctions
.columnMeans(k
.getSubMatrix(0, n - 1, 0,
k.getColumnDimension()
- 1)
.multiply(projection)).toArray());
m_projection = projection.getSubMatrix(0, n - 1, 0,
projection.getColumnDimension() - 1);
m_betweenClassDistances =
new double[] { Math.abs(m_targetPoints.getEntry(0, 0)) };
}