Skip to content

Commit

Permalink
Implemented julian(x, a, b)
Browse files Browse the repository at this point in the history
  • Loading branch information
PC-SUMMO\Michele Summo committed Apr 15, 2022
1 parent 8952418 commit 3af3414
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/include/sffe_cmplx_gsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>

#define sffnctscount 78
#define sffnctscount 79
#define sfvarscount 6
#define cmplxset(c, r, i) GSL_SET_COMPLEX(&c, r, i)
#define real(c) GSL_REAL((c))
Expand Down Expand Up @@ -102,6 +102,8 @@ sfarg *sfcoti(sfarg *const p);
sfarg *sftrunc(sfarg *const p);
sfarg *sfsawtooth(sfarg *const p);
sfarg *sftwave(sfarg *const p);
/* other functions */
sfarg *sfjulian(sfarg *const p); // |z^a|*e^(i*b*arg(z))

/*const eval*/
void sfcPI(sfNumber *cnst);
Expand Down
17 changes: 17 additions & 0 deletions src/sffe/sffe_cmplx_gsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const sffunction sfcmplxfunc[sffnctscount] = {
{sfsawtooth, 1, "sawtooth\0"},
{sftwave, 1, "twave\0"},

{sfjulian, 3, "julian\0"},

{NULL, 1, "rad\0"},
{NULL, 1, "deg\0"},
{NULL, 1, "sign\0"},
Expand Down Expand Up @@ -676,6 +678,21 @@ sfarg *sftwave(sfarg *const p)
return sfaram1(p);
}

sfarg *sfjulian(sfarg *const p)
{
gsl_complex z = sfvalue(sfaram3(p));
double mag = gsl_complex_abs(
gsl_complex_pow(z, sfvalue(sfaram2(p))));
gsl_complex b = sfvalue(sfaram1(p));
double arg = gsl_complex_arg(z);
double byg = exp(-GSL_IMAG(b)*arg);
double bxg = arg * GSL_REAL(b);

GSL_REAL(sfvalue(p)) = mag * byg * cos(bxg);
GSL_IMAG(sfvalue(p)) = mag * byg * sin(bxg);
return sfaram3(p);
}

// const eval
void sfcPI(sfNumber *cnst) { GSL_SET_COMPLEX(cnst, 4 * atan(1), 0); }

Expand Down

0 comments on commit 3af3414

Please sign in to comment.