I've been using Sage for 3 weeks so please bear with me if this is an ignorant question.
There are lots of great tools for studying properties of quaternion algebras http://doc.sagemath.org/html/en/reference/quat_algebras/sage/algebras/quatalg/quaternion_algebra.html and also for doing computations in these algebras http://doc.sagemath.org/html/en/reference/quat_algebras/sage/algebras/quatalg/quaternion_algebra_element.html
But I am interested in working with functions that move between quaternion algebras and other spaces. For instance let's say I write
K.<d> = NumberField(x^2 + 1)
A.<i,j,k> = QuaternionAlgebra(K,-1,-1)
And let's say I want a function $$f:A\rightarrow M_2(K), w+xi+yj+zij\mapsto (w,x,y,z)$$. How can define this function in such a way that I can enter something like
f(2*i+i*j)
and get as output
(0,2,0,1)
?
This particular function is not very useful or interesting, I'm just using this to keep it simple. I'd also be interested in defining functions that go from one quaternion algebra to another, or from a quaternion algebra to a matrix ring, in such a way that I can compose these things.
I feel there is probably a general principle addressing things like this but I'm not finding it.