| 1 | //
 | 
|---|
| 2 | // blocked.cc
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
 | 
|---|
| 5 | //
 | 
|---|
| 6 | // Author: Curtis Janssen <cljanss@limitpt.com>
 | 
|---|
| 7 | // Maintainer: LPS
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // This file is part of the SC Toolkit.
 | 
|---|
| 10 | //
 | 
|---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
| 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 14 | // any later version.
 | 
|---|
| 15 | //
 | 
|---|
| 16 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 19 | // GNU Library General Public License for more details.
 | 
|---|
| 20 | //
 | 
|---|
| 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
| 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 24 | //
 | 
|---|
| 25 | // The U.S. Government is granted a limited license as per AL 91-7.
 | 
|---|
| 26 | //
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #ifdef __GNUC__
 | 
|---|
| 29 | #pragma implementation
 | 
|---|
| 30 | #endif
 | 
|---|
| 31 | 
 | 
|---|
| 32 | #include <math.h>
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #include <util/misc/formio.h>
 | 
|---|
| 35 | #include <util/keyval/keyval.h>
 | 
|---|
| 36 | #include <math/scmat/blocked.h>
 | 
|---|
| 37 | #include <math/scmat/cmatrix.h>
 | 
|---|
| 38 | #include <math/scmat/elemop.h>
 | 
|---|
| 39 | 
 | 
|---|
| 40 | using namespace std;
 | 
|---|
| 41 | using namespace sc;
 | 
|---|
| 42 | 
 | 
|---|
| 43 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 44 | // BlockedSCMatrixKit member functions
 | 
|---|
| 45 | 
 | 
|---|
| 46 | static ClassDesc BlockedSCMatrixKit_cd(
 | 
|---|
| 47 |   typeid(BlockedSCMatrixKit),"BlockedSCMatrixKit",1,"public SCMatrixKit",
 | 
|---|
| 48 |   0, create<BlockedSCMatrixKit>, 0);
 | 
|---|
| 49 | 
 | 
|---|
| 50 | BlockedSCMatrixKit::BlockedSCMatrixKit(const Ref<SCMatrixKit>&subkit):
 | 
|---|
| 51 |   subkit_(subkit)
 | 
|---|
| 52 | {
 | 
|---|
| 53 | }
 | 
|---|
| 54 | 
 | 
|---|
| 55 | BlockedSCMatrixKit::BlockedSCMatrixKit(const Ref<KeyVal>& keyval):
 | 
|---|
| 56 |   SCMatrixKit(keyval)
 | 
|---|
| 57 | {
 | 
|---|
| 58 |   subkit_ << keyval->describedclassvalue("subkit");
 | 
|---|
| 59 | }
 | 
|---|
| 60 | 
 | 
|---|
| 61 | BlockedSCMatrixKit::~BlockedSCMatrixKit()
 | 
|---|
| 62 | {
 | 
|---|
| 63 | }
 | 
|---|
| 64 | 
 | 
|---|
| 65 | SCMatrix*
 | 
|---|
| 66 | BlockedSCMatrixKit::matrix(const RefSCDimension&d1, const RefSCDimension&d2)
 | 
|---|
| 67 | {
 | 
|---|
| 68 |   int i;
 | 
|---|
| 69 |   for (i=0; i<d1->blocks()->nblock(); i++) {
 | 
|---|
| 70 |       if (d1->blocks()->subdim(i).null()) {
 | 
|---|
| 71 |           ExEnv::errn() << indent
 | 
|---|
| 72 |                << "BlockedSCMatrixKit: given a dim without subdim info"
 | 
|---|
| 73 |                << endl;
 | 
|---|
| 74 |           abort();
 | 
|---|
| 75 |         }
 | 
|---|
| 76 |     }
 | 
|---|
| 77 |   for (i=0; i<d2->blocks()->nblock(); i++) {
 | 
|---|
| 78 |       if (d2->blocks()->subdim(i).null()) {
 | 
|---|
| 79 |           ExEnv::errn() << indent
 | 
|---|
| 80 |                << "BlockedSCMatrixKit: given a dim without subdim info"
 | 
|---|
| 81 |                << endl;
 | 
|---|
| 82 |           abort();
 | 
|---|
| 83 |         }
 | 
|---|
| 84 |     }
 | 
|---|
| 85 |   return new BlockedSCMatrix(d1,d2,this);
 | 
|---|
| 86 | }
 | 
|---|
| 87 | 
 | 
|---|
| 88 | SymmSCMatrix*
 | 
|---|
| 89 | BlockedSCMatrixKit::symmmatrix(const RefSCDimension&d)
 | 
|---|
| 90 | {
 | 
|---|
| 91 |   for (int i=0; i<d->blocks()->nblock(); i++) {
 | 
|---|
| 92 |       if (d->blocks()->subdim(i).null()) {
 | 
|---|
| 93 |           ExEnv::errn() << indent
 | 
|---|
| 94 |                << "BlockedSCMatrixKit: given a dim without subdim info"
 | 
|---|
| 95 |                << endl;
 | 
|---|
| 96 |           abort();
 | 
|---|
| 97 |         }
 | 
|---|
| 98 |     }
 | 
|---|
| 99 |   return new BlockedSymmSCMatrix(d,this);
 | 
|---|
| 100 | }
 | 
|---|
| 101 | 
 | 
|---|
| 102 | DiagSCMatrix*
 | 
