aimstil  5.0.5
til::IntegerRoot< T > Class Template Reference

Compute the N-root of an integer. More...

#include <til/miscTools.h>

Classes

class  NoRoot
 

Public Member Functions

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...
 

Detailed Description

template<typename T>
class til::IntegerRoot< T >

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.

Member Function Documentation

◆ operator()()

template<typename T >
T til::IntegerRoot< T >::operator() ( 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.


The documentation for this class was generated from the following file: