Epetra_OskiMultiVector.cpp

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright (2001) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ************************************************************************
00028 //@HEADER
00029 
00030 #include "Epetra_ConfigDefs.h"
00031 
00032 #ifdef HAVE_OSKI
00033 #ifdef HAVE_EPETRA_TEUCHOS
00034 #include "Epetra_OskiMultiVector.h"
00035 
00036 //=============================================================================
00037 
00038 Epetra_OskiMultiVector::Epetra_OskiMultiVector(const Epetra_OskiMultiVector& Source) 
00039   : Epetra_MultiVector(Source), 
00040   Epetra_View_(Source.Epetra_View_), 
00041   Copy_Created_(Source.Copy_Created_) {
00042     Oski_View_ = oski_CopyVecView(Source.Oski_View_);
00043 }
00044 
00045 Epetra_OskiMultiVector::Epetra_OskiMultiVector(const Epetra_MultiVector& Source) 
00046   : Epetra_MultiVector(Source),
00047   Epetra_View_(&Source), 
00048   Copy_Created_(false) {
00049     double* A;
00050     double** Aptr;
00051     int LDA;
00052     int* LDAptr;
00053     LDAptr = new int[1];
00054     Aptr = new double*[1];
00055     if(Source.ConstantStride() || (Source.NumVectors() == 1)) {
00056       if(Source.ExtractView(Aptr, LDAptr))
00057         std::cerr << "Extract view failed\n";
00058       else
00059         Oski_View_ = oski_CreateMultiVecView(*Aptr, Source.MyLength(), Source.NumVectors(), LAYOUT_COLMAJ, *LDAptr);
00060     }
00061     else {
00062       Copy_Created_ = true;
00063       LDA = Source.MyLength();
00064       A = new double[LDA*Source.NumVectors()];
00065       if(Source.ExtractCopy(A, LDA))
00066         std::cerr << "Extract copy failed\n";
00067       else
00068         Oski_View_ = oski_CreateMultiVecView(A, Source.MyLength(), Source.NumVectors(), LAYOUT_COLMAJ, LDA);
00069     }
00070     delete [] LDAptr;
00071     delete [] Aptr;
00072 }
00073 
00074 Epetra_OskiMultiVector::~Epetra_OskiMultiVector() {
00075   if(oski_DestroyVecView(Oski_View_))
00076     std::cerr << "Vector destroy failed\n";
00077 }
00078 
00079 bool Epetra_OskiMultiVector::Copy_Created() const {
00080   return Copy_Created_;
00081 }
00082 
00083 oski_vecview_t Epetra_OskiMultiVector::Oski_View() const {
00084   return Oski_View_;
00085 }
00086 
00087 const Epetra_MultiVector* Epetra_OskiMultiVector::Epetra_View() const {
00088   return Epetra_View_;
00089 }
00090 
00091 Epetra_OskiMultiVector& Epetra_OskiMultiVector::operator = (const Epetra_OskiMultiVector& Source) {
00092   Epetra_View_ = Source.Epetra_View_;
00093   Oski_View_ = Source.Oski_View_;
00094   Copy_Created_ = Source.Copy_Created_;
00095   return(*this);
00096 }
00097 
00098 #endif
00099 #endif

Generated on Wed May 12 21:41:05 2010 for Epetra Package Browser (Single Doxygen Collection) by  doxygen 1.4.7