H*****8 发帖数: 222 | 1 在matlab poly.m 文件中,assume x is a vector. the code is:
function c = poly(x)
....
n = length(x);
c = [1 zeros(1,n)];
e=x;
for j=1:n
c(2:(j+1)) = c(2:(j+1)) - e(j).*c(1:j);
end
..
呵呵。 | H*****8 发帖数: 222 | 2 Seems no one interested. What I did is following:
// The class Vector is done before.
// Vector.addVector(double a, Vector b, double c) will return a*self+c*b
Vector * UnivariateDecomposition::Poly(Vector *x)
{
/* first step translate matlab into another format.
for j=1:n
for k=2:j+1
c(k) = c1(k) - e(j)*c1(k-1);
end
c1 = c;
end
*/
//then translate into c. tmp is class wide member.
int n = x->Size();
if (tmp ==0) {
tmp = new Vector(n+1);
}
【在 H*****8 的大作中提到】 : 在matlab poly.m 文件中,assume x is a vector. the code is: : function c = poly(x) : .... : n = length(x); : c = [1 zeros(1,n)]; : e=x; : for j=1:n : c(2:(j+1)) = c(2:(j+1)) - e(j).*c(1:j); : end : ..
|
|