>>> A = matrix([[-1, 2], [2, 1]])
>>> A_list = A.tolist()
>>> cosm(A)
matrix(
[['-0.617272876457167', '0.0'],
['0.0', '-0.617272876457167']])
>>> cosm(A_list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "*\Python312\Lib\site-packages\mpmath\matrices\calculus.py", line 170, in cosm
B = 0.5 * (ctx.expm(A*ctx.j) + ctx.expm(A*(-ctx.j)))
~^~~~~~
TypeError: can't multiply sequence by non-int of type 'mpc'
>>> sinm(A)
matrix(
[['-0.351844907875699', '0.703689815751398'],
['0.703689815751398', '0.351844907875699']])
>>> sinm(A_list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "*\Python312\Lib\site-packages\mpmath\matrices\calculus.py", line 199, in sinm
B = (-0.5j) * (ctx.expm(A*ctx.j) - ctx.expm(A*(-ctx.j)))
~^~~~~~
TypeError: can't multiply sequence by non-int of type 'mpc'
>>> expm(A)
matrix(
[['2.66340202678877', '4.136542888684'],
['4.136542888684', '6.79994491547277']])
>>> expm(A_list)
matrix(
[['2.66340202678877', '4.136542888684'],
['4.136542888684', '6.79994491547277']])
>>> logm(A)
matrix(
[[mpc(real='0.80471895621705014', imag='-2.2732777998989695'), mpc(real='-4.6883518372847911e-18', imag='1.4049629462081452')],
[mpc(real='-4.6884011070393636e-18', imag='1.4049629462081452'), mpc(real='0.80471895621705014', imag='-0.86831485369082395')]])
>>> logm(A_list)
matrix(
[[mpc(real='0.80471895621705014', imag='-2.2732777998989695'), mpc(real='-4.6883518372847911e-18', imag='1.4049629462081452')],
[mpc(real='-4.6884011070393636e-18', imag='1.4049629462081452'), mpc(real='0.80471895621705014', imag='-0.86831485369082395')]])
>>> sqrtm(A)
matrix(
[[mpc(real='0.41330423812239919', imag='-1.0820445430988213'), mpc(real='0.66874030497642201', imag='0.66874030497642201')],
[mpc(real='0.66874030497642201', imag='0.66874030497642201'), mpc(real='1.0820445430988213', imag='-0.41330423812239925')]])
>>> sqrtm(A_list)
matrix(
[[mpc(real='0.41330423812239919', imag='-1.0820445430988213'), mpc(real='0.66874030497642201', imag='0.66874030497642201')],
[mpc(real='0.66874030497642201', imag='0.66874030497642201'), mpc(real='1.0820445430988213', imag='-0.41330423812239925')]])
>>> powm(A, 2)
matrix(
[['5.0', '0.0'],
['0.0', '5.0']])
>>> powm(A_list, 2)
matrix(
[['5.0', '0.0'],
['0.0', '5.0']])
cosm()andsinm()don't accept list or int arguments.A fix is possible is by converting the argument to
matrixtype (if the argument type is notmatrixtype.)