[英]Sparse Matrix Decomposition in ojalgo
我想用 ojalgo 做最小二乘調整。 問題是我的 Designmatrix 非常大(超過 100kx100k)但非常稀疏。 用 ojalgo 建立巨大的稀疏矩陣是沒有問題的。 還要做一些基本的數學運算。 當我從 SparseStore 矩陣創建 QR 對象時,似乎忽略了 SparseStore 矩陣信息,並且 qr 對象被初始化為 2D-DenseMatrix 對象。 當然比我的系統內存不足。
是否有可能執行 qr(或其他)操作來保持 SparseStore。
謝謝你的幫助,
最好的,羅尼
源代碼:
package matrixTest;
import static org.ojalgo.type.CalendarDateUnit.*;
import java.util.Random;
import org.ojalgo.OjAlgoUtils;
import org.ojalgo.array.LongToNumberMap;
import org.ojalgo.array.Primitive64Array;
import org.ojalgo.array.SparseArray;
import org.ojalgo.matrix.decomposition.QR;
import org.ojalgo.matrix.store.MatrixStore;
import org.ojalgo.matrix.store.SparseStore;
import org.ojalgo.matrix.task.iterative.ConjugateGradientSolver;
import org.ojalgo.netio.BasicLogger;
import org.ojalgo.series.BasicSeries;
import org.ojalgo.type.Stopwatch;
/**
* Example use of SparseStore and other special MatrixStore implementations.
*
* @see https://www.ojalgo.org/2020/09/sparse-and-special-structure-matrices/
* @see https://github.com/optimatika/ojAlgo/wiki/Sparse-Matrices
*/
public class SparseMatrices {
private static String NON_ZEROS = "{} non-zeroes out of {} matrix elements calculated in {}";
private static Random RANDOM = new Random();
public static void main(final String[] args) {
BasicLogger.debug();
BasicLogger.debug(SparseMatrices.class);
BasicLogger.debug(OjAlgoUtils.getTitle());
BasicLogger.debug(OjAlgoUtils.getDate());
BasicLogger.debug();
int dim = 100_000;
SparseStore<Double> mtrxD = SparseStore.PRIMITIVE64.make(dim, dim);
for (int j = 0; j < dim; j++) {
double val = RANDOM.nextDouble();
mtrxD.set(j, j, val);
} // Each column of B contains 1 non-zero element at random row
QR<Double> decompQR = QR.PRIMITIVE.make(mtrxD);
stopwatch.reset();
decompQR.compute(mtrxD);
BasicLogger.debug("Sparse Identity decomposed (QR) in {}", stopwatch.stop());
}
}
目前沒有保留稀疏性的矩陣分解。
不確定您需要什么或 ojAlgo 中的確切內容。 您可以乘以轉置矩陣,然后使用迭代求解器嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.