You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using SparseMatrix (int rowCount, int columnCount, int [] columnStart, int [] rowIndicators, double [] values) causes LU decomposition to fail
error log:
Exception in thread "main" com.powsybl.math.matrix.MatrixException: klu_analyze error KLU_INVALID
at com.powsybl.math.matrix.SparseLUDecomposition.init(Native Method)
at com.powsybl.math.matrix.SparseLUDecomposition.init(SparseLUDecomposition.java:49)
at com.powsybl.math.matrix.SparseLUDecomposition.(SparseLUDecomposition.java:43)
at com.powsybl.math.matrix.SparseMatrix.decomposeLU(SparseMatrix.java:330)
at com.powsybl.math.matrix.SparseMatrixTest.main(SparseMatrixTest.java:121)
Describe the expected behavior
Expected decomposition successful
Describe the steps
SparseMatrix a =new SparseMatrix(2, 2, 2);
a.add(0, 0, 1d);
a.add(1, 0, 1d);
a.add(0, 1, 1d);
SparseMatrix m = new SparseMatrix(a.getRowCount(), a.getColumnCount(), a.getColumnStart(), a.getRowIndices(), a.getValues());
LUDecomposition decomposition = m.decomposeLU();
Problem solving:
This issue is caused by the variable "currentColumn" not being assigned during initialization
SparseMatrix(int rowCount, int columnCount, int[] columnStart, int[] rowIndices, double[] values) {
this.rowCount = rowCount;
this.columnCount = columnCount;
this.columnStart = Objects.requireNonNull(columnStart);
this.currentColumn = values.length;//Initialize here
columnValueCount = new int[columnCount];
this.rowIndices = new TIntArrayListHack(Objects.requireNonNull(rowIndices));
this.values = new TDoubleArrayListHack(Objects.requireNonNull(values));
fillColumnValueCount(this.columnCount, this.columnStart, columnValueCount, this.values);
}
}
Environment
powsybl-core 6.2.0-SNAPSHOT
Relevant Log Output
No response
Extra Information
No response
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue. I will open a PR on core repo.
Is your original need to copy an existing sparse matrix or build a sparse matrix from provided arrays ?
I initially wanted to use arrays to quickly construct a sparse matrix for testing the performance of KLU. Surprisingly, the decomposition speed of KLU is very fast. I am grateful that we have developed such a great library.
Describe the current behavior
Using SparseMatrix (int rowCount, int columnCount, int [] columnStart, int [] rowIndicators, double [] values) causes LU decomposition to fail
error log:
Exception in thread "main" com.powsybl.math.matrix.MatrixException: klu_analyze error KLU_INVALID
at com.powsybl.math.matrix.SparseLUDecomposition.init(Native Method)
at com.powsybl.math.matrix.SparseLUDecomposition.init(SparseLUDecomposition.java:49)
at com.powsybl.math.matrix.SparseLUDecomposition.(SparseLUDecomposition.java:43)
at com.powsybl.math.matrix.SparseMatrix.decomposeLU(SparseMatrix.java:330)
at com.powsybl.math.matrix.SparseMatrixTest.main(SparseMatrixTest.java:121)
Describe the expected behavior
Expected decomposition successful
Describe the steps
SparseMatrix a =new SparseMatrix(2, 2, 2);
a.add(0, 0, 1d);
a.add(1, 0, 1d);
a.add(0, 1, 1d);
SparseMatrix m = new SparseMatrix(a.getRowCount(), a.getColumnCount(), a.getColumnStart(), a.getRowIndices(), a.getValues());
LUDecomposition decomposition = m.decomposeLU();
Problem solving:
This issue is caused by the variable "currentColumn" not being assigned during initialization
}
Environment
powsybl-core 6.2.0-SNAPSHOT
Relevant Log Output
No response
Extra Information
No response
The text was updated successfully, but these errors were encountered: