#include "crp.h" #include #include #include #include #include "boost/array.hpp" #include "boost/multi_array.hpp" bool readSampleData( const std::string &file, std::vector &vec ); std::ostream &operator<<( std::ostream &ostr, const std::vector &vec ); int main() { int m = 2; int t = 12; float e = 1.5; std::vector x; boost::multi_array< float, 2> s; // (boost::extents[Nx][Nx]); std::string file("a_small.txt"); if( !readSampleData( file, x ) ) { std::cerr << "Unable to open sample data file: " << file << std::endl; return -1; } if( !crp( m, t, e, x, s ) ) std::cerr << "Error in crp function." << std::endl; { std::ofstream ofstr( "s_cpp.txt" ); int Nx = s.shape()[0]; for( int cnt = 0; cnt < Nx; ++cnt ) { for( int j = 0; j < Nx; j++ ) { ofstr << s[cnt][j] << " "; } ofstr << std::endl; } } return 0; } bool readSampleData( const std::string &file, std::vector &vec ) { std::ifstream ifs( file.c_str() ); if( !ifs.good() ) { return false; } while( !ifs.eof() ) { float val; if( ifs >> val ) vec.push_back( val ); else ; // ??? } return true; }