sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.31k stars 450 forks source link

Can not create matrices over octonions #37176

Open geometryof opened 7 months ago

geometryof commented 7 months ago

Steps To Reproduce

O=OctonionAlgebra(SR) M=MatrixSpace(O,2,2)

Expected Behavior

Matrices are defined so long as multiplication and addition make sense.

Actual Behavior

Running the above code results in the TypeError base_ring (=Octonion algebra over Symbolic Ring) must be a ring

Additional Information

This is somewhere between a bug report and a feature request. Matrix multiplication is well defined so long as addition and multiplication are defined; an associative ring is not required. So are many other operations (e.g. trace, transpose, conjugate) but not all (e.g. determinant). Having Matrix_Spaces test for an (associative) ring prevents access to those operations that are defined. Ideally, there should probably be a separate matrix class for the nonassociative case. But I'd rather have to deal with unreliable results of poorly-defined operations (e.g. determinant) than be blocked from multiplying nonassociative matrices altogether.

As a workaround, is there a reasonably simple way to disable the test in Matrix_Spaces? Perhaps by manually adding my instance of an octonion algebra to Rings? Something else?

Environment

- **OS**: (browser-based)
- **Sage Version**: sagecell.sagemath.org

Checklist

RuchitJagodara commented 7 months ago

If we are creating a new function specifically for non-associative matrices (matrices based on non-associative structures), we should not implement functions whose definitions are not properly defined. Perhaps we can ask the user how they want to define it, but I am not sure if this is possible. However, we can still create a new class with all the properties that are properly defined (e.g., trace, transpose, conjugate). So I am working on this to make a new class and if I find some method to implement functions like determinant then I will let you know.

geometryof commented 7 months ago

Thank you; I look forward to trying out the result. Determinants are not well defined over the octonions except in one special case (3x3 Hermitian matrices). But I'm quite happy to (re)define such additional functions myself, so long as I am not prevented from carrying out matrix multiplication, as at present. (The determinant in this special case can be defined in terms of traces.)