Skip to content

Instantly share code, notes, and snippets.

@sushant-hiray
Last active August 29, 2015 14:01
Show Gist options
  • Save sushant-hiray/b7cc24e7874154560aaa to your computer and use it in GitHub Desktop.
Save sushant-hiray/b7cc24e7874154560aaa to your computer and use it in GitHub Desktop.

Revisions

  1. sushant-hiray revised this gist May 14, 2014. 1 changed file with 11 additions and 3 deletions.
    14 changes: 11 additions & 3 deletions sampleeval.cpp
    Original file line number Diff line number Diff line change
    @@ -61,11 +61,19 @@ RCP<const Basic> sin(const RCP<const Basic> &arg)
    if (conjugate) {
    // cos has to be returned
    if (sign == 1)
    return cos(ret_arg);
    return rcp(new Cos(ret_arg));
    else
    return mul(minus_one, cos(ret_arg));
    return mul(minus_one, rcp(new Cos(ret_arg)));
    }
    else {

    if (eq(ret_arg, zero)) {
    return sign*sin_table[index];
    }
    else {
    if (sign == 1)
    return rcp(new Sin(ret_arg));
    else
    return mul(minus_one, rcp(new Sin(ret_arg)));
    }
    }
    }
  2. sushant-hiray revised this gist May 14, 2014. 1 changed file with 49 additions and 15 deletions.
    64 changes: 49 additions & 15 deletions sampleeval.cpp
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,16 @@
    const RCP<const Basic> handle_minus(const RCP<const Basic> &arg, bool odd)
    {
    if(could_extract_minus(r)) {
    if(odd)
    return mul(minus_one, r);
    else
    return r;
    }
    }

    // \return true of conjugate has to be returned finally else false
    bool eval(const RCP<const Basic> &arg, int period, bool odd, //input
    const Ptr<RCP<const Basic>> arg&,int index) //output
    const Ptr<RCP<const Basic>> arg&,int& index, int& sign) //output
    {
    if (eq(arg, zero)) return zero;
    bool check;
    @@ -10,28 +20,52 @@ bool eval(const RCP<const Basic> &arg, int period, bool odd, //input
    if (check) {
    int m = n->as_int();
    m = m % (12*period);
    sign = 1;
    if (eq(r, zero)) {
    index = m;
    *arg = zero;
    return false;
    }
    else if((m % (12*period)) == 0) {
    else if ((m % (12*period)) == 0) {
    index = 0;
    if(could_extract_minus(r)) {
    if(odd)
    *arg = mul(minus_one, r);
    else
    *arg = r;
    }
    else
    *arg = r;

    *arg = handle_minus(r, odd);
    if (!odd)
    sign = -1;
    return false;
    }
    else if((m % 6) == 0)) {

    else if ((m % 6) == 0)) {
    if (m == 6)
    sign = 1;
    else
    sign = -1;
    *arg = r;
    return true;
    }
    }
    else
    return rcp(new Sin(arg));
    else {
    *arg = r;
    index = -1;
    return false;
    }

    }

    RCP<const Basic> sin(const RCP<const Basic> &arg)
    {
    RCP<const Basic>>& ret_arg;
    int index;
    int sign;
    bool conjugate = eval(arg, 2, 1, //input
    outArg(ret_arg), index, sign); //output

    if (conjugate) {
    // cos has to be returned
    if (sign == 1)
    return cos(ret_arg);
    else
    return mul(minus_one, cos(ret_arg));
    }
    else {

    }
    }
  3. sushant-hiray revised this gist May 14, 2014. 1 changed file with 26 additions and 4 deletions.
    30 changes: 26 additions & 4 deletions sampleeval.cpp
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,36 @@
    RCP<const Basic> eval(const RCP<const Basic> &arg)
    // \return true of conjugate has to be returned finally else false
    bool eval(const RCP<const Basic> &arg, int period, bool odd, //input
    const Ptr<RCP<const Basic>> arg&,int index) //output
    {
    if (eq(arg, zero)) return zero;
    bool check;
    RCP<const Integer> n;
    RCP<const Basic> r;
    check = get_pi_shift(arg, outArg(n), outArg(r));
    if (check) {
    int index;
    index = n->as_int();
    return sin_table[index % 24];
    int m = n->as_int();
    m = m % (12*period);
    if (eq(r, zero)) {
    index = m;
    *arg = zero;
    return false;
    }
    else if((m % (12*period)) == 0) {
    index = 0;
    if(could_extract_minus(r)) {
    if(odd)
    *arg = mul(minus_one, r);
    else
    *arg = r;
    }
    else
    *arg = r;

    return false;
    }
    else if((m % 6) == 0)) {

    }
    }
    else
    return rcp(new Sin(arg));
  4. sushant-hiray renamed this gist May 14, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. sushant-hiray created this gist May 14, 2014.
    15 changes: 15 additions & 0 deletions sampleeval,cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    RCP<const Basic> eval(const RCP<const Basic> &arg)
    {
    if (eq(arg, zero)) return zero;
    bool check;
    RCP<const Integer> n;
    RCP<const Basic> r;
    check = get_pi_shift(arg, outArg(n), outArg(r));
    if (check) {
    int index;
    index = n->as_int();
    return sin_table[index % 24];
    }
    else
    return rcp(new Sin(arg));
    }