File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
src/structural_transformation Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -207,11 +207,22 @@ function bareiss!(M::AbstractMatrix{T}, swap_strategy=bareiss_colswap;
207
207
return (n, pivot, column_permuted)
208
208
end
209
209
210
- function nullspace (A)
210
+ function nullspace (A; col_order = nothing )
211
211
column_pivots = collect (1 : size (A, 2 ))
212
212
B = copy (A)
213
213
(rank, d, column_permuted) = bareiss! (B; column_pivots)
214
214
reduce_echelon! (B, rank, d)
215
+
216
+ # The first rank entries in col_order are columns that give a basis
217
+ # for the column space. The remainder give the free variables.
218
+ if col_order != = nothing
219
+ resize! (col_order, size (A,2 ))
220
+ col_order .= 1 : size (A,2 )
221
+ for (i,cp) in enumerate (column_pivots)
222
+ @swap (col_order[i],col_order[cp])
223
+ end
224
+ end
225
+
215
226
N = ModelingToolkit. reduced_echelon_nullspace (rank, B)
216
227
apply_inv_pivot_rows! (N, column_pivots)
217
228
end
You can’t perform that action at this time.
0 commit comments