example/LAPACK/cxx_main.cpp

Go to the documentation of this file.
00001 #include "Teuchos_LAPACK.hpp"
00002 #include "Teuchos_SerialDenseMatrix.hpp"
00003 #include "Teuchos_SerialDenseVector.hpp"
00004 #include "Teuchos_Version.hpp"
00005 
00006 int main(int argc, char* argv[])
00007 {
00008   std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
00009 
00010   // Creating an instance of the LAPACK class for double-precision routines looks like:
00011   Teuchos::LAPACK<int, double> lapack;
00012 
00013   // This instance provides the access to all the LAPACK routines.
00014   Teuchos::SerialDenseMatrix<int, double> My_Matrix(4,4);
00015   Teuchos::SerialDenseVector<int, double> My_Vector(4);
00016   My_Matrix.random();
00017   My_Vector.random();
00018 
00019   // Perform an LU factorization of this matrix. 
00020   int ipiv[4], info;
00021   char TRANS = 'N';
00022   lapack.GETRF( 4, 4, My_Matrix.values(), My_Matrix.stride(), ipiv, &info ); 
00023   
00024   // Solve the linear system.
00025   lapack.GETRS( TRANS, 4, 1, My_Matrix.values(), My_Matrix.stride(), 
00026     ipiv, My_Vector.values(), My_Vector.stride(), &info );  
00027 
00028   // Print out the solution.
00029   std::cout << My_Vector << std::endl;
00030 
00031   return 0;
00032 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Tue Oct 20 10:13:59 2009 for Teuchos Package Browser (Single Doxygen Collection) by  doxygen 1.6.1