109 Posted Topics
Below is my code [code] string str2 = "1, 2, 3, 4, 5, 6, 7, 8"; string output; typedef std::tr1::sregex_token_iterator sti; const sti end; for(sti i(str2.begin(), str2.end(), regex(",\\s"), -1); i != end; ++i) { //output += "\"" + *i + "\", "; output += "\""; output += *i; output += … | |
[code] Mat_<double> const affine = (Mat_<double>(2, 2) << 0.5, 1, 0, 2); Mat_<double> coordinate = (Mat_<double>(2, 1) << 20, 3); Mat_<double> C(2, 1); C = affine.mul(coordinate); // this line would crash the program C = affine * coordinate; // this line is ok [/code] I don't why and how, did … | |
Below is my code [code] void specificity::showText(vector<name_ID> &sacrifice, int die) { cimg::wait(100); unsigned int R = 50 + rand() % 255; unsigned int G = 100 + rand() % 255; unsigned int B = 50 + rand() % 255; unsigned char purple[] = { R,G,B }; img.fill(0).draw_text(width / 2, height … | |
I am using the library of boost to create a 2D dimensions array and compare about their speed There are three kinds of array, matrix of boost, multi_array of boost and the raw array Below is my code: [code] #ifndef TESTRELMAT_H #define TESTRELMAT_H #define BOOST_NO_EXCEPTIONS #define BOOST_DISABLE_ASSERTS #include <boost/numeric/ublas/matrix.hpp> #include … | |
Re: [QUOTE=;][/QUOTE] the problem of name ambiguous [code]distance[/code] is one of the name of std just change distance to Distance | |
Re: [code] #include<iostream> #include<bitset> int main() { bitset<8> num; cin>>num; cout<<num.to_ulong(); } [/code] } | |
Re: [code]float nm1, nm2, sid;[/code] maybe the problem is [code]float[/code] try [code]string nm1, nm2[/code] remember to include[code]#include<string>[/code] | |
i am curious about the unordered map of boost this is the first code I wrote [code = first] typedef pair<int, int> axis; typedef boost::unordered_map<axis, int> mCost; void testUnorderedMap() { mCost mc; axis p(0, 0); mc.insert(mCost::value_type(p, 3)); p.first = 0; p.second = 6; mc.insert(mCost::value_type(p, 33)); p.first = 0; p.second = … | |
I need to store about 0.1million int into the unordered_map and need the key(int, int) to search them The size of the data are fixed, and I don't need to change the data so oftenly Search is much more often than insert(more than 20 times of insert) I try to … |
The End.