#include "Didasko_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#endif
#if defined(HAVE_DIDASKO_TEUCHOS)
#include "Teuchos_TimeMonitor.hpp"
using namespace Teuchos;
RCP<Time> CompTime = TimeMonitor::getNewTimer("Computational Time");
RCP<Time> FactTime = TimeMonitor::getNewTimer("Factorial Time");
double quadFunc( double x );
double factFunc( int x );
int main(int argc, char* argv[])
{
int i;
double x;
#ifdef HAVE_MPI
MPI_Init(&argc, &argv);
#endif
for( i=-100; i<100; i++ ) {
x = quadFunc( (double) i );
}
for( i=0; i<100; i++ ) {
x = factFunc( i );
}
TimeMonitor::summarize();
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
double quadFunc( double x )
{
Teuchos::TimeMonitor LocalTimer(*CompTime);
return ( x*x - 1.0 );
}
double factFunc( int x )
{
Teuchos::TimeMonitor LocalTimer(*FactTime);
if( x == 0 ) return 0.0;
if( x == 1 ) return 1.0;
return ( (double) x * factFunc(x-1) );
}
#else
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
puts("Please configure Didasko with:\n"
"--enable-teuchos");
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
#endif