BLAS/cxx_main.cpp

This is an example of how to use the Teuchos::BLAS class.

00001 #include "Teuchos_BLAS.hpp"
00002 #include "Teuchos_Version.hpp"
00003 
00004 int main(int argc, char* argv[])
00005 {
00006   std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
00007 
00008   // Creating an instance of the BLAS class for double-precision kernels looks like:
00009   Teuchos::BLAS<int, double> blas;
00010 
00011   // This instance provides the access to all the BLAS kernels listed in Figure \ref{blas_kernels}:
00012   const int n = 10;
00013   double alpha = 2.0;
00014   double x[ n ];
00015   for ( int i=0; i<n; i++ ) { x[i] = i; }
00016   blas.SCAL( n, alpha, x, 1 );
00017   int max_idx = blas.IAMAX( n, x, 1 );
00018   std::cout<< "The index of the maximum magnitude entry of x[] is the "
00019       <<  max_idx <<"-th and x[ " << max_idx-1 << " ] = "<< x[max_idx-1] 
00020       << std::endl;
00021   
00022   return 0;
00023 }

Generated on Wed May 12 21:24:40 2010 for Teuchos - Trilinos Tools Package by  doxygen 1.4.7