Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Commit

Permalink
expose C trig functions to pub
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-goldsmith-okcupid committed Sep 5, 2012
1 parent 27eee8b commit 5fa78e0
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
100 changes: 100 additions & 0 deletions librfn/math.C
Expand Up @@ -110,6 +110,106 @@ namespace rfn3 {

//-----------------------------------------------------------------------

ptr<const expr_t>
cos_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
double n = args[0]._f;
return expr_double_t::alloc (cos (n));
}

//-----------------------------------------------------------------------

const str cos_t::DOCUMENTATION =
"The C-library cos() function, input in radians.";

//-----------------------------------------------------------------------

ptr<const expr_t>
tan_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
double n = args[0]._f;
return expr_double_t::alloc (tan (n));
}

//-----------------------------------------------------------------------

const str tan_t::DOCUMENTATION =
"The C-library tan() function, input in radians.";

//-----------------------------------------------------------------------

ptr<const expr_t>
asin_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
double n = args[0]._f;
return expr_double_t::alloc (asin (n));
}

//-----------------------------------------------------------------------

const str asin_t::DOCUMENTATION =
"The C-library asin() function, input in radians.";

//-----------------------------------------------------------------------

ptr<const expr_t>
acos_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
double n = args[0]._f;
return expr_double_t::alloc (acos (n));
}

//-----------------------------------------------------------------------

const str acos_t::DOCUMENTATION =
"The C-library acos() function, input in radians.";

//-----------------------------------------------------------------------

ptr<const expr_t>
sin_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
double n = args[0]._f;
return expr_double_t::alloc (sin (n));
}

//-----------------------------------------------------------------------

const str sin_t::DOCUMENTATION =
"The C-library sin() function, input in radians.";

//-----------------------------------------------------------------------

ptr<const expr_t>
atan_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
double n = args[0]._f;
return expr_double_t::alloc (atan (n));
}

//-----------------------------------------------------------------------

const str atan_t::DOCUMENTATION =
"The C-library atan() function, input in radians.";


//-----------------------------------------------------------------------

ptr<const expr_t>
atan2_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
double y = args[0]._f;
double x = args[1]._f;
return expr_double_t::alloc (atan2 (y,x));
}

//-----------------------------------------------------------------------

const str atan2_t::DOCUMENTATION =
"The C-library atan2() function, input in radians.";

//-----------------------------------------------------------------------

ptr<const expr_t>
pow_t::v_eval_2 (eval_t *p, const vec<arg_t> &args) const
{
Expand Down
7 changes: 7 additions & 0 deletions librfn/okrfn-int.h
Expand Up @@ -51,6 +51,13 @@ namespace rfn3 {
PUB3_COMPILED_FN_DOC(sqrt, "f");
PUB3_COMPILED_FN_DOC(exp, "f");
PUB3_COMPILED_FN_DOC(log, "f");
PUB3_COMPILED_FN_DOC(sin, "f");
PUB3_COMPILED_FN_DOC(cos, "f");
PUB3_COMPILED_FN_DOC(tan, "f");
PUB3_COMPILED_FN_DOC(asin, "f");
PUB3_COMPILED_FN_DOC(acos, "f");
PUB3_COMPILED_FN_DOC(atan, "f");
PUB3_COMPILED_FN_DOC(atan2, "f");
PUB3_COMPILED_FN_DOC(str, "O");
PUB3_COMPILED_FN(documentation, "O");
PUB3_COMPILED_FN_DOC(tag_escape, "s|r");
Expand Down
7 changes: 7 additions & 0 deletions librfn/rfn3.C
Expand Up @@ -107,6 +107,13 @@ namespace rfn3 {
F(index_of);
F(eval_location);
F(breadcrumb);
F(cos);
F(sin);
F(tan);
F(asin);
F(acos);
F(atan);
F(atan2);

#undef F

Expand Down

0 comments on commit 5fa78e0

Please sign in to comment.