You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FiniteRankFreeModule: Move all module identifications to methods exterior_power, dual_exterior_power, tensor_module #30255
Currently, the identification of a base module M with M.tensor_module(1, 0) and M.exterior_power(1) is implemented in FiniteRankFreeModule.__init__ but the identification of M.base_ring() with M.exterior_power(0) is implemented in exterior_power.
In this ticket, we move all identifications to the methods tensor_module, exterior_power, dual_exterior_power.
We also rewrite these methods in try/except style.
Merge branch 't/30254/tensorfreemodule__an_element___create_a_default_basis_in_the_base_module_if_necessary' into t/30255/finiterankfreemodule__move_all_module_identifications_to_methods_exterior_power__dual_exterior_power__tensor_module
Merge branch 't/30250/finiterankfreemodule__simplify_unique_representation_code_for_dependent_modules' into t/30255/finiterankfreemodule__move_all_module_identifications_to_methods_exterior_power__dual_exterior_power__tensor_module
The code duplication between these three methods of FiniteRankFreeModule and VectorFieldFreeModule could of course be removed by using class attributes _exterior_power_class, _exterior_dual_power_class, _tensor_module_class. I can do that on a follow-up ticket if you like.
sage: sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: sage: M.exterior_power(2)
2nd exterior power of the Rank-3 free module M over the Integer Ring
sage: %timeit M.exterior_power(2)
The slowest run took 9.54 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 5: 2.23 µs per loop
after:
sage: sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: sage: M.exterior_power(2)
2nd exterior power of the Rank-3 free module M over the Integer Ring
sage: %timeit M.exterior_power(2)
The slowest run took 13.09 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 5: 929 ns per loop
The slow path is 2 orders of magnitude slower than the fast path because a heavy weight object is created:
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: %time M.exterior_power(1)
CPU times: user 729 µs, sys: 692 µs, total: 1.42 ms
Wall time: 891 µs
Rank-3 free module M over the Integer Ring
sage: %time M.exterior_power(2)
CPU times: user 685 µs, sys: 18 µs, total: 703 µs
Wall time: 707 µs
2nd exterior power of the Rank-3 free module M over the Integer Ring
sage: %time M.exterior_power(3)
CPU times: user 239 µs, sys: 11 µs, total: 250 µs
Wall time: 254 µs
3rd exterior power of the Rank-3 free module M over the Integer Ring
sage: %time M.exterior_power(4)
CPU times: user 229 µs, sys: 0 ns, total: 229 µs
Wall time: 233 µs
4th exterior power of the Rank-3 free module M over the Integer Ring
sage: %time M.exterior_power(5)
CPU times: user 269 µs, sys: 14 µs, total: 283 µs
Wall time: 303 µs
5th exterior power of the Rank-3 free module M over the Integer Ring
sage: %time M.exterior_power(0)
CPU times: user 15 µs, sys: 1 µs, total: 16 µs
Wall time: 16.7 µs
Integer Ring
So whatever the changes to this method do does not matter for the slow path.
Activity
mkoeppe commentedon Jul 30, 2020
Dependencies: #30254
mkoeppe commentedon Jul 30, 2020
Branch: u/mkoeppe/finiterankfreemodule__move_all_module_identifications_to_methods_exterior_power__dual_exterior_power__tensor_module
mkoeppe commentedon Jul 30, 2020
New commits:
1bd50f8FiniteRankFreeModule: Move all module identifications to methods exterior_power, dual_exterior_power, tensor_module; Rewrite in try/except styled64c8edExtPowerFreeModule._an_element_: Make sure a default basis is availabled2d7f42ExtPowerDualFreeModule._an_element_: Make sure a default basis is available9e739e5FreeModuleLinearGroup._an_element_: Make sure a default basis is availableeec19fdTensorFreeModule._an_element_: Make sure a default basis is available1378d06Merge branch 't/30254/tensorfreemodule__an_element___create_a_default_basis_in_the_base_module_if_necessary' into t/30255/finiterankfreemodule__move_all_module_identifications_to_methods_exterior_power__dual_exterior_power__tensor_module5a340d9TensorFreeModule.__init__: Remove duplicate registration of self in the base module, uniqueness checkde35db3FreeModuleBasis.__init__: Update all modules in the set fmodule._all_modules2ac26d7Merge branch 't/30250/finiterankfreemodule__simplify_unique_representation_code_for_dependent_modules' into t/30255/finiterankfreemodule__move_all_module_identifications_to_methods_exterior_power__dual_exterior_power__tensor_modulemkoeppe commentedon Jul 30, 2020
Author: Matthias Koeppe
mkoeppe commentedon Jul 30, 2020
Commit:
2ac26d7mkoeppe commentedon Jul 30, 2020
Changed dependencies from #30254 to #30250, #30254
mkoeppe commentedon Jul 30, 2020
Ha! This one did not pass the
sage.manifoldsdoctests. Hold on...sagetrac-git commentedon Jul 30, 2020
Branch pushed to git repo; I updated commit sha1. New commits:
a6961c6VectorFieldFreeModule: Update methods exterior_power, dual_exterior_power, tensor_module for changed FiniteRankFreeModule.__init__sagetrac-git commentedon Jul 30, 2020
Changed commit from
2ac26d7toa6961c6mkoeppe commentedon Jul 30, 2020
The code duplication between these three methods of
FiniteRankFreeModuleandVectorFieldFreeModulecould of course be removed by using class attributes_exterior_power_class,_exterior_dual_power_class,_tensor_module_class. I can do that on a follow-up ticket if you like.egourgoulhon commentedon Jul 30, 2020
Thanks for this cleaning.
What is the advantage of
over
?
The latter looks easier to read.
mkoeppe commentedon Jul 30, 2020
It's more than twice as fast in the fast path.
before:
after:
tscrim commentedon Jul 30, 2020
How does it compare in the slow path?
mkoeppe commentedon Jul 31, 2020
The slow path is 2 orders of magnitude slower than the fast path because a heavy weight object is created:
So whatever the changes to this method do does not matter for the slow path.
egourgoulhon commentedon Jul 31, 2020
Replying to @mkoeppe:
Thanks for the explanation.
3 remaining items
mjungmath commentedon Aug 6, 2020
Reviewer: Michael Jung
mjungmath commentedon Aug 6, 2020
Sorry. I'll give positive review when the line is removed.
sagetrac-git commentedon Aug 6, 2020
Changed commit from
a6961c6toc035d06sagetrac-git commentedon Aug 6, 2020
Branch pushed to git repo; I updated commit sha1. New commits:
c035d06Remove unused import in doctestmjungmath commentedon Aug 6, 2020
LGTM. Patchbot is now full green, too.
mkoeppe commentedon Aug 6, 2020
Thanks!
vbraun commentedon Aug 9, 2020
Changed branch from u/mkoeppe/finiterankfreemodule__move_all_module_identifications_to_methods_exterior_power__dual_exterior_power__tensor_module to
c035d06