aimstil
5.0.5
|
Compute the N-root of an integer. More...
#include <til/miscTools.h>
Classes | |
class | NoRoot |
Public Member Functions | |
T | operator() (T n, std::size_t N) |
Return an N-root of integer n, that is, the integer i so that i^N = n. More... | |
Compute the N-root of an integer.
Right now, just a stupid, super-brute-force algorithm. NB: T can actually be a non integer type, this does not have to be a restriction, and at the same time the name of the class advertise quite clearly what it does, so I guess it's OK.
Definition at line 172 of file miscTools.h.
T til::IntegerRoot< T >::operator() | ( | T | n, |
std::size_t | N | ||
) |
Return an N-root of integer n, that is, the integer i so that i^N = n.
If several solutions are possible, returns the positive solution. This happens only if n > 0 and N%2 = 0, and in that case, the other solution is -n. If there exist no integer solution, throws an exception.