Main Page | Namespace List | Data Structures | File List | Namespace Members | Data Fields | Globals

ex_fill1.cpp

Go to the documentation of this file.
00001 // -*- c++ -*- //
00002 /***************************************************************************
00003  -   begin                : 2003-09-05
00004  -   copyright            : (C) 2003 by Gunter Winkler
00005  -   email                : guwi17@gmx.de
00006  -   This program is free. Use it at your own risk                
00007  ***************************************************************************/
00008 
00009 #include <iostream>
00010 
00011 #include <boost/numeric/ublas/matrix.hpp>
00012 #include <boost/numeric/ublas/matrix_sparse.hpp>
00013 #include <boost/numeric/ublas/io.hpp>
00014 
00015 using namespace boost::numeric::ublas ;
00016 
00017 using std::cout;
00018 using std::endl;
00019 
00020 int main(int argc, char *argv[])
00021 {
00022   const size_t size = 10;
00023   // define a row-major sparse matrix
00024   compressed_matrix<double>  A(size, size);
00025 
00026   for (size_t i=0; i<A.size1(); ++i)    {
00027         if (i>=1) { 
00028           A.push_back(i,i-1,-1.0); 
00029         }
00030         A.push_back(i,i,4);
00031         if (i+1<A.size2()) { 
00032           A.push_back(i,i+1,-1.0); 
00033         }
00034   }
00035   
00036   cout << "A = " << A << "(nonzeros: " << A.filled() << ")" << endl;
00037 
00038   return EXIT_SUCCESS;
00039 };

Generated on Wed Oct 1 14:41:00 2003 for Sample Code by doxygen 1.3.2