Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dblock.cpp

Go to the documentation of this file.
00001 //****************************************************
00002 //  April, 1993, University of Illinois
00003 // Copyright (C) 1993, 1994 Tianlin Wang
00004 /* Copyright (C) 1994-2003 Matvec Development Team. 
00005 
00006   This program is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010   
00011   This program is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015     
00016   You should have received a copy of the GNU Library General Public
00017   License along with this library; if not, write to the Free
00018   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00019   MA 02111-1307, USA 
00020 */
00021 
00022 #include "dblock.h"
00023 
00024 namespace matvec {
00025 
00026 Dblock::Dblock (int nd, int nr, int nc){ 
00027   if (nd<=0) {
00028     std::cerr <<"Depth of block is not positive \n" << std::flush;
00029   }
00030   else if (nr<=0) {
00031     std::cerr <<"Number of rows Block is not positive \n" << std::flush;
00032   }
00033   else if (nc<=0) {
00034     std::cerr <<"Number of columns Block is not positive \n" << std::flush;
00035   }
00036   else {
00037     ndim=nd;
00038     nrow=nr; 
00039     ncol=nc;
00040     block.resize(nd);
00041     for (int i=1;i<=nd;i++){
00042       block(i).resize(nr,nc);
00043     }
00044   }
00045 }
00046 
00047 void Dblock::resize (int nd, int nr, int nc){
00048   if (nd<=0) {
00049     std::cerr <<"Depth of block is not positive \n" << std::flush;
00050   }
00051   else if (nr<=0) {
00052     std::cerr <<"Number of rows Block is not positive \n" << std::flush;
00053   }
00054   else if (nc<=0) {
00055     std::cerr <<"Number of columns Block is not positive \n" << std::flush;
00056   }
00057   else {
00058     ndim=nd;
00059     nrow=nr; 
00060     ncol=nc;
00061     block.resize(nd);
00062     for (int i=1;i<=nd;i++){
00063       block(i).resize(nr,nc);
00064     }
00065   }
00066 }
00067 
00068 void Dblock::resize (int nd, int nr, int nc, double init){
00069   if (nd<=0) {
00070     std::cerr <<"Depth of block is not positive \n" << std::flush;
00071   }
00072   else if (nr<=0) {
00073     std::cerr <<"Number of rows Block is not positive \n" << std::flush;
00074   }
00075   else if (nc<=0) {
00076     std::cerr <<"Number of columns Block is not positive \n" << std::flush;
00077   }
00078   else {
00079     ndim=nd;
00080     nrow=nr; 
00081     ncol=nc;
00082     block.resize(nd);
00083     for (int i=1;i<=nd;i++){
00084       block(i).resize(nr,nc,init);
00085     }
00086   }
00087 }
00088 
00089 void Dblock::init(double val){
00090   int i,j,k;
00091   for (i=0;i<ndim;i++){
00092        for (j=0;j<nrow;j++){
00093          for (k=0;k<ncol;k++){
00094              block[i][j][k]=val;
00095          }
00096        }
00097   }
00098 }
00099 
00100 std::ostream& operator << (std::ostream &stream, Dblock& D)
00101 {
00102    stream << "\n";
00103    int k,i,j,jstart,jend,ncols_remaining;
00104 
00105    for (k=1;k<=D.ndim; k++){
00106     ncols_remaining = D.ncol;
00107     jend = 0;
00108     while (ncols_remaining > 0) {
00109       jstart = jend + 1;
00110       jend = jstart + ncols_remaining - 1;
00111       ncols_remaining -= 10;
00112       if (ncols_remaining < 0) {
00113         ncols_remaining = 0;
00114       }
00115       else {
00116         jend = jstart + 9;
00117       } 
00118       stream << "\n Block " << k <<"\n" << "          ";
00119       stream.width(2);
00120       for (j=jstart;j<=jend;j++){
00121         stream << " column " << j;
00122       }
00123       stream << "\n";
00124       for (i=1;i<=D.nrow; i++) {
00125         stream << "\n" << "Row ";
00126         stream.width(4);
00127         stream << i << "  ";
00128         for (j=jstart;j<=jend;j++){
00129           stream.width(9);
00130           stream << D(k,i,j);
00131         } 
00132       }
00133     }
00134    stream << "\n" ;     
00135    }
00136    stream << "\n" << "\n" ;     
00137    return stream;
00138 }
00139 }

Generated on Thu Jun 16 17:13:38 2005 for Matvec by doxygen1.2.16