|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Thyra: Interfaces and Support for Abstract Numerical Algorithms 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef THYRA_DESCRIBE_LINEAR_OP_HPP 00030 #define THYRA_DESCRIBE_LINEAR_OP_HPP 00031 00032 #include "Thyra_describeLinearOp_def.hpp" 00033 #include "Thyra_LinearOpBase.hpp" 00034 #include "Thyra_MultiVectorBase.hpp" 00035 #include "Thyra_VectorStdOps.hpp" 00036 #include "Thyra_AssertOp.hpp" 00037 #include "Thyra_AssertOp.hpp" 00038 00039 00040 template<class Scalar> 00041 void Thyra::describeLinearOp( 00042 const LinearOpBase<Scalar> &A, 00043 Teuchos::FancyOStream &out_arg, 00044 const Teuchos::EVerbosityLevel verbLevel 00045 ) 00046 { 00047 using Teuchos::RCP; 00048 using Teuchos::FancyOStream; 00049 using Teuchos::OSTab; 00050 typedef Teuchos::ScalarTraits<Scalar> DST; 00051 00052 RCP<FancyOStream> out = rcp(&out_arg,false); 00053 OSTab tab(out); 00054 *out << A.description() << "\n"; 00055 00056 const Teuchos::RCP<const VectorSpaceBase<Scalar> > 00057 range = A.range(); 00058 const Teuchos::RCP<const VectorSpaceBase<Scalar> > 00059 domain = A.domain(); 00060 00061 if(!range.get()) { 00062 return; 00063 } 00064 00065 const Ordinal dimDomain = domain->dim(), dimRange = range->dim(); 00066 if ( dimDomain > 0 && dimRange > 0 && verbLevel >= Teuchos::VERB_EXTREME ) { 00067 // Copy into dense matrix by column 00068 Teuchos::RCP<VectorBase<Scalar> > e_j = createMember(domain); 00069 Teuchos::RCP<VectorBase<Scalar> > t = createMember(range); // temp column 00070 RTOpPack::ConstSubVectorView<Scalar> sv; 00071 Array<Scalar> Md(dimRange*dimDomain); // Column major 00072 const Ordinal 00073 cs = 1, // stride for columns or rows 00074 rs = dimRange; // stride for rows or columns 00075 Ordinal i, j; 00076 OSTab tab2(out); 00077 for( j = 0; j < dimDomain; ++j ) { 00078 Thyra::assign( e_j.ptr(), DST::zero() ); 00079 Thyra::set_ele( j, DST::one(), e_j.ptr() ); 00080 Thyra::apply<Scalar>(A, NOTRANS, *e_j, t.ptr()); // extract the ith column or row 00081 t->acquireDetachedView(Range1D(),&sv); 00082 for( i = 0; i < dimRange; ++i ) Md[ i*cs + j*rs ] = sv(i); 00083 t->releaseDetachedView(&sv); 00084 } 00085 // Print the matrix 00086 for( i = 0; i < dimRange; ++i ) { 00087 for( j = 0; j < dimDomain; ++j ) 00088 *out << " " << i << ":" << j << ":" << Md[ i + j*dimRange ]; 00089 *out << std::endl; 00090 } 00091 } 00092 00093 } 00094 00095 00096 // 00097 // Explicit instant macro 00098 // 00099 00100 #define THYRA_DESCRIBE_LINEAR_INSTANT(SCALAR) \ 00101 \ 00102 template void describeLinearOp( \ 00103 const LinearOpBase<SCALAR > &A, \ 00104 Teuchos::FancyOStream &out_arg, \ 00105 const Teuchos::EVerbosityLevel verbLevel \ 00106 ); \ 00107 00108 00109 00110 #endif // THYRA_DESCRIBE_LINEAR_OP_HPP
1.7.4