- rename example modules from "example" to "swigexample", to avoid a warning from shadowing the Octave built-in function "example" - remove deprecated "static" Makefile targets: there is no longer an option to build static Octave modules in the Examples Makefile - emacs whitespace cleanup run on all files
35 lines
974 B
C++
35 lines
974 B
C++
/* File : example.h */
|
|
#include <math.h>
|
|
|
|
class ComplexVal {
|
|
private:
|
|
double rpart, ipart;
|
|
public:
|
|
ComplexVal(double r = 0, double i = 0) : rpart(r), ipart(i) { }
|
|
ComplexVal(const ComplexVal &c) : rpart(c.rpart), ipart(c.ipart) { }
|
|
ComplexVal &operator=(const ComplexVal &c) {
|
|
rpart = c.rpart;
|
|
ipart = c.ipart;
|
|
return *this;
|
|
}
|
|
ComplexVal operator+(const ComplexVal &c) const {
|
|
return ComplexVal(rpart+c.rpart, ipart+c.ipart);
|
|
}
|
|
ComplexVal operator-(const ComplexVal &c) const {
|
|
return ComplexVal(rpart-c.rpart, ipart-c.ipart);
|
|
}
|
|
ComplexVal operator*(const ComplexVal &c) const {
|
|
return ComplexVal(rpart*c.rpart - ipart*c.ipart,
|
|
rpart*c.ipart + c.rpart*ipart);
|
|
}
|
|
ComplexVal operator-() const {
|
|
return ComplexVal(-rpart, -ipart);
|
|
}
|
|
|
|
double re() const { return rpart; }
|
|
double im() const { return ipart; }
|
|
};
|
|
|
|
ComplexVal operator*(const double &s, const ComplexVal &c) {
|
|
return ComplexVal(s*c.re(), s*c.im());
|
|
}
|