Skip to content

missing method AD'ing through a QR decomposition #286

@tpapp

Description

@tpapp

Could not reduce this to a MWE yet, but I get this error message when using ForwardDiff.jacobian on a problem that uses the QR decomposition for least squares.

ERROR: MethodError: no method matching A_ldiv_B!(::Base.LinAlg.QRCompactWY{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2}}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2})
Closest candidates are:
  A_ldiv_B!(::Base.LinAlg.QR{T,S} where S<:(AbstractArray{T,2} where T), ::Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}) where T at linalg/qr.jl:730
  A_ldiv_B!(::Base.LinAlg.QRPivoted, ::Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray} where T) at linalg/qr.jl:782
  A_ldiv_B!(::Base.LinAlg.LQ{T,S} where S<:(AbstractArray{T,2} where T), ::Union{Union{Base.ReshapedArray{T,1,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,1}, SubArray{T,1,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}, Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}}) where T at linalg/lq.jl:234
  ...
Stacktrace:
 [1] \(::Base.LinAlg.QRCompactWY{Float64,Array{Float64,2}}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2}) at ./linalg/qr.jl:819

Importantly, in the X \ Y the Y is a matrix, not a vector (multiple independent variables).

Using Julia v0.6.1, tried both ForwardDiff master and 0.7.0. A workaround would also help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions