Ejemplo n.º 1
0
complex operator* (const complex& c1, const complex& c2)
{
    double res_re = c1.get_re()*c2.get_re() - c1.get_im()*c2.get_im();
    double res_im = c1.get_im()*c2.get_re() + c1.get_re()*c2.get_im();
    complex res{res_re, res_im};

    return res;
}
Ejemplo n.º 2
0
complex operator/ (const complex& c1, const complex& c2)
{
        double abs2c2 = c2.abs2();
        double res_re = (c1.get_re()*c2.get_re() + c1.get_im()*c2.get_im())/abs2c2;
        double res_im = (c1.get_im()*c2.get_re() - c1.get_re()*c2.get_im())/abs2c2;
        complex res{res_re, res_im};

        return res;
}
Ejemplo n.º 3
0
complex operator- (const complex& c1)
{
    complex res{-c1.get_re(), -c1.get_im()};
    return res;
}