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

handle uniform scalings in compositions of maps explicitly #69

Closed
wants to merge 1 commit into from

Conversation

dkarrasch
Copy link
Member

This is probably an incredibly dirty hack, but it does all the things we were considering in the context of #57, namely:

  • it's type stable, since it doesn't touch the constructors at all, but rather handles everything within the mul! as suggested by @Jutho in make A*I return A #63;
  • it finishes earlier when one of the maps in a composition is a scaling by zero;
  • it skips uniform scalings by one, no matter in which position they occur, and also no matter of what exact type the one is, i.e., this is not restricted to Bools.

@dkarrasch dkarrasch mentioned this pull request Sep 12, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 97.716% when pulling acfb701 on identity into c435822 on master.

@codecov
Copy link

codecov bot commented Sep 12, 2019

Codecov Report

Merging #69 into master will decrease coverage by 1.7%.
The diff coverage is 72.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #69      +/-   ##
==========================================
- Coverage   98.62%   96.91%   -1.71%     
==========================================
  Files           8        8              
  Lines         435      454      +19     
==========================================
+ Hits          429      440      +11     
- Misses          6       14       +8
Impacted Files Coverage Δ
src/composition.jl 88.88% <72.41%> (-9.5%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c435822...acfb701. Read the comment docs.

@@ -108,25 +108,67 @@ function A_mul_B!(y::AbstractVector, A::CompositeMap, x::AbstractVector)
A_mul_B!(y, A.maps[1], x)
else
T = eltype(y)
dest = Array{T}(undef, size(A.maps[1], 1))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for assigning dest this way is to make sure that the eltype of dest is fixed (to that of y) such that it can hopefully be reused later on if there are more than 2 linear maps. This might fail with the new lines of code below.

@Jutho
Copy link
Collaborator

Jutho commented Sep 15, 2019

Thanks for working on this.

While the tests turn green, I think I could see cases where this fails. Also, there is still copying going on with identity linear maps, so I think a more involved change is required if we really don't want to do any extra work for uniformscalingmap with lambda = 1.

@dkarrasch dkarrasch closed this Oct 21, 2019
@dkarrasch dkarrasch deleted the identity branch June 27, 2024 07:24
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

Successfully merging this pull request may close these issues.

3 participants