How can I define a function with quaternion argument, and other non-vector input
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/refer... and also for doing computations in these algebras http://doc.sagemath.org/html/en/refer...
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
and get as output
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. It seems functions are generally expected to have vector input, but there is not always a straightforward way of turning elements of a domain into vectors (there is for matrices, but even this is tedious).
I feel there is probably a general principle addressing things like this but I'm not finding it.