This example looks at btf
View output (PDF) | source (python)
- See also
casadi::diagcat();
casadi_int btf(std::vector< casadi_int > &rowperm, std::vector< casadi_int > &colperm, std::vector< casadi_int > &rowblock, std::vector< casadi_int > &colblock, std::vector< casadi_int > &coarse_rowblock, std::vector< casadi_int > &coarse_colblock) const
Calculate the block triangular form (BTF)
29 b1 = DM([[2,3],[4,5]])
30 b2 = DM([[6,7,8],[9,10,11],[12,13,14]])
31 A = diagcat(1,b1,b2,15)
39 p1 = numpy.random.permutation(A.size1())
40 p2 = numpy.random.permutation(A.size2())
45 print(
"randomly permuted: ")
47 nb, rowperm, colperm, rowblock, colblock, coarse_rowblock, coarse_colblock = S.sparsity().btf()
49 print(
"number of blocks: ", nb)
50 print(
"rowperm: ", rowperm)
51 print(
"colperm: ", colperm)
53 print(S[rowperm,colperm])
54 print(
"rowblock: ", rowblock)
55 print(
"colblock: ", colblock)
56 print(
"coarse_rowblock: ", coarse_rowblock)
57 print(
"coarse_colblock: ", coarse_colblock)