PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/octave/operator/example.i

#
Swig | 25 lines | 17 code | 4 blank | 4 comment | 0 complexity | 395bdf3bbbd2bf729eb4e4bf784cdabf 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. /* Rename friend operator */
  8. %rename(op_scalar_mul_ComplexVal) operator*(const double&, const ComplexVal&);
  9. /* Now grab the original header file */
  10. %include "example.h"
  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. ComplexVal __paren__(int j) {
  19. return ComplexVal($self->re()*j,$self->im()*j);
  20. }
  21. };