0

I'm forking a C++ program using Alglib so that I can invert matrices and do matrix multiplications easily.

Right now I'm facing this error:

Invalid operands to binary expression ('const alglib::real_1d_array' and 'const alglib::real_1d_array')

So what caused this error?

 inline vecset getAdmittedCVectors(void)
 {
        return admittedCVectors;
 }

Here vecset means

typedef std::set<alglib::real_1d_array> vecset;

and admittedCVectors is a member of a class.

vecset admittedCVectors;

How shall I solve it? Using a variant of std::set that does not have this issue or overloading < in alglib::real_1d_array which is much harder?

Ying Zhou
  • 189
  • 3
  • 16
  • 2
    `std::set` requires that its elements be less-than comparable. Does `alglib::real_1d_array` support such comparison? – Igor Tandetnik Oct 08 '18 at 01:45
  • @IgorTandetnik Oh! Definitely not unless I try to define this operation. OK it seems that I need to look for alternative collections. Well I don't think even == is actually overloaded for alglib::real_1d_array..so maybe I should give up on the idea of using set-like structures for it. – Ying Zhou Oct 08 '18 at 01:49
  • 1
    If the type doesn't have overloads for the `<` or `==` operators, it doesn't sound like you need the collection to be ordered or unique. Have you considered `std::vector`? – John Ilacqua Oct 08 '18 at 02:08
  • @JohnIlacqua Well I do want the collection to be unique but do not want it to be ordered. == can be implemented. However I'm probably not going to be able to modify alglib very soon so maybe I will use a different collection. – Ying Zhou Oct 08 '18 at 02:35
  • 2
    then perhaps `unordered_set`? (though this requires a hash function and ==) – kmdreko Oct 08 '18 at 03:35

0 Answers0