Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RecursiveArrayTools"
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
version = "2.4.2"
version = "2.4.3"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
8 changes: 4 additions & 4 deletions src/array_partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ function LinearAlgebra.ldiv!(A::T, bb::ArrayPartition) where T<:Union{UnitUpperT
lens = map(length, b)
@inbounds for j in n:-1:1
Ajj = T(getblock(A, lens, j, j))
xj = ldiv!(Ajj, b[j])
xj = ldiv!(Ajj, vec(b[j]))
for i in j-1:-1:1
Aij = getblock(A, lens, i, j)
# bi = -Aij * xj + bi
mul!(b[i], Aij, xj, -1, true)
mul!(vec(b[i]), Aij, xj, -1, true)
end
end
return bb
Expand All @@ -348,11 +348,11 @@ function LinearAlgebra.ldiv!(A::T, bb::ArrayPartition) where T<:Union{UnitLowerT
lens = map(length, b)
@inbounds for j in 1:n
Ajj = T(getblock(A, lens, j, j))
xj = ldiv!(Ajj, b[j])
xj = ldiv!(Ajj, vec(b[j]))
for i in j+1:n
Aij = getblock(A, lens, i, j)
# bi = -Aij * xj + b[i]
mul!(b[i], Aij, xj, -1, true)
mul!(vec(b[i]), Aij, xj, -1, true)
end
end
return bb
Expand Down
26 changes: 12 additions & 14 deletions test/upstream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ sol = solve(prob,AutoTsit5(Rosenbrock23()))

@test all(Array(sol) .== sol)

function f!(F, vars)
x = vars.x[1]
F.x[1][1] = (x[1]+3)*(x[2]^3-7)+18
F.x[1][2] = sin(x[2]*exp(x[1])-1)
y=vars.x[2]
F.x[2][1] = (y[1]+3)*(y[2]^3-7)+18
F.x[2][2] = sin(y[2]*exp(y[1])-1)
function mymodel(F, vars)
for i in 1:2
x = vars.x[i]
F.x[i][1,1] = (x[1,1]+3)*(x[1,2]^3-7)+18.0
F.x[i][1,2] = sin(x[1,2]*exp(x[1,1])-1)
F.x[i][2,1] = (x[2,1]+3)*(x[2,2]^3-7)+19.0
F.x[i][2,2] = sin(x[2,2]*exp(x[2,1])-3)
end
end

# To show that the function works
F = ArrayPartition([0.0 0.0],[0.0, 0.0])
u0= ArrayPartition([0.1; 1.2], [0.1; 1.2])
result = f!(F, u0)

# To show the NLsolve error that results with ArrayPartitions:
nlsolve(f!, ArrayPartition([0.1; 1.2], [0.1; 1.2]))
F = ArrayPartition([0.0 0.0; 0.0 0.0],[0.0 0.0; 0.0 0.0])
u0= ArrayPartition([0.1 1.2; 0.1 1.2], [0.1 1.2; 0.1 1.2])
result = mymodel(F, u0)
nlsolve(mymodel, u0)