Skip to content

Commit 8bf6d19

Browse files
authored
Backport: TensorSpace in ProductFun constructor (#543)
* Backport: TensorSpace in ProductFun constructor * Revert ProductFun space promotion * multiply KroneckerOperator with Fun
1 parent c14fef4 commit 8bf6d19

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/LinearAlgebra/lyap.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ end
1010
# where P,R,S and T are upper triangular
1111
function lyapuptriang(P,R,S,T,F::AbstractArray{N}) where N
1212
m=size(P,2); n = size(T,2)
13-
Y=Matrix{N}(m,n)
14-
PY = Matrix{N}(m,n); SY = Matrix{N}(m,n)
13+
Y=Matrix{N}(undef,m,n)
14+
PY = Matrix{N}(undef,m,n)
15+
SY = Matrix{N}(undef,m,n)
1516

1617
k=n
1718
while k > 1
@@ -24,7 +25,8 @@ function lyapuptriang(P,R,S,T,F::AbstractArray{N}) where N
2425
end
2526

2627
Y[:,k] = (R[k,k]*P + T[k,k]*S)\rhs
27-
PY[:,k] = P*Y[:,k];SY[:,k] = S*Y[:,k]
28+
PY[:,k] = P*Y[:,k]
29+
SY[:,k] = S*Y[:,k]
2830

2931
k -= 1
3032
else
@@ -34,7 +36,7 @@ function lyapuptriang(P,R,S,T,F::AbstractArray{N}) where N
3436
rhs2[l] -= R[k,j]*PY[l,j] + T[k,j]*SY[l,j]
3537
end
3638

37-
SM = Matrix{N}(2m,2m)
39+
SM = Matrix{N}(undef,2m,2m)
3840

3941
for i=1:m,j=1:m
4042
SM[i,j] = R[k-1,k-1]*P[i,j] + T[k-1,k-1]*S[i,j]

src/Multivariate/VectorFun.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ norm(A::VectorFun, p::Real) = norm(norm.(Array(A)),p)
147147

148148
function coefficientmatrix(::Type{N},f::AbstractVector{F},o...) where {N,F}
149149
if isempty(f)
150-
return Matrix{N}(0,0)
150+
return Matrix{N}(undef,0,0)
151151
end
152152

153153
n=mapreduce(ncoefficients,max,f)

src/PDE/KroneckerOperator.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,16 @@ end
452452
function (*)(ko::KroneckerOperator{<:Operator, <:ConstantOperator}, pf::ProductFun)
453453
O1, O2 = ko.ops
454454
O12 = O2.λ * O1
455-
ProductFun(map(x -> O12*x, pf.coefficients), factor(pf.space, 2))
455+
vc = map(x -> O12*x, pf.coefficients)
456+
if space(pf) isa TensorSpace
457+
ProductFun(vc, space(vc[1]), factor(pf.space, 2))
458+
else
459+
ProductFun(vc, factor(pf.space, 2))
460+
end
461+
end
462+
function (*)(ko::KroneckerOperator{<:Operator, <:ConstantOperator}, f::Fun{<:TensorSpace})
463+
q = ko * ProductFun(f)
464+
Fun(q)
456465
end
457466

458467
function (*)(ko::KroneckerOperator, lrf::LowRankFun)

0 commit comments

Comments
 (0)