Changeset 5fe545 in git


Ignore:
Timestamp:
May 18, 2005, 5:39:19 PM (19 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
b340969c053d9f828187f38bac97b1feb96e654e
Parents:
7835d2ba9bdd252cdfa90863a2ff862d818f9ac1
Message:
*hannes: ngcPower fixed


git-svn-id: file:///usr/local/Singular/svn/trunk@8218 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/gnumpc.cc

    r7835d2b r5fe545  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: gnumpc.cc,v 1.2 2005-01-18 08:53:45 Singular Exp $ */
     4/* $Id: gnumpc.cc,v 1.3 2005-05-18 15:39:19 Singular Exp $ */
    55/*
    66* ABSTRACT: computations with GMP complex floating-point numbers
     
    290290    return;
    291291  }
    292   if ( exp == 1 )
     292  else if ( exp == 1 )
    293293  {
    294294    nNew(u);
     
    306306    return;
    307307  }
    308   ngcPower(x,exp-1,u);
    309   gmp_complex *n=new gmp_complex();
    310   *n=*(gmp_complex*)x;
    311   *(gmp_complex*)(*u) *= *(gmp_complex*)n;
    312   delete n;
     308  else if (exp == 2)
     309  {
     310    nNew(u);
     311    if ( x == NULL )
     312    {
     313      gmp_complex* n = new gmp_complex();
     314      *u=(number)n;
     315    }
     316    else
     317    {
     318      gmp_complex* n = new gmp_complex();
     319      *n= *(gmp_complex*)x;
     320      *u=(number)n;
     321      *(gmp_complex*)(*u) *= *(gmp_complex*)n;
     322    }
     323    return;
     324  }
     325  if (exp&1==1)
     326  {
     327    ngcPower(x,exp-1,u);
     328    gmp_complex *n=new gmp_complex();
     329    *n=*(gmp_complex*)x;
     330    *(gmp_complex*)(*u) *= *(gmp_complex*)n;
     331    delete n;
     332  }
     333  else
     334  {
     335    number w;
     336    nNew(&w);
     337    ngcPower(x,exp/2,&w);
     338    ngcPower(w,2,u);
     339    nDelete(&w);
     340  }
    313341}
    314342
Note: See TracChangeset for help on using the changeset viewer.