text: /*
     Copyright (c) 2009-2013, Jack Poulson
     All rights reserved.
  
     This file is part of Elemental and is under the BSD 2-Clause License, 
     which can be found in the LICENSE file in the root directory, or at 
     http://opensource.org/licenses/BSD-2-Clause
  */
  // NOTE: It is possible to simply include "elemental.hpp" instead
  #include "elemental-lite.hpp"
  #include "elemental/lapack-like/Polar.hpp"
  #include "elemental/matrices/Uniform.hpp"
  using namespace std;
  using namespace elem;
  
  // Typedef our real and complex types to 'R' and 'C' for convenience
  typedef double R;
  typedef Complex<R> C;
  
  int
  main( int argc, char* argv[] )
  {
      Initialize( argc, argv );
  
      mpi::Comm comm = mpi::COMM_WORLD;
      const int commRank = mpi::CommRank( comm );
  
      try 
      {
          const int m = Input("--height","matrix height",100);
          const int n = Input("--width","matrix width",100);
          const bool print = Input("--print","print matrices?",false);
          ProcessInput();
          PrintInputReport();
  
          Grid g( comm );
          DistMatrix<C> A( g ), Q( g ), P( g );
          Uniform( A, m, n );
  
          // Compute the polar decomp of A (but do not overwrite A)
          Q = A;
          Polar( Q, P );
  
          if( print )
          {
              A.Print("A");
              Q.Print("Q");
              P.Print("P");
          }
      }
      catch( ArgException& e )
      {
          // There is nothing to do
      }
      catch( exception& e )
      {
          ostringstream os;
          os << "Process " << commRank << " caught error message: " << e.what()
             << endl;
          cerr << os.str();
  #ifndef RELEASE
          DumpCallStack();
  #endif
      }
  
      Finalize();
      return 0;
  }
  
  