当前位置: 首页>>代码示例>>Java>>正文


Java AMatrix.asVector方法代码示例

本文整理汇总了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;
        }
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:20,代码来源:ReadWriteUtilities.java

示例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();
	}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:21,代码来源:Linear.java

示例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();
    }
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:20,代码来源:Linear.java


注:本文中的mikera.matrixx.AMatrix.asVector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。