Registered Member
|
In Eigen 3.0.1 .../Core/util/XprHelper.h, line 131, is:
My suggested fix is to remainder the multiplier and multiplicand, first, as the product of an integer multiple and any integer is also an integer multiple (by definition) and won't contribute to the final remainder. This reduces the range of the new product to less than the square of the modulus. expand: (A*B)%C = {[(A/C)*C + A%C]*[(B/C)*C + B%C]}%C cross multiply: (A*B)%C = {[(A/C)*C]*[(B/C)*C] + (A/C)*C*(B%C) + (B/C)*C*(A%C) + (A%C)*(B%C)}%C distribute: (A*B)%C = {[(A/C)*C]*[(B/C)*C]}%C + [(A/C)*C*(B%C)]%C + [(B/C)*C*(A%C)]%C + [(A%C)*(B%C)]%C cancel: (A*B)%C = [(A%C)*(B%C)]%C
|
Moderator
|
ok, fair enough, but those values are supposed to be very small since they target stack allocation. For instance it really makes no sense to use them values greater than let's say 32...
|
Registered Member
|
Stumbled on it; overflows of intermediate values are a pet peeve.
|
Moderator
|
which values did you use? because if you specify them, then somewhere in the code we'll have:
Scalar data[MaxCols*MaxRows]; if MaxCols*MaxRows overflows that means you are trying to allocate more than 2^31 * sizeof(Scalar) bytes on the stack! so I still don't really see how your fix can really improve things. Maybe your compiler did not used "int" but "short" for the enum values??? |
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar