本文整理汇总了Java中mikera.matrixx.AMatrix.asVector方法的典型用法代码示例。如果您正苦于以下问题:Java AMatrix.asVector方法的具体用法?Java AMatrix.asVector怎么用?Java AMatrix.asVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mikera.matrixx.AMatrix
的用法示例。
在下文中一共展示了AMatrix.asVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getINDArray
import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
public static INDArray getINDArray(List<String[]> contents)
{
//will get an error if you don't have any data, so don't do that lol
int[] shape = new int[]{contents.size(), contents.get(0).length};
AMatrix readArray = Matrix.create(shape);
for(int rowIndex = 0; rowIndex < contents.size(); rowIndex++){
String[] line = contents.get(rowIndex);
for(int colIndex = 0; colIndex < line.length; colIndex++){
readArray.set(new int[]{rowIndex, colIndex}, Double.valueOf(line[colIndex]));
}
}
if(shape[1] == 1) {
AVector readVector = readArray.asVector();
return readVector;
}
else {
return readArray;
}
}
示例2: solveSquare
import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
* For a square matrix A, returns the solution to the equation A.x = b.
* Returns null if equation doesn't have a solution.
*
* @param A
* @param b
* @return
*/
private static AVector solveSquare(AMatrix A, AVector b) {
A.checkSquare();
LUSolver solver = new LUSolver();
solver.setA(A);
// create AMatrix from AVector
AMatrix B = ColumnMatrix.wrap(b);
AMatrix X = solver.solve(B);
// if no solution
if(X == null)
return null;
return X.asVector();
}
示例3: solveLeastSquares
import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
*
* Returns the least squares solution to the equation A.x = b
* Use this in the case of over-determined (more equations than unknowns) or
* under-determined (more unknowns than equations)
*
* @param A
* @param b
* @return AVector x
*/
public static AVector solveLeastSquares(AMatrix A, AVector b) {
QRHouseColSolver solver = new QRHouseColSolver();
solver.setA(A);
// create AMatrix from AVector
AMatrix B = ColumnMatrix.wrap(b);
AMatrix X = solver.solve(B);
// convert AMatrix into AVector and return
return X.asVector();
}