Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Scilab-Branch-6.1-GIT
Change language to: English - Français - Português - Русский
Scilabヘルプ >> Scilab > types > rational

rational

Scilab オブジェクト, Scilabの有理数

説明

An array R of rationals can be directly defined as the elementwise quotient of two polynomial arrays Num and Den : R = Num./Den.

The internal representation of a rational is a list of type "r": R = tlist(['r','num','den','dt'], Num, Den,[]), or R = rlist(Num, Den, []).

All usual operators can be used with arrays of rationals: ' .' + - * .* / ./ .^ .*. [,] [;],

As for polynomials, the horner() function allows to compute the value of rationals for some value of their variable.

Many other Scilab functions can be used with rationals input : permute, cat, real, imag, conj, isreal, etc. Addressing some components of an array R of rationals with their linearized indices can be done using the syntax R(k,0) where k is the vector of linearized indices, and 0 is used instead of j or higher order indices.

例

s=poly(0,'s');
W=[1/s,1/(s+1)]
W'*W
Num=[s,s+2;1,s];Den=[s*s,s;s,s*s];
rlist(Num,Den,[])
H=Num./Den
syslin('c',Num,Den)
syslin('c',H)
[Num1,Den1]=simp(Num,Den)

R = (1-%s).^[1 0 2] ./ %s.^[1 2 0]
horner(R,[-1 0 2 -2]')

R = (1-%s)/(1+%s)
horner(R, 1-%z^2)
--> R = (1-%s).^[1 0 2] ./ %s.^[1 2 0]
R  =
2
1 - s   1   1 - 2s + s
------  --  -----------
2
s     s       1

--> horner(R,[-1 0 2 -2]')
ans  =
-2.    1.     4.
Inf   Inf    1.
-0.5   0.25   1.
-1.5   0.25   9.

--> R = (1-%s)/(1+%s)
R  =
1 - s
------
1 + s

--> horner(R, 1-%z^2)
ans  =
2
z
------
2
2 - z

参照

• poly — Polynomial definition from given roots or coefficients, or characteristic to a square matrix.
• syslin — 線形システムを定義する
• horner — 多項式/有理数の評価
• simp — 有理数の簡単化

履歴

 バージョン 記述 6.0.2 The syntax R(k,0) is now available to address components with their linearized indices k.