[Scilab-users] Evaluating a polynomial on a square matrix
Dang Ngoc Chan, Christophe
Christophe.Dang at sidel.com
Tue Sep 24 09:31:08 CEST 2019
Hello Frederico,
> De : Federico Miyara
> Envoyé : mardi 24 septembre 2019 00:25
>
> Is there some way of evaluating a polynomial on a square matrix in a
> matrix-wise (not component-wise) fashion?
You can transform your polynomial into a usual external function Then apply it to a matrix.
e.g.
\\ **********
P = %s^2 + 2*%s + 3 \\ example of polynomial
C = coeff(P)
n = size(C, "c")
stringP = "Y = "+string(C(1))
for i = 2:n
stringP = stringP+" + "+string(C(i))+"*x^"+string(i-1) end
deff("[Y] = fctP(x)", stringP) \\ creation of the function corresponding to the polynomial
\\ test
A = [1 2 ; 3 4]
fctP(A)
\\ [12. 17. ; 24. 33.]
\\ **********
General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
More information about the users
mailing list