2002

Grusel++ of the month

Home
Download Source
/******************************************************************************/
/*                                                                            */
/*                                                             FILE: june.cpp */
/*                                                                            */
/*  I finally found an application for the C++ complex                        */
/*  ==================================================                        */
/*                                                                            */
/*  Compiled and tested with Visual C++ V6.0                                  */
/*                                                                            */
/*  V1.00   30-JUN-2002   P. Tellenbach   http://www.heimetli.ch/             */
/*                                                                            */
/******************************************************************************/

#include <iostream>
#include <complex>
#include <algorithm>

using namespace std ;

#define CONSTANT complex<double>(0,0.448798950512827605494663340468)

complex<double> table[] = { complex<double>( 581.2500,    0.0000),
                            complex<double>(-164.0940, -125.6900), 
                            complex<double>(  18.7120, -242.6540), 
                            complex<double>( -22.7807,  -25.1399), 
                            complex<double>(  72.1255,   32.4917), 
                            complex<double>( -27.1256, -113.7790), 
                            complex<double>( -29.8375,   17.3722), 
                            complex<double>(  77.5000,    1.383845e-014) } ;

class Function
{
   protected:
      double value ;
      int    index ;
      double loop ;

   public:
      Function( int l ) : value(0.0), index(0), loop(l)
      {
      }

      void operator()( const complex<double> &cplx )
      {
         value += real( cplx * exp( CONSTANT * loop * (double)index++) ) ;
      }

   friend ostream &operator<<( ostream &os, Function &func )
   {
      os << (char)(func.value / 7) ;
      return os ;
   }
} ;

int main( )
{
   for( int k = 0; k < 14; k++ )
     cout << for_each( table, table + 8, Function(k) ) ;

   return 0 ;
}