How optimize speed of vector initialization? RRS feed

  • Question

  • I am using boost/multiprecision/cpp_int.hpp for arbitrary length integers computing.

    Now I am testing simplest algorithm for multiplication: wiki/Multiplication_algorithm#Long_multiplication

    My algorithm tested with Visual 2019 Release is several times slower than boost algorithm, but when I change vecctor do stack constant arrays is faster than Boost for small numbers. Most time is spent in:

    vector<SingleDigit> standard_multiply(const vector<SingleDigit>&a, const vector<SingleDigit>&b)
    	int p = a.size();
    	int q = b.size();
    	vector<SingleDigit> product;
    	product.resize(p + q);
    In product.resize or
    vector<SingleDigit> product(p+q);
    Boost sources is more complicated but faster is allocated number.

    Monday, November 4, 2019 11:33 PM

All replies

  • Hi,

    Thank you for posting here.

    This forum is about c++ development. According to your issue , I suggest you should ask it in a boost newsgroup or forum. And this thread will be moved to Off-Topic Posts.

    Best Regards,

    Suarez Zhou

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 5, 2019 6:03 AM
  • Tuesday, November 5, 2019 7:05 AM