AbstractLinAlgPack_COOMatrixClass.cpp

Go to the documentation of this file.
00001 #if 0
00002 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00007 //                  Copyright (2003) Sandia Corporation
00008 // 
00009 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 // license for use of this work by or on behalf of the U.S. Government.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00027 // 
00028 // ***********************************************************************
00029 // @HEADER
00030 
00031 #include <sstream>
00032 
00033 #include "AbstractLinAlgPack_COOMatrixClass.hpp"
00034 #include "AbstractLinAlgPack_SparseCOOReadMatrix.hpp"
00035 #include "DenseLinAlgPack_IVector.hpp"
00036 
00037 // Junk, test compilation
00038 //#include "MemMngPackDef.h"
00039 //MemMngPack::RefCount<double> ref1;
00040 
00041 //#include "SequentialAllocatorPack.hpp"
00042 //template SequentialAllocatorPack::SequentialAllocator<double>;
00043 
00044 // ///////////////////////////////////////////////////////////////////////////////////
00045 // COOMatrix
00046 
00047 AbstractLinAlgPack::COOMatrix& AbstractLinAlgPack::COOMatrix::operator=(const COOMatrix& coom)
00048 {
00049   if(this == &coom) return *this; // assignment to self
00050 
00051   val_.resize(coom.nz_);  // must resize, this is why you can't use default assignment.
00052 
00053   // Now assign the members(this is what the default would have done).
00054   rows_       = coom.rows_;
00055   cols_       = coom.cols_;
00056   nz_         = coom.nz_;
00057   val_        = coom.val_;
00058   ivect_ref_      = coom.ivect_ref_;
00059   jvect_ref_      = coom.jvect_ref_;
00060 
00061   return *this;
00062 }
00063 
00064 void AbstractLinAlgPack::COOMatrix::resize(size_type rows, size_type cols, size_type nz)
00065 {
00066    // don't resize if you don't have to to presearve row and column access just in case.
00067   if(rows == rows_ && cols == cols_ && nz == nz_) return;
00068   
00069   rows_ = rows;
00070   cols_ = cols;
00071   nz_ = nz;
00072   val_.resize(nz);
00073   ivect_ref_.obj().resize(nz);
00074   jvect_ref_.obj().resize(nz);
00075 }
00076 
00077 void AbstractLinAlgPack::COOMatrix::initialize(std::istream& istrm) {
00078   // Read COO matrix into val, ivect, jvect
00079   read_coo_into_valarrays(istrm,rows_,cols_,nz_,val_,ivect_ref_.obj()
00080     ,jvect_ref_.obj());
00081 }
00082 
00083 #endif // 0

Generated on Tue Jul 13 09:30:49 2010 for MOOCHO (Single Doxygen Collection) by  doxygen 1.4.7