|---|
| 103 | BlockedSCMatrixKit::diagmatrix(const RefSCDimension&d)
 | 
|---|
| 104 | {
 | 
|---|
| 105 |   for (int i=0; i<d->blocks()->nblock(); i++) {
 | 
|---|
| 106 |       if (d->blocks()->subdim(i).null()) {
 | 
|---|
| 107 |           ExEnv::errn() << indent
 | 
|---|
| 108 |                << "BlockedSCMatrixKit: given a dim without subdim info"
 | 
|---|
| 109 |                << endl;
 | 
|---|
| 110 |           abort();
 | 
|---|
| 111 |         }
 | 
|---|
| 112 |     }
 | 
|---|
| 113 |   return new BlockedDiagSCMatrix(d,this);
 | 
|---|
| 114 | }
 | 
|---|
| 115 | 
 | 
|---|
| 116 | SCVector*
 | 
|---|
| 117 | BlockedSCMatrixKit::vector(const RefSCDimension&d)
 | 
|---|
| 118 | {
 | 
|---|
| 119 |   for (int i=0; i<d->blocks()->nblock(); i++) {
 | 
|---|
| 120 |       if (d->blocks()->subdim(i).null()) {
 | 
|---|
| 121 |           ExEnv::errn() << indent
 | 
|---|
| 122 |                << "BlockedSCMatrixKit: given a dim without subdim info"
 | 
|---|
| 123 |                << endl;
 | 
|---|
| 124 |           abort();
 | 
|---|
| 125 |         }
 | 
|---|
| 126 |     }
 | 
|---|
| 127 |   return new BlockedSCVector(d,this);
 | 
|---|
| 128 | }
 | 
|---|
| 129 | 
 | 
|---|
| 130 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 131 | 
 | 
|---|
| 132 | static ClassDesc BlockedSCElementOp_cd(
 | 
|---|
| 133 |   typeid(BlockedSCElementOp),"BlockedSCElementOp",1,"public SCElementOp",
 | 
|---|
| 134 |   0, 0, 0);
 | 
|---|
| 135 | 
 | 
|---|
| 136 | BlockedSCElementOp::BlockedSCElementOp()
 | 
|---|
| 137 | {
 | 
|---|
| 138 |   current_block_=0;
 | 
|---|
| 139 | }
 | 
|---|
| 140 | 
 | 
|---|
| 141 | void
 | 
|---|
| 142 | BlockedSCElementOp::working_on(int b)
 | 
|---|
| 143 | {
 | 
|---|
| 144 |   current_block_ = b;
 | 
|---|
| 145 | }
 | 
|---|
| 146 | 
 | 
|---|
| 147 | int
 | 
|---|
| 148 | BlockedSCElementOp::current_block() const
 | 
|---|
| 149 | {
 | 
|---|
| 150 |   return current_block_;
 | 
|---|
| 151 | }
 | 
|---|
| 152 | 
 | 
|---|
| 153 | static ClassDesc BlockedSCElementOp2_cd(
 | 
|---|
| 154 |   typeid(BlockedSCElementOp2),"BlockedSCElementOp2",1,"public SCElementOp2",
 | 
|---|
| 155 |   0, 0, 0);
 | 
|---|
| 156 | 
 | 
|---|
| 157 | BlockedSCElementOp2::BlockedSCElementOp2()
 | 
|---|
| 158 | {
 | 
|---|
| 159 |   current_block_=0;
 | 
|---|
| 160 | }
 | 
|---|
| 161 | 
 | 
|---|
| 162 | void
 | 
|---|
| 163 | BlockedSCElementOp2::working_on(int b)
 | 
|---|
| 164 | {
 | 
|---|
| 165 |   current_block_ = b;
 | 
|---|
| 166 | }
 | 
|---|
| 167 | 
 | 
|---|
| 168 | int
 | 
|---|
| 169 | BlockedSCElementOp2::current_block() const
 | 
|---|
| 170 | {
 | 
|---|
| 171 |   return current_block_;
 | 
|---|
| 172 | }
 | 
|---|
| 173 | 
 | 
|---|
| 174 | static ClassDesc BlockedSCElementOp3_cd(
 | 
|---|
| 175 |   typeid(BlockedSCElementOp3),"BlockedSCElementOp3",1,"public SCElementOp3",
 | 
|---|
| 176 |   0, 0, 0);
 | 
|---|
| 177 | 
 | 
|---|
| 178 | BlockedSCElementOp3::BlockedSCElementOp3()
 | 
|---|
| 179 | {
 | 
|---|
| 180 |   current_block_=0;
 | 
|---|
| 181 | }
 | 
|---|
| 182 | 
 | 
|---|
| 183 | void
 | 
|---|
| 184 | BlockedSCElementOp3::working_on(int b)
 | 
|---|
| 185 | {
 | 
|---|
| 186 |   current_block_ = b;
 | 
|---|
| 187 | }
 | 
|---|
| 188 | 
 | 
|---|
| 189 | int
 | 
|---|
| 190 | BlockedSCElementOp3::current_block() const
 | 
|---|
| 191 | {
 | 
|---|
| 192 |   return current_block_;
 | 
|---|
| 193 | }
 | 
|---|
| 194 | 
 | 
|---|
| 195 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 196 | 
 | 
|---|
| 197 | // Local Variables:
 | 
|---|
| 198 | // mode: c++
 | 
|---|
| 199 | // c-file-style: "CLJ"
 | 
|---|
| 200 | // End:
 | 
|---|