IFPACK Development
ifp_BlockVec.cpp
00001 //@HEADER
00002 // ***********************************************************************
00003 // 
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) 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 #include "ifp_BlockVec.h"
00030 
00031 ifp_BlockVec::ifp_BlockVec(const ifp_BlockVec& A)
00032 {
00033     dim0 = A.dim0;
00034     dim1 = A.dim1;
00035     ld = A.dim0;
00036     size0 = A.dim0;
00037     base = new double[dim0*dim1];
00038     v = base;
00039     partit = A.partit;
00040     owndata = 1;
00041     VecCopy(A);
00042 }
00043 
00044 ifp_BlockVec::ifp_BlockVec(const ifp_BlockVec& A, int index)
00045 {
00046 if (index >= 0)
00047 {
00048     dim0 = A.partit[index+1] - A.partit[index];;
00049     dim1 = A.dim1;
00050     ld = dim0;
00051     size0 = dim0;
00052     base = new double[dim0*dim1];
00053     v = base;
00054     partit = NULL;
00055     owndata = 1;
00056 
00057     // copy the values
00058 
00059     int i, j;
00060     double *p;
00061     const double *q;
00062 
00063     for (i=0; i<dim1; i++)
00064     {
00065     p = v + i*ld;
00066         q = A.base + A.partit[index] + i*A.ld;
00067         for (j=0; j<size0; j++)
00068             *p++ = *q++;
00069     }
00070 }
00071 else
00072 {
00073     dim0 = A.size0;
00074     dim1 = A.dim1;
00075     ld = dim0;
00076     size0 = dim0;
00077     base = new double[dim0*dim1];
00078     v = base;
00079     partit = NULL;
00080     owndata = 1;
00081 
00082     // copy the values
00083 
00084     int i, j;
00085     double *p;
00086     const double *q;
00087 
00088     for (i=0; i<dim1; i++)
00089     {
00090     p = v + i*ld;
00091         q = A.v + i*A.ld;
00092         for (j=0; j<size0; j++)
00093             *p++ = *q++;
00094     }
00095 }
00096 }
00097 
00098 void ifp_BlockVec::VecCopy(const ifp_BlockVec& A)
00099 {
00100 #ifdef DEBUG
00101     assert(dim0 == A.dim0 && dim1 == A.dim1);
00102 #endif
00103     int i, j;
00104     double *p;
00105     const double *q;
00106 
00107     for (i=0; i<dim1; i++)
00108     {
00109     p = v + i*ld;
00110         q = A.v + i*A.ld;
00111         for (j=0; j<dim0; j++)
00112             *p++ = *q++;
00113     }
00114 }
00115 
00116 void ifp_BlockVec::VecSetToZero()
00117 {
00118     int i, j;
00119     double *p;
00120 
00121     for (i=0; i<dim1; i++)
00122     {
00123     p = v + i*ld;
00124         for (j=0; j<dim0; j++)
00125             *p++ = 0.0;
00126     }
00127 }
00128 
00129 void ifp_BlockVec::BlockCopy(const ifp_BlockVec& A)
00130 {
00131 #ifdef DEBUG
00132     assert(size0 == A.size0 && dim1 == A.dim1);
00133 #endif
00134     int i, j;
00135     double *p;
00136     const double *q;
00137 
00138     for (i=0; i<dim1; i++)
00139     {
00140     p = v + i*ld;
00141         q = A.v + i*A.ld;
00142         for (j=0; j<size0; j++)
00143             *p++ = *q++;
00144     }
00145 }
00146 
00147 void ifp_BlockVec::BlockSetToZero()
00148 {
00149     int i, j;
00150     double *p;
00151 
00152     for (i=0; i<dim1; i++)
00153     {
00154     p = v + i*ld;
00155         for (j=0; j<size0; j++)
00156             *p++ = 0.0;
00157     }
00158 }
 All Classes Files Functions Variables Enumerations Friends