Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions for debugging a version-dependent DimensionMismatch("") #189

Closed
ezaron opened this issue Jul 30, 2022 · 3 comments
Closed

Suggestions for debugging a version-dependent DimensionMismatch("") #189

ezaron opened this issue Jul 30, 2022 · 3 comments

Comments

@ezaron
Copy link

ezaron commented Jul 30, 2022

Greetings LinearMaps.jl Enthusiasts:

I have a piece of code which uses LinearMaps v3.3.0 inside Julia version 1.6.1. This version of the code works without error.

When I run this identical code on another machine using LinearMaps v3.8.0 inside Julia version 1.7.2, I receive an error:

ERROR: LoadError: DimensionMismatch("")
Stacktrace:
 [1] *(A::LinearMaps.FunctionMap{Float64, var"#Fb1t#277"{Dict{Symbol, Any}, Vector{Any}}, Nothing}, x::Vector{Float64})
   @ LinearMaps ~/.julia/packages/LinearMaps/BT89E/src/functionmap.jl:46

The line in question in functionmap.jl is doing a very simple check of dimensions of the linear operator compared to the input vector. My caller is just attempting to compute A*x. The operator A is based a simple function call that operates on a vector of Float64; it is instantiated with a simple call, e.g., Gb1t = LinearMap(Fb1t,length(D1[:id1])), where Fb1t is the function.

This use case is so simple, I wonder if there was some fundamental change to LinearMaps from v3.3.0 to v.3.8.0. Maybe you have seen something like this before?

Using Infiltrator I have been able to verify that the sizes of the A and x objects are correct before the call to A*x in both the working and non-working cases. I have not studied the functionmap.jl code extensively, but I wonder if some kind of type aliasing may occur prior to the test at line 46 which somehow alters the apparent dimensions, or something like that.

-Ed

@ezaron
Copy link
Author

ezaron commented Jul 30, 2022

Aha -- In the new version of the LinearMaps.jl package, it is necessary to instantiate the linear map with both dimensions of the operator, e.g.,
Gb1t = LinearMap(Fb1t,M,N)
for the non-square case.

@ezaron ezaron closed this as completed Jul 30, 2022
@dkarrasch
Copy link
Member

Strange. I think it always used to be like that. So, Fb1t is a Matrix? I see usage of length, where perhaps size would be more appropriate?

@ezaron
Copy link
Author

ezaron commented Jul 30, 2022

-thx, Daniel. For some reason the old code worked when I merely specified the size of the input vector. The new code works if I explicitly pass the sizes of the domain and range when I instantiate the LinearMap. Fb1t is a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants