Initial commit of Octave module.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10290 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
50b1578e19
commit
393391965c
275 changed files with 14004 additions and 5 deletions
36
Examples/octave/operator/example.h
Normal file
36
Examples/octave/operator/example.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* 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; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue