This is even a more interesting example:
sage: f(x,y) = x+y
sage: Matrix(2, 2, f) # Matrix over CallableSymbolicExpressionRing
[(x, y) |--> x + y (x, y) |--> 0]
[(x, y) |--> 0 (x, y) |--> x + y]
Here is a proposal (assuming callable(f) is true):
if not isinstance(f, RingElement):
Tiebreaker needed:
We have a whole bunch of ways in which a matrix can be constructed. Some of
the possible signatures we support according to the documentation:
A)
matrix(n,m, )
which constructs the n x m matrix with entries f(i,j), where i,j run throw
the row and column indices.
B)
matrix