- /* SMPBERN.CPP by K.Tsuru */
- const char* title = "<<< A sample program for tangent coefficient, Bernouilli and Euler numbers >>>\n";
- #include "sn.h"
- #include "getnum.h"
- #include "wait.h"
- #include "timer.h"
-
- void TnTableTest(uint N){
- SNBlock <SLong> T(N+1);
- Timer timer;
- double cpu_time;
-
- puts("Calculating tangent coefficients by TanCoeffTable() function.");
- timer.Start();
- TanCoeffTable(T, N);
- cpu_time = timer.Stop();
- for(uint n = 1; n<= N; n++){
- printf("T[%u]= ", n);
- T(n).Puts();
- }
- printf("CPU time = %.3f sec.\n", cpu_time);
- Wait();
- }
-
- void TanCoeffTest(uint N){
- SNBlock <SLong> T(N+1);
- Timer timer;
- double cpu_time;
- uint n;
-
- puts("Calcuating tangent coefficients by TanCoeff() function.");
- timer.Start();
- for(n = 1; n <= N; n++) T[n-1] = TanCoeff(n);
- cpu_time = timer.Stop();
-
- for(n = 1; n <= N; n++){
- printf("T[%u]=", n);
- T(n-1).Puts();
- }
- printf("CPU time = %.3f sec.\n", cpu_time);
- Wait();
- }
-
- void BnTableTest(uint N){
- SNBlock <SFraction> B(N+1);
- Timer timer;
- double cpu_time;
-
- puts("Calculating Bernouilli numbers by BernNumTable() function.");
- timer.Start();
- BernNumTable(B, N);
- cpu_time = timer.Stop();
- for(uint n = 1; n<= N; n++){
- printf("B[%u]= ", n);
- B(n).Puts();
- }
- printf("CPU time = %.3f sec.\n", cpu_time);
- Wait();
- }
-
- void BernNumTest(uint N){
- SNBlock <SFraction> B(N+1);
- Timer timer;
- double cpu_time;
- uint n;
-
- puts("Calculating Bernouilli numbers by BernNum() function with combL().");
- timer.Start();
- for(n = 1; n <= N; n++) B[n] = BernNum(n);
- cpu_time = timer.Stop();
- for(n = 1; n <= N; n++){
- printf("B[%u]= ", n);
- B(n).Puts();
- }
- printf("CPU time = %.3f sec.\n", cpu_time);
- Wait();
- }
-
- void EulerNumTest(uint N){
- SNBlock <SLong> E(N+1);
- Timer timer;
- double cpu_time;
- uint n;
-
- puts("Calculating Euler numbers by EulerNum() function.");
- timer.Start();
- for(n=0; n<= N; n++) E[n] = EulerNum(n);
- cpu_time = timer.Stop();
-
- for(n = 0; n<= N; n++){
- printf("E[%u]=", n);
- E(n).Puts();
- }
- printf("CPU time = %.3f sec.\n", cpu_time);
- Wait();
- }
-
- int main(){
- uint N;
-
- ErrorPuts(title);
- fprintf(stderr,"How many terms do you want? ");
- N = GetInt();
-
- TnTableTest(N);
- TanCoeffTest(N);
- BnTableTest(N);
- BernNumTest(N);
- EulerNumTest(N);
-
- Ending();
-
- return EXIT_SUCCESS;
- }
smpbern.cpp : last modifiled at 2007/04/18 14:09:40(2,375 bytes)
created at 2010/01/13 16:21:47
The creation time of this html file is 2010/01/21 10:02:02 (Thu Jan 21 10:02:02 2010).