MathTL
io/vector_io.h
00001 // -*- c++ -*-
00002 
00003 // +--------------------------------------------------------------------+
00004 // | This file is part of MathTL - the Mathematical Template Library    |
00005 // |                                                                    |
00006 // | Copyright (c) 2002-2009                                            |
00007 // | Thorsten Raasch, Manuel Werner                                     |
00008 // +--------------------------------------------------------------------+
00009 
00010 #ifndef _MATHTL_VECTOR_IO_H
00011 #define _MATHTL_VECTOR_IO_H
00012 
00013 #include <iostream>
00014 
00015 namespace MathTL
00016 {
00017   /*
00018     generic input/output routines for VECTOR classes with a standard
00019     signature like of std::vector<T>
00020     We use the size() routine for determining the dimension of the vector.
00021   */
00022   
00027   template <class VECTOR>
00028   void print_vector(const VECTOR& v, std::ostream& os)
00029   {
00030     os << "[";
00031     if (v.size() > 0)
00032       {
00033         os << v[0];
00034         for (unsigned int i(1); i < v.size(); i++)
00035           os << " " << v[i];
00036       }
00037     os << "]";
00038   }
00039 }
00040 
00041 #endif
 All Classes Functions Variables Typedefs Enumerations