class
POLYNOMIAL_COMPLEX
create
make
feature
coefficients: ARRAY [COMPLEX]
-- Arreglo que almacena los coeficientes del polinomio
make (coeffs: ARRAY [COMPLEX])
-- Constructor para crear un polinomio con coeficientes dados
do
coefficients := coeffs
end
multiply (other: POLYNOMIAL_COMPLEX): POLYNOMIAL_COMPLEX
-- Método para multiplicar dos polinomios complejos
local
result_coeffs: ARRAY [COMPLEX]
i, j: INTEGER
do
create result_coeffs.make_empty (coefficients.count + other.coefficients.count - 1)
across coefficients as c loop
across other.coefficients as oc loop
i := c.item.exponent + oc.item.exponent
j := i + 1
result_coeffs.put (coefficients[c.item.exponent] * other.coefficients[oc.item.exponent], j)
end
end
Result := POLYNOMIAL_COMPLEX.create (result_coeffs)
end
end