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

Fix QuaternionAlgebra bug that caused QuaternionAlgebra( [1], 2, 5 ).1 to error the second time it was invoked #4427

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions lib/algsc.gi
Original file line number Diff line number Diff line change
Expand Up @@ -689,26 +689,9 @@ InstallAccessToGenerators( IsSCAlgebraObjCollection and IsFullSCAlgebra,
##
#V QuaternionAlgebraData
##
InstallFlushableValue( QuaternionAlgebraData, [] );
InstallFlushableValue( QuaternionAlgebraData, [ [], [] ] );
if IsHPCGAP then
ShareSpecialObj( QuaternionAlgebraData );

BindGlobal("StoreQuaternionAlgebraData", function( a, b, F, A )
local stored;
atomic readwrite QuaternionAlgebraData do
stored:= First( QuaternionAlgebraData,
t -> t[1] = a and t[2] = b and
IsIdenticalObj( t[3], FamilyObj( F ) ) );
if stored = fail then
# Store the data for the next call.
Add( QuaternionAlgebraData, MakeImmutable([ a, b, FamilyObj( F ), A ]) );
else
A:= AlgebraWithOne( F, GeneratorsOfAlgebra( stored[4] ), "basis" );
SetGeneratorsOfAlgebra( A, GeneratorsOfAlgebraWithOne( A ) );
fi;
od;
return A;
end);
fi;


Expand Down Expand Up @@ -744,16 +727,8 @@ InstallGlobalFunction( QuaternionAlgebra, function( arg )
fi;

# Generators in the right family may be already available.
atomic readonly QuaternionAlgebraData do
stored:= First( QuaternionAlgebraData,
t -> t[1] = a and t[2] = b
and IsIdenticalObj( t[3], FamilyObj( F ) ) );
od;
if stored <> fail then
A:= AlgebraWithOne( F, GeneratorsOfAlgebra( stored[4] ), "basis" );
SetGeneratorsOfAlgebra( A, GeneratorsOfAlgebraWithOne( A ) );
else

stored := GET_FROM_SORTED_CACHE( QuaternionAlgebraData, [ a, b, FamilyObj( F ) ],
function()
# Construct a filter describing element properties,
# which will be stored in the family.
filter:= IsSCAlgebraObj and IsQuaternion;
Expand All @@ -780,15 +755,12 @@ InstallGlobalFunction( QuaternionAlgebra, function( arg )
filter );
SetFilterObj( A, IsAlgebraWithOne );
#T better introduce AlgebraWithOneByStructureConstants?
return A;
end );

# Store the data for the next call.
if IsHPCGAP then
A := StoreQuaternionAlgebraData( a, b, F, A );
else
Add( QuaternionAlgebraData, [ a, b, FamilyObj( F ), A ] );
fi;

fi;
A:= AlgebraWithOne( F, GeneratorsOfAlgebra( stored ), "basis" );
Copy link
Contributor

Choose a reason for hiding this comment

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

Here a new algebra gets created; setting the filter IsFullSCAlgebra would be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch, fixed now, and commit message adjusted. I agree this is a bugfix.

SetGeneratorsOfAlgebra( A, GeneratorsOfAlgebraWithOne( A ) );
SetIsFullSCAlgebra( A, true );

# A quaternion algebra with negative parameters over a real field
# is a division ring.
Expand Down