Thread: Using operator "()" inside boost matrix

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    33

    Using operator "()" inside boost matrix

    Hi,

    I've wrote a class inherit from boost matrix, however, I can't figure out how to access the random access operator "()" inside the class.

    For instance, I can use "()" outside the class by m.(x, y) = some_value, however, inside the class I can't just using (x, y) = some_value, although my compiler didn't complain this way, some_value will not be assigned successfully.

    Neither this(x, y), *this(x, y), this->(x, y) will pass the compiler. (I have to confess that I'm not familiar with the usage of "this"...)

    Besides, I can't examine the value of x_location and y_location inside the following for-loop, is it a bug of gdb?

    Here is my code, any idea?

    Code:
    #ifndef TARGET_REGION_H
    #define TARGET_REGION_H
    
    #include <iostream>
    #include <vector>
    #include <utility>
    #include <boost/numeric/ublas/matrix.hpp>
    #include <boost/numeric/ublas/io.hpp>
    
    using namespace std ;
    using namespace boost::numeric ;
    
    class Target_Region: public ublas::matrix<bool>
    {
    public:
    	Target_Region( const int width, const int height, const vector<int> to_be_inpaint_vec_x, const vector<int> to_be_inpaint_vec_y )
    	{
    		assert( to_be_inpaint_vec_x.size() == to_be_inpaint_vec_y.size() ) ;
    
    		bool preserve_previous_value = false ;
    		resize( width, height, preserve_previous_value ) ;
    
    		// for each pixel location in to_be_inpaint_vec, markup to true in the target region
    		vector<int>::const_iterator x_location_iter = to_be_inpaint_vec_x.begin() ;
    		vector<int>::const_iterator y_location_iter = to_be_inpaint_vec_y.begin() ;
    		int x_location = 0 ;
    		int y_location = 0 ;
    		for( ; x_location_iter != to_be_inpaint_vec_x.end() ; ++x_location_iter, ++y_location_iter )
    		{
    			x_location = *x_location_iter ;
    			y_location = *y_location_iter ;
    			( x_location, y_location ) = true ;
    		}
    	}
    
    private:
    
    };
    
    
    #endif
    Last edited by jutirain; 02-17-2008 at 10:21 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  2. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 05:57 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. What is a matrix's purpose in OpenGL
    By jimboob in forum Game Programming
    Replies: 5
    Last Post: 11-14-2004, 12:19 AM