mirror of
https://github.com/louisrubet/rpn
synced 2024-11-17 07:47:50 +01:00
#133: added complex conj
This commit is contained in:
parent
0b1bd7bc85
commit
aa6cd3a4de
3 changed files with 14 additions and 1 deletions
|
@ -60,7 +60,7 @@ program::keyword_t program::s_keywords[] =
|
|||
//COMPLEX
|
||||
{ cmd_keyword, "re", &program::re, "complex real part" },
|
||||
{ cmd_keyword, "im", &program::im, "complex imaginary part" },
|
||||
//{ cmd_keyword, "conj", &program::conj, "complex conjugate" },
|
||||
{ cmd_keyword, "conj", &program::conj, "complex conjugate" },
|
||||
{ cmd_keyword, "arg", &program::arg, "complex argument in radians" },
|
||||
|
||||
//TEST
|
||||
|
|
|
@ -38,3 +38,12 @@ void arg()
|
|||
stack::copy_and_push_back(_branch_stack, 0, *_stack);
|
||||
_branch_stack.pop_back();
|
||||
}
|
||||
|
||||
void conj()
|
||||
{
|
||||
MIN_ARGUMENTS(1);
|
||||
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
|
||||
|
||||
complex* cplx = (complex*)_stack->back();
|
||||
CHECK_MPFR(mpfr_neg(cplx->im()->mpfr, cplx->im()->mpfr, floating_t::s_mpfr_rnd));
|
||||
}
|
||||
|
|
|
@ -226,3 +226,7 @@ drop
|
|||
(0,-1) arg pi neg 2 / ==
|
||||
-> stack should be 1
|
||||
drop
|
||||
|
||||
# conj
|
||||
(1,2) conj dup conj
|
||||
-> stack should be (1,-2), (1,2)
|
||||
|
|
Loading…
Reference in a new issue