Formal power series: Difference between revisions

m
→‎{{header|Perl 6}}: Make FPS a role.
m (→‎{{header|Perl 6}}: Comment edits.)
m (→‎{{header|Perl 6}}: Make FPS a role.)
Line 1,099:
class IntFPS { ... }
 
classrole FPS {
method coeffs { ... }
method differentiate { DerFPS.new(:x(self)) }
Line 1,115:
}
 
class ExplicitFPS isdoes FPS { has @.coeffs }
 
class SumFPS isdoes FPS {
has FPS ($.x, $.y);
method coeffs { $.x.coeffs Z+ $.y.coeffs }
}
 
class DifFPS isdoes FPS {
has FPS ($.x, $.y);
method coeffs { $.x.coeffs Z- $.y.coeffs }
}
 
class ProFPS isdoes FPS {
has FPS ($.x, $.y);
method coeffs { (0..*).map: { [+] ($.x.coeffs[0..$_] Z* $.y.coeffs[$_...0]) } }
}
 
class InvFPS isdoes FPS {
has FPS $.x;
method coeffs {
Line 1,145:
}
 
class DerFPS isdoes FPS {
has FPS $.x;
method coeffs { (1..*).map: { $_ * $.x.coeffs[$_] } }
}
 
class IntFPS isdoes FPS {
has FPS $.x;
method coeffs { 0, (0..*).map: { $.x.coeffs[$_] / ($_+1) } }
}
 
class DeferredFPS isdoes FPS {
has FPS $.realized is rw;
method coeffs { $.realized.coeffs }
57

edits