| [0b990d] | 1 | //
 | 
|---|
 | 2 | // blockedtest.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 | #include <util/keyval/keyval.h>
 | 
|---|
 | 29 | #include <math/scmat/local.h>
 | 
|---|
 | 30 | #include <math/scmat/blocked.h>
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 | using namespace sc;
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | void matrixtest(Ref<SCMatrixKit>, Ref<KeyVal>,
 | 
|---|
 | 35 |                 RefSCDimension d1,RefSCDimension d2,RefSCDimension d3,
 | 
|---|
 | 36 |                 bool have_svd);
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 | main(int argc, char **argv)
 | 
|---|
 | 39 | {
 | 
|---|
 | 40 |   int i;
 | 
|---|
 | 41 |   int nblks;
 | 
|---|
 | 42 |   int *blks1, *blks2, *blks3;
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 |   Ref<KeyVal> keyval = new ParsedKeyVal(SRCDIR "/matrixtest.in");
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 |   Ref<MessageGrp> msg = MessageGrp::initial_messagegrp(argc, argv);
 | 
|---|
 | 47 | 
 | 
|---|
 | 48 |   if (msg.null()) {
 | 
|---|
 | 49 |       msg << keyval->describedclassvalue("messagegrp");
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 |       if (msg.null()) {
 | 
|---|
 | 52 |           std::cerr << indent << "Couldn't initialize MessageGrp\n";
 | 
|---|
 | 53 |           abort();
 | 
|---|
 | 54 |         }
 | 
|---|
 | 55 |     }
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 |   MessageGrp::set_default_messagegrp(msg);
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 |   Ref<SCMatrixKit> subkit = new LocalSCMatrixKit;
 | 
|---|
 | 60 |   Ref<BlockedSCMatrixKit> kit = new BlockedSCMatrixKit(subkit);
 | 
|---|
 | 61 | 
 | 
|---|
 | 62 |   nblks = keyval->intvalue("nblocks");
 | 
|---|
 | 63 |   if (!nblks)
 | 
|---|
 | 64 |     nblks=3;
 | 
|---|
 | 65 |   
 | 
|---|
 | 66 |   blks1 = new int[nblks];
 | 
|---|
 | 67 |   blks2 = new int[nblks];
 | 
|---|
 | 68 |   blks3 = new int[nblks];
 | 
|---|
 | 69 |   
 | 
|---|
 | 70 |   RefSCDimension sd1; sd1 << keyval->describedclassvalue("d1");
 | 
|---|
 | 71 |   RefSCDimension sd2; sd2 << keyval->describedclassvalue("d2");
 | 
|---|
 | 72 |   RefSCDimension sd3; sd3 << keyval->describedclassvalue("d2");
 | 
|---|
 | 73 |   
 | 
|---|
 | 74 |   RefSCDimension d1(new SCDimension(sd1.n()*nblks,nblks));
 | 
|---|
 | 75 |   RefSCDimension d2(new SCDimension(sd2.n()*nblks,nblks));
 | 
|---|
 | 76 |   RefSCDimension d3(new SCDimension(sd3.n()*nblks,nblks));
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 |   for (i=0; i < nblks; i++) {
 | 
|---|
 | 79 |     d1->blocks()->set_subdim(i,sd1);
 | 
|---|
 | 80 |     d2->blocks()->set_subdim(i,sd2);
 | 
|---|
 | 81 |     d3->blocks()->set_subdim(i,sd3);
 | 
|---|
 | 82 |   }
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 |   matrixtest(kit,keyval,d1,d2,d3,false);
 | 
|---|
 | 85 |   
 | 
|---|
 | 86 |   d1 = new SCDimension(sd1.n(),1);
 | 
|---|
 | 87 |   d2 = new SCDimension(sd2.n(),1);
 | 
|---|
 | 88 |   d3 = new SCDimension(sd3.n(),1);
 | 
|---|
 | 89 | 
 | 
|---|
 | 90 |   d1->blocks()->set_subdim(0,sd1);
 | 
|---|
 | 91 |   d2->blocks()->set_subdim(0,sd2);
 | 
|---|
 | 92 |   d3->blocks()->set_subdim(0,sd3);
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 |   matrixtest(kit,keyval,d1,d2,d3,false);
 | 
|---|
 | 95 |   d1=0;
 | 
|---|
 | 96 | 
 | 
|---|
 | 97 |   return 0;
 | 
|---|
 | 98 | }
 | 
|---|
 | 99 | 
 | 
|---|
 | 100 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
 | 101 | 
 | 
|---|
 | 102 | // Local Variables:
 | 
|---|
 | 103 | // mode: c++
 | 
|---|
 | 104 | // c-file-style: "CLJ"
 | 
|---|
 | 105 | // End:
 | 
|---|