comflash.h

来自「大数运算库miracl。有了miracl这样的函数库」· C头文件 代码 · 共 51 行

H
51
字号
/*
 * Quick and dirty complex data type using flash arithmetic
 * Should be extended
 */


#ifndef COMFLASH_H
#define COMFLASH_H

#include <flash.h>

class Complex
{
    Flash x,y;
public:
    Complex() {x=(Flash)0; y=(Flash)0; }
    Complex(int a) {x=(Flash)a; y=(Flash)0; }
    Complex(const Flash& a) {x=a; y=(Flash)0; }
    Complex(const Flash& a,const Flash& b) {x=a;y=b;}
    Complex(const Complex& a) {x=a.x;y=a.y;}

    Complex& operator=(const Complex &);
    Complex& operator+=(const Complex &);
    Complex& operator-=(const Complex &);
    Complex& operator*=(const Complex &);
    Complex& operator/=(const Complex &);

    BOOL iszero() const;

    friend Flash real(const Complex &);
    friend Flash imaginary(const Complex &);
    friend Complex recip(const Complex &);

    friend Complex operator-(const Complex&);

    friend BOOL operator==(const Complex&,const Complex&);
    friend BOOL operator!=(const Complex&,const Complex&);

    friend Complex operator+(const Complex &, const Complex &);
    friend Complex operator-(const Complex &, const Complex &);
    friend Complex operator*(const Complex &, const Complex &);
    friend Complex operator/(const Complex &, const Complex &);
    friend Complex exp(const Complex &);
    friend Complex pow(const Complex &,int);
    friend ostream& operator<<(ostream&,const Complex&);
    ~Complex() {}
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?