/home/coin/SVN-release/OS-2.0.1/Bcp/src/Member/BCP_matrix_pack.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #include <numeric>
00005 
00006 #include "BCP_matrix.hpp"
00007 #include "BCP_buffer.hpp"
00008 
00009 void
00010 BCP_lp_relax::pack(BCP_buffer& buf) const {
00011    const int major = getMajorDim();
00012    const int minor = getMinorDim();
00013    buf.pack(colOrdered_)
00014       .pack(extraGap_)
00015       .pack(extraMajor_)
00016       .pack(major)
00017       .pack(minor)
00018       .pack(size_)
00019       .pack(maxMajorDim_)
00020       .pack(maxSize_);
00021 
00022    const int * length = getVectorLengths();
00023    const int * start = getVectorStarts();
00024    const int * ind = getIndices();
00025    const double * elem = getElements();
00026    if (major > 0) {
00027      buf.pack(length, major);
00028      buf.pack(start, major+1);
00029      for (int i = 0; i < major; ++i)
00030        buf.pack(ind + start[i], length[i]);
00031      for (int i = 0; i < major; ++i)
00032        buf.pack(elem + start[i], length[i]);
00033    }
00034 
00035    buf.pack(_Objective).pack(_ColLowerBound).pack(_ColUpperBound)
00036       .pack(_RowLowerBound).pack(_RowUpperBound);
00037 }
00038 
00039 void
00040 BCP_lp_relax::unpack(BCP_buffer& buf) {
00041    CoinPackedMatrix::gutsOfDestructor();
00042 
00043    buf.unpack(colOrdered_)
00044       .unpack(extraGap_)
00045       .unpack(extraMajor_)
00046       .unpack(majorDim_)
00047       .unpack(minorDim_)
00048       .unpack(size_)
00049       .unpack(maxMajorDim_)
00050       .unpack(maxSize_);
00051 
00052    length_  = new int[maxMajorDim_];
00053    start_   = new int[maxMajorDim_+1];
00054    index_   = new int[maxSize_];
00055    element_ = new double[maxSize_];
00056    if (majorDim_) {
00057      buf.unpack(length_, majorDim_, false);
00058      int md1 = majorDim_+1;
00059      buf.unpack(start_, md1, false);
00060 
00061      for (int i = 0; i < majorDim_; ++i) {
00062        int * itmp = index_ + start_[i];
00063        buf.unpack(itmp, length_[i], false);
00064      }
00065      for (int i = 0; i < majorDim_; ++i) {
00066        double * dtmp = element_ + start_[i];
00067        buf.unpack(dtmp, length_[i], false);
00068      }
00069    }
00070 
00071    buf.unpack(_Objective).unpack(_ColLowerBound).unpack(_ColUpperBound)
00072       .unpack(_RowLowerBound).unpack(_RowUpperBound);
00073 }

Generated on Thu Oct 8 03:02:52 2009 by  doxygen 1.4.7