<commit_before>
/**
 * Complex number class
 */
export class Complex {

    static exp(a: Complex): Complex {
        let s: number = Math.exp(a.real);
        return new Complex(s * Math.cos(a.imag), s * Math.sin(a.imag));
    }

    static expi(a: number): Complex {
        return new Complex(Math.cos(a), Math.sin(a));
    }

    constructor (public real: number, public imag: number) {}

    // the complex conjugate: (a + ib) -> (a - ib)
    get conjugate(): Complex {
        return new Complex(this.real, -this.imag);
    }

    // the square function: (a + ib) -> a^2 - b^2
    public square(): number {
        return this.real * this.real - this.imag * this.imag;
    }

    // the length square: (a + ib) -> a^2 + b^2
    public norm2(): number {
        return Math.sqrt(this.real * this.real + this.imag * this.imag);
    }

    // inverse number: x -> y such that x*y == 1
    public inverse(): Complex {
        let s: number = this.norm2();
        return new Complex(this.real / s, -this.imag / s);
    }

    // complex multiplication: (a + ib) * (c + id) -> (a*c - b*d + i(a*d + b*c))
    public times(a: Complex): Complex {
        return new Complex(
            this.real * a.real - this.imag * a.imag,
            this.imag * a.real + this.real * a.imag
        );
    }

    // multiply by real number
    public times_real(a: number): Complex {
        return new Complex(this.real * a, this.imag * a);
    }

    // complex addition: (a + ib) + (c + id) -> (a+c + i(b+d))
    public plus(a: Complex): Complex {
        return new Complex(
            this.real + a.real, this.imag + a.imag
        );
    }

    // complex subtraction
    public minus(a: Complex): Complex {
        return new Complex(
            this.real - a.real, this.imag - a.imag
        );
    }
}

<commit_msg>tsdoc-strings for complex data type<commit_after>/**
 * Complex number class
 */
export class Complex {
    constructor (public real: number, public imag: number) {}

    /**
    * @returns the complex conjugate: (a + ib) -> (a - ib)
    */
    get conjugate(): Complex {
        return new Complex(this.real, -this.imag);
    }

    /**
    * @returns the square function: (a + ib) -> a^2 - b^2
    */
    public square(): number {
        return this.real * this.real - this.imag * this.imag;
    }

    /**
    * @returns the length square: (a + ib) -> a^2 + b^2
    */
    public norm2(): number {
        return Math.sqrt(this.real * this.real + this.imag * this.imag);
    }

    /**
    * @returns inverse number: x -> y such that x y == 1
    */
    public inverse(): Complex {
        let s: number = this.norm2();
        return new Complex(this.real / s, -this.imag / s);
    }

    /**
    * @param a other complex number.
    * @returns complex multiple: (a + ib) * (c + id)
    *    -> (a c - b d + i(a d + b c))
    */
    public times(a: Complex): Complex {
        return new Complex(
            this.real * a.real - this.imag * a.imag,
            this.imag * a.real + this.real * a.imag
        );
    }

    /**
    * @returns multiple by real number: (a + ib) c -> (a c + i b c)
    */
    public times_real(a: number): Complex {
        return new Complex(this.real * a, this.imag * a);
    }

    /**
    * @returns complex sum: (a + ib) + (c + id) -> (a+c + i(b+d))
    */
    public plus(a: Complex): Complex {
        return new Complex(
            this.real + a.real, this.imag + a.imag
        );
    }

    /**
    * @returns complex difference: (a + ib) - (c + id) -> (a-c + i(b-d))
    */
    public minus(a: Complex): Complex {
        return new Complex(
            this.real - a.real, this.imag - a.imag
        );
    }
}
{'fraction_non_alphanumeric': 0.1582244008714597, 'fraction_numerical': 0.003812636165577342, 'mean_word_length': 1.7825757575757575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '454242', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1193, 'n_words': 358}