Creation and use of matrixes in C++
\nNote that also you can use boost.ublas for matrix creation and manipulation and also boost.graph to represent and manipulate graphs in a number of ways, as well as using algorithms on them, etc.<\/p>\n
Edit: Anyway, doing a range-check version of a vector for your purposes is not a hard thing:<\/p>\n
template public: }; LINK: Creation and use of matrixes in C++
\nclass BoundsMatrix
\n{
\nstd::vector
\nunsigned int dimx<\/em>, dimy_;<\/p>\n
\nBoundsMatrix (unsigned int dimx, unsigned int dimy)
\n: dimx (dimx), dimy<\/em> (dimy)
\n{
\ninner.resize (dimx<\/em>*dimy_);
\n}<\/p>\n T& operator()(unsigned int x, unsigned int y)\n {\n if (x >= dimx_ || y>= dimy_)\n throw 0; \/\/ ouch\n return inner_[dimx_*y + x];\n }<\/code><\/pre>\n
\nNote that you would also need to add the const version of the operators, and\/or iterators, and the strange use of exceptions, but you get the idea.<\/p>\n
\nhttp:\/TC1017 #Mastery26<\/a><\/h1>\n<\/div>\n","protected":false},"excerpt":{"rendered":"
\nNote that also you can use boost.ublas for matrix creation and manipulation and also boost.graph to represent and manipulate graphs in a number of ways, as well as using algorithms on them, etc.
\nEdit: Anyway… Continue reading