octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

binary operator '+' not implemented for 'scalar' by 'new_type' operation


From: CdeMills
Subject: binary operator '+' not implemented for 'scalar' by 'new_type' operations
Date: Sat, 13 Jul 2013 14:48:30 -0700 (PDT)

Hello,

taking inspiration from examples/make_int.cc, I implemented a
'octave_multiprec' class which is
1) a scalar: it may access mapping func like sin, cos, tan, ...
2) a new type: it has unary and binary op

The skeleton found in make_int.cc permits to register the new type; I gave
the main func the name make_mp (this  is temporary)

Operations like
x = make_mp(2); y = make_mp(3), z=x+y do work correctly as
1) the class as a 'add' member function:
int add (const octave_multiprec& v1, const octave_multiprec& v2)
  {
    return mpfr_add (this->scalar, v1.scalar, v2.scalar, GMP_RNDN);
  }
2) this function is registred and accessed as
DEFBINOP (add, multiprec, multiprec)
{
  CAST_BINOP_ARGS (const octave_multiprec&, const octave_multiprec&);

  octave_multiprec *s = new octave_multiprec ();
  s->add (v1, v2); 
  return s;
}
INSTALL_BINOP (op_add, octave_multiprec, octave_multiprec, add);

How can I define similar function where only one of the arguments is an
Octave real scalar ? I tried
 INSTALL_BINOP (op_add, octave_multiprec, octave_scalar, add);
 INSTALL_BINOP (op_add, octave_scalar, octave_multiprec, add);

But I keep getting the same error message. Platform: octave-3.6.4

TIA

Pascal




--
View this message in context: 
http://octave.1599824.n4.nabble.com/binary-operator-not-implemented-for-scalar-by-new-type-operations-tp4655604.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]