本文整理汇总了Java中mikera.matrixx.AMatrix.asDoubleArray方法的典型用法代码示例。如果您正苦于以下问题:Java AMatrix.asDoubleArray方法的具体用法?Java AMatrix.asDoubleArray怎么用?Java AMatrix.asDoubleArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mikera.matrixx.AMatrix
的用法示例。
在下文中一共展示了AMatrix.asDoubleArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToColumnMajor
import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
* Converts the standard row-major matrix into a column-major vector
* that is advantageous for this problem.
*
* @param A original matrix that is to be decomposed.
*/
protected void convertToColumnMajor(AMatrix A) {
double[] data = A.asDoubleArray();
for( int x = 0; x < numCols; x++ ) {
double colQ[] = dataQR[x];
for( int y = 0; y < numRows; y++ ) {
colQ[y] = data[y*numCols+x];
}
}
}
示例2: improveSol
import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
* This attempts to improve upon the solution generated by account
* for numerical imprecisions. See numerical recipes for more information. It
* is assumed that solve has already been run on 'b' and 'x' at least once.
*
* @param b A matrix. Not modified.
* @param x A matrix. Modified.
*/
public void improveSol( AMatrix b , AMatrix x )
{
if( b.columnCount() != x.columnCount() ) {
throw new IllegalArgumentException("bad shapes");
}
double dataA[] = A.asDoubleArray();
double dataB[] = b.asDoubleArray();
double dataX[] = x.asDoubleArray();
final int nc = b.columnCount();
final int n = b.columnCount();
double []vv = decomp._getVV();
// AMatrix LU = decomp.getLU();
// BigDecimal sdp = new BigDecimal(0);
for( int k = 0; k < nc; k++ ) {
for( int i = 0; i < n; i++ ) {
// *NOTE* in the book this is a long double. extra precision might be required
double sdp = -dataB[ i * nc + k];
// BigDecimal sdp = new BigDecimal(-dataB[ i * nc + k]);
for( int j = 0; j < n; j++ ) {
sdp += dataA[i* n +j] * dataX[ j * nc + k];
// sdp = sdp.add( BigDecimal.valueOf(dataA[i* n +j] * dataX[ j * nc + k]));
}
vv[i] = sdp;
// vv[i] = sdp.doubleValue();
}
decomp._solveVectorInternal(vv);
for( int i = 0; i < n; i++ ) {
dataX[i*nc + k] -= vv[i];
}
}
}