next up previous contents
Next: The Usual Private Print Up: The Definition File mycomplex.c: Previous: The Modulus of a

The nth Roots of Unity:

//====================================================//
//                                                    //
//                nth roots of unity                  //
//                                                    //
//====================================================//

MYCOMPLEX* unity(int n)
{
  MYCOMPLEX *w;
  w = new MYCOMPLEX[n];
  double t = 2.0*PI/(double)n;
  for(int i=0;i<n;++i){
    w[i].real = cos(i*t);
    w[i].imaginary = sin(i*t);
    }
  return(w);
}



Jim Peterson
1999-04-22