Re: [Scilab-users] {EXT} Re: Evaluating a polynomial on a square matrix

2019-09-24 Thread Dang Ngoc Chan, Christophe
Hello, > De : Federico Miyara > Envoyé : mardi 24 septembre 2019 17:09 > > Stéphane, > Thanks, this is great Indeed, my own solution proves to be poor because the conversion to a string causes a drastic truncation. A quick example with something like P = poly(0.01:0.01:1, "s") shows a great

Re: [Scilab-users] Evaluating a polynomial on a square matrix

2019-09-24 Thread Federico Miyara
Stéphane, Thanks, this is great, the use of eye is the way to go to overcome the problem of an earlier suggestion which discarded, for instance, A + 2 for not being what Horner expects; but A + 2*eye(A) is! Thanks also for making me aware of the simplified syntax 2*eye() which adapts its

Re: [Scilab-users] Evaluating a polynomial on a square matrix

2019-09-24 Thread Stéphane Mottelet
Why just not writing Horner's algorithm directly ? functionout=horner_mat(p, X)a=coeff(p)out=zeros(X);fork=degree(p):-1:0out=out*X+a(k+1)*eye()endendfunction--> a=[1 2;3 4]a = 1. 2.3. 4.--> horner_mat(1+%s-%s^2,a)ans =-5. -8. -12. -17.--> eye() + a - a^2ans =-5. -8. -12. -17.S. Le

Re: [Scilab-users] Evaluating a polynomial on a square matrix

2019-09-24 Thread Dang Ngoc Chan, Christophe
Hi, I've got some time this morning (-: so this one seems to work and should be a bit more efficient: // ** P = %s^2 + 2*%s + 3 C = coeff(P) n = size(C, "c") if n > 1 then stringP = "X1 = x; " for i = 3:n stringP = stringP+"X"+string(i-1)+" = X"+string(i-2)+"*x; "

Re: [Scilab-users] Evaluating a polynomial on a square matrix

2019-09-24 Thread Dang Ngoc Chan, Christophe
I'm aware that this is an inefficient way to compute the result but unfortunately, the Horner form of polynomial does not work on matrices: (A + 2)*A is not the same as A*A + 2*A for Scilab. It is possible to write a better function manually, by first calculating the successive powers before

Re: [Scilab-users] ?= Re: ?= =?utf-8?q? parallel_run

2019-09-24 Thread Stéphane Mottelet
Le 24/09/2019 à 09:29, Antoine Monmayrant a écrit : Le 23/09/2019 à 23:13, stephane.motte...@utc.fr a écrit : Hello Antoine, Before judging that some code is just a "dirty hack" you should first get into the code and see hows things are written. The implementation in 5.5.2 was using

Re: [Scilab-users] ?= Re: ?= =?utf-8?q? parallel_run

2019-09-24 Thread Arvid Rosén
Hi, I agree. The lack of a working solution for parallel computations is a problem on modern server type machines with many cores. We typically try to work around this by having scilab functions that generate scilab scripts that are executed by spawned headless scilab processes. Communication

Re: [Scilab-users] Evaluating a polynomial on a square matrix

2019-09-24 Thread Dang Ngoc Chan, Christophe
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.

Re: [Scilab-users] ?= Re: ?= =?utf-8?q? parallel_run

2019-09-24 Thread Antoine Monmayrant
Le 23/09/2019 à 23:13, stephane.motte...@utc.fr a écrit : Hello Antoine, Before judging that some code is just a "dirty hack" you should first get into the code and see hows things are written. The implementation in 5.5.2 was using OpenMP so I don't see anything dirty here. The

Re: [Scilab-users] ?=Re: ?=Re: ?=Re: ?==?utf-8?q?

2019-09-24 Thread Stéphane Mottelet
Hello, Le 24/09/2019 à 02:48, fujimoto2005 a écrit : Dear all, Thanks for a lot of information. If the documentation contained information on the workable version, it would be much better for users. Feel free to help making the documentation better. Scilab is free software and cannot be