在稀疏矩阵和密集向量 Julia 上使用反斜杠运算符时出错

Getting an error when using backslash operator on sparse matrix and dense vector Julia

所以,当我执行操作 A\b 时,我的 Julia 程序中有 260 x 260 稀疏矩阵定义为 A = sparse(KRow, KCol, KVal),其中 b 是 Vector{T} 类型,我收到错误:

ERROR: LoadError: MethodError: no method matching lu!(::SparseArrays.SparseMatrixCSC{Float32, UInt64}, ::Val{true}; check=true)

有人对此有任何解决方案吗?我不想将 A 转换为密集数组,而 b 是一个密集向量。

编辑:

代码是这样的:

using LinearAlgebra, SparseArrays

lhs = sparse(
    [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 7, 8, 9, 10, 11, 12, 7, 8, 9, 10, 11, 12, 9, 10, 11, 12, 13, 14, 9, 10, 11, 12, 13, 14, 11, 12, 13, 14, 15, 16, 11, 12, 13, 14, 15, 16, 13, 14, 15, 16, 17, 18, 13, 14, 15, 16, 17, 18, 15, 16, 17, 18, 19, 20, 15, 16, 17, 18, 19, 20, 17, 18, 19, 20, 21, 22, 17, 18, 19, 20, 21, 22, 19, 20, 21, 22, 23, 24, 19, 20, 21, 22, 23, 24, 21, 22, 23, 24, 25, 26, 21, 22, 23, 24, 25, 26, 23, 24, 25, 26, 27, 28, 23, 24, 25, 26, 27, 28, 25, 26, 27, 28, 29, 30, 25, 26, 27, 28, 29, 30, 27, 28, 29, 30, 31, 32, 27, 28, 29, 30, 31, 32, 29, 30, 31, 32, 33, 34, 29, 30, 31, 32, 33, 34, 31, 32, 33, 34, 35, 36, 31, 32, 33, 34, 35, 36, 33, 34, 35, 36, 37, 38, 33, 34, 35, 36, 37, 38, 35, 36, 37, 38, 39, 40, 35, 36, 37, 38, 39, 40, 37, 38, 39, 40, 41, 42, 37, 38, 39, 40, 41, 42, 39, 40, 41, 42, 43, 44, 39, 40, 41, 42, 43, 44, 41, 42, 43, 44, 45, 46, 41, 42, 43, 44, 45, 46, 43, 44, 45, 46, 47, 48, 43, 44, 45, 46, 47, 48, 45, 46, 47, 48, 49, 50, 45, 46, 47, 48, 49, 50, 47, 48, 49, 50, 51, 52, 47, 48, 49, 50, 51, 52, 49, 50, 51, 52, 53, 54, 49, 50, 51, 52, 53, 54, 51, 52, 53, 54, 55, 56, 51, 52, 53, 54, 55, 56, 53, 54, 55, 56, 57, 58, 53, 54, 55, 56, 57, 58, 55, 56, 57, 58, 59, 60, 55, 56, 57, 58, 59, 60, 57, 58, 59, 60, 61, 62, 57, 58, 59, 60, 61, 62, 59, 60, 61, 62, 63, 64, 59, 60, 61, 62, 63, 64, 61, 62, 63, 64, 65, 66, 61, 62, 63, 64, 65, 66, 63, 64, 65, 66, 67, 68, 63, 64, 65, 66, 67, 68, 65, 66, 67, 68, 69, 70, 65, 66, 67, 68, 69, 70, 67, 68, 69, 70, 71, 72, 67, 68, 69, 70, 71, 72, 69, 70, 71, 72, 73, 74, 69, 70, 71, 72, 73, 74, 71, 72, 73, 74, 75, 76, 71, 72, 73, 74, 75, 76, 73, 74, 75, 76, 77, 78, 73, 74, 75, 76, 77, 78, 75, 76, 77, 78, 79, 80, 75, 76, 77, 78, 79, 80, 77, 78, 79, 80, 81, 82, 77, 78, 79, 80, 81, 82, 79, 80, 81, 82, 83, 84, 79, 80, 81, 82, 83, 84, 81, 82, 83, 84, 85, 86, 81, 82, 83, 84, 85, 86, 83, 84, 85, 86, 87, 88, 83, 84, 85, 86, 87, 88, 85, 86, 87, 88, 89, 90, 85, 86, 87, 88, 89, 90, 87, 88, 89, 90, 91, 92, 87, 88, 89, 90, 91, 92, 89, 90, 91, 92, 93, 94, 89, 90, 91, 92, 93, 94, 91, 92, 93, 94, 95, 96, 91, 92, 93, 94, 95, 96, 93, 94, 95, 96, 97, 98, 93, 94, 95, 96, 97, 98, 95, 96, 97, 98, 99, 100, 95, 96, 97, 98, 99, 100, 97, 98, 99, 100, 101, 102, 97, 98, 99, 100, 101, 102, 99, 100, 101, 102, 103, 104, 99, 100, 101, 102, 103, 104, 101, 102, 103, 104, 105, 106, 101, 102, 103, 104, 105, 106, 103, 104, 105, 106, 107, 108, 103, 104, 105, 106, 107, 108, 105, 106, 107, 108, 109, 110, 105, 106, 107, 108, 109, 110, 107, 108, 109, 110, 111, 112, 107, 108, 109, 110, 111, 112, 109, 110, 111, 112, 113, 114, 109, 110, 111, 112, 113, 114, 111, 112, 113, 114, 115, 116, 111, 112, 113, 114, 115, 116, 113, 114, 115, 116, 117, 118, 113, 114, 115, 116, 117, 118, 115, 116, 117, 118, 119, 120, 115, 116, 117, 118, 119, 120, 117, 118, 119, 120, 121, 122, 117, 118, 119, 120, 121, 122, 119, 120, 121, 122, 123, 124, 119, 120, 121, 122, 123, 124, 121, 122, 123, 124, 125, 126, 121, 122, 123, 124, 125, 126, 123, 124, 125, 126, 127, 128, 123, 124, 125, 126, 127, 128, 125, 126, 127, 128, 125, 126, 127, 128],
    [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, 71, 71, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76, 76, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 78, 78, 79, 79, 79, 79, 79, 79, 80, 80, 80, 80, 80, 80, 81, 81, 81, 81, 81, 81, 82, 82, 82, 82, 82, 82, 83, 83, 83, 83, 83, 83, 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, 85, 85, 86, 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, 87, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92, 92, 92, 93, 93, 93, 93, 93, 93, 94, 94, 94, 94, 94, 94, 95, 95, 95, 95, 95, 95, 96, 96, 96, 96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 100, 100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 103, 104, 104, 104, 104, 104, 104, 105, 105, 105, 105, 105, 105, 106, 106, 106, 106, 106, 106, 107, 107, 107, 107, 107, 107, 108, 108, 108, 108, 108, 108, 109, 109, 109, 109, 109, 109, 110, 110, 110, 110, 110, 110, 111, 111, 111, 111, 111, 111, 112, 112, 112, 112, 112, 112, 113, 113, 113, 113, 113, 113, 114, 114, 114, 114, 114, 114, 115, 115, 115, 115, 115, 115, 116, 116, 116, 116, 116, 116, 117, 117, 117, 117, 117, 117, 118, 118, 118, 118, 118, 118, 119, 119, 119, 119, 119, 119, 120, 120, 120, 120, 120, 120, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, 123, 124, 124, 124, 124, 124, 124, 125, 125, 125, 125, 125, 125, 126, 126, 126, 126, 126, 126, 127, 127, 127, 127, 128, 128, 128, 128],
    Float32[9375.0, 625.0, -2187.5, -2812.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 9375.0, 625.0, -2187.5, -2812.5, -2812.5, -2187.5, 625.0, 9375.0, -2812.5, -2187.5, -2187.5, -2812.5, 4687.5, 312.5, -2812.5, -2187.5, 312.5, 4687.5],
    128,
    128
)

rhs = Float32[-6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -6.1035156, -3.0517578, -3.0517578]

x = lhs\rhs

这是我能找到的重现错误的最小代码示例。请将代码粘贴到 IDE 中以查看它,因为矩阵是 128 x 128。抱歉代码太长。

问题是 lu! 对于 Float32 类型的稀疏矩阵不存在。在内部,目前 Julia 在内部将 Float32 稀疏矩阵提升为 Float64 以解决系统问题。因此,如果您想使用稀疏求解器,我建议不要使用 Float32,而继续使用 Float64。

julia> typeof(lhs)
SparseMatrixCSC{Float32, Int64}

julia> lu!(lhs)
ERROR: MethodError: no method matching lu!(::SparseMatrixCSC{Float32, Int64})
Closest candidates are:
  lu!(::StridedMatrix{var"#s857"} where var"#s857"<:Union{Float32, Float64, ComplexF32, ComplexF64}; check) at ~/Desktop/Julia/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/LinearAlgebra/src/lu.jl:79

https://github.com/JuliaLang/SuiteSparse.jl/issues/54

中提交了问题