PageRenderTime 34ms CodeModel.GetById 25ms app.highlight 8ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/octave/operator/example.i

#
Swig | 24 lines | 16 code | 5 blank | 3 comment | 0 complexity | 50ea2f09ac7aad81fce2aa21c5590d7b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1/* File : example.i */
 2%module example
 3#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
 4%{
 5#include "example.h"
 6%}
 7
 8/* Now grab the original header file */
 9%include "example.h"
10
11/* An output method that turns a complex into a short string */
12%extend ComplexVal {
13   char *__str() {
14       static char temp[512];
15       sprintf(temp,"(%g,%g)", $self->re(), $self->im());
16       return temp;
17   }
18
19   ComplexVal __paren(int j) {
20     return ComplexVal($self->re()*j,$self->im()*j);
21   }
22};
23
24