• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/OpenTissue/OpenTissue/core/math/big/big_generate_random.h

Go to the documentation of this file.
00001 #ifndef OPENTISSUE_CORE_MATH_BIG_BIG_GENERATE_RANDOM_H
00002 #define OPENTISSUE_CORE_MATH_BIG_BIG_GENERATE_RANDOM_H
00003 //
00004 // OpenTissue Template Library
00005 // - A generic toolbox for physics-based modeling and simulation.
00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
00007 //
00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
00009 //
00010 #include <OpenTissue/configuration.h>
00011 
00012 #include <OpenTissue/core/math/math_random.h>
00013 #include <OpenTissue/core/math/math_value_traits.h>
00014 #include <OpenTissue/core/math/math_is_number.h>
00015 
00016 
00017 namespace OpenTissue
00018 {
00019   namespace math
00020   {
00021     namespace big
00022     {
00023 
00035       template<typename matrix_type>
00036       inline void generate_random( size_t const & m, size_t const & n,  matrix_type & A  )
00037       {
00038         typedef typename matrix_type::value_type                     value_type;
00039         typedef          OpenTissue::math::ValueTraits<value_type>   value_traits;
00040 
00041         Random<value_type> value(value_traits::zero(),value_traits::one());
00042 
00043         assert( m>0         || !"generate_random(): m was out of range");
00044         assert( n>0         || !"generate_random(): n was out of range");
00045   
00046         A.resize(m,n,false);
00047         A.clear();
00048 
00049         for(size_t i=0;i<A.size1();++i)
00050         {
00051           for(size_t j=0;j<A.size2();++j)
00052           {
00053             A(i,j) = value();
00054             assert( is_number( A(i,j) ) || !"generate_random(): not a number encountered");
00055           }
00056         }
00057       }
00058 
00059 
00070       template<typename value_type>
00071       inline void generate_random( size_t const & n,  ublas::vector<value_type> & v  )
00072       {
00073         typedef ValueTraits<value_type> value_traits;
00074 
00075         Random<value_type> value(value_traits::zero(),value_traits::one());
00076 
00077         assert( n>0         || !"generate_random(): n was out of range");
00078 
00079         v.resize(n,false);
00080         v.clear();
00081 
00082         for(size_t i=0;i<n;++i)
00083         {
00084           v(i) = value();
00085           assert( is_number( v(i) ) || !"generate_random(): not a number encountered");
00086         }
00087       }
00088 
00089 
00090     } // end of namespace big
00091   } // end of namespace math
00092 } // end of namespace OpenTissue
00093 
00094 // OPENTISSUE_CORE_MATH_BIG_BIG_GENERATE_RANDOM_H
00095 #endif

Generated on Thu Dec 1 2011 12:52:05 for HUMIM Tracker by  doxygen 1.7.1