AbstractLinAlgPack_COOMatrixClass.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) 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 Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include <sstream>
00030 
00031 #include "AbstractLinAlgPack_COOMatrixClass.hpp"
00032 #include "AbstractLinAlgPack_SparseCOOReadMatrix.hpp"
00033 #include "DenseLinAlgPack_IVector.hpp"
00034 
00035 // Junk, test compilation
00036 //#include "MemMngPackDef.h"
00037 //MemMngPack::RefCount<double> ref1;
00038 
00039 //#include "SequentialAllocatorPack.hpp"
00040 //template SequentialAllocatorPack::SequentialAllocator<double>;
00041 
00042 // ///////////////////////////////////////////////////////////////////////////////////
00043 // COOMatrix
00044 
00045 AbstractLinAlgPack::COOMatrix& AbstractLinAlgPack::COOMatrix::operator=(const COOMatrix& coom)
00046 {
00047   if(this == &coom) return *this; // assignment to self
00048 
00049   val_.resize(coom.nz_);  // must resize, this is why you can't use default assignment.
00050 
00051   // Now assign the members(this is what the default would have done).
00052   rows_       = coom.rows_;
00053   cols_       = coom.cols_;
00054   nz_         = coom.nz_;
00055   val_        = coom.val_;
00056   ivect_ref_      = coom.ivect_ref_;
00057   jvect_ref_      = coom.jvect_ref_;
00058 
00059   return *this;
00060 }
00061 
00062 void AbstractLinAlgPack::COOMatrix::resize(size_type rows, size_type cols, size_type nz)
00063 {
00064    // don't resize if you don't have to to presearve row and column access just in case.
00065   if(rows == rows_ && cols == cols_ && nz == nz_) return;
00066   
00067   rows_ = rows;
00068   cols_ = cols;
00069   nz_ = nz;
00070   val_.resize(nz);
00071   ivect_ref_.obj().resize(nz);
00072   jvect_ref_.obj().resize(nz);
00073 }
00074 
00075 void AbstractLinAlgPack::COOMatrix::initialize(std::istream& istrm) {
00076   // Read COO matrix into val, ivect, jvect
00077   read_coo_into_valarrays(istrm,rows_,cols_,nz_,val_,ivect_ref_.obj()
00078     ,jvect_ref_.obj());
00079 }

Generated on Thu Sep 18 12:35:10 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1