diff --git a/src_number/Makefile b/src_number/Makefile index 4094df7..39a8eae 100644 --- a/src_number/Makefile +++ b/src_number/Makefile @@ -1,4 +1,4 @@ -#PROGRAM = TestSquareRoot test_unordered_map_mpzq Factorize PracticalInf TestQuoInt PrintStaticInfo RealCubicFieldTest QuadFieldTest RationalTest TestTypeBoostGmp TestGetBit TestQuadraticResidue +PROGRAM = TestSquareRoot test_unordered_map_mpzq Factorize PracticalInf TestQuoInt PrintStaticInfo RealCubicFieldTest QuadFieldTest RationalTest TestTypeBoostGmp TestGetBit TestQuadraticResidue #PROGRAM = test_mpz_givaro #PROGRAM = test_unordered_map_mpzq #PROGRAM = Factorize @@ -11,7 +11,7 @@ #PROGRAM = RealCubicFieldTest #PROGRAM = RationalTest #PROGRAM = TestTypeBoostGmp -PROGRAM = TestQuadraticResidue +#PROGRAM = TestQuadraticResidue OBJECTS = $(PROGRAM:%=%.o) diff --git a/src_number/factorizations.h b/src_number/factorizations.h index 9c78186..ed71cff 100644 --- a/src_number/factorizations.h +++ b/src_number/factorizations.h @@ -78,7 +78,7 @@ template bool IsPrime(const T &N) { } } -template std::vector FactorsInt(T const &N) { +template std::vector Kernel_FactorsInt(T const &N) { static_assert(is_implementation_of_Z::value, "Requires T to be a Z ring"); if (N == 1) return {}; @@ -95,8 +95,27 @@ template std::vector FactorsInt(T const &N) { } } +template +inline typename std::enable_if::value,std::vector>::type +FactorsInt(T const &N) { + return Kernel_FactorsInt(N); +} + +template +inline typename std::enable_if::value,std::vector>::type +FactorsInt(T const &N) { + using Tint = typename underlying_ring::ring_type; + Tint N_int = UniversalScalarConversion(N); + std::vector LFact_int = Kernel_FactorsInt(N_int); + std::vector LFact; + for (auto & val_i : LFact_int) { + T val = UniversalScalarConversion(val_i); + LFact.push_back(val); + } + return LFact; +} + template std::map FactorsIntMap(T const &N) { - static_assert(is_implementation_of_Z::value, "Requires T to be a Z ring"); std::vector vect = FactorsInt(N); std::map map; for (auto &eV : vect) { @@ -107,7 +126,6 @@ template std::map FactorsIntMap(T const &N) { template std::vector GetAllFactors(std::map const &eMap) { - static_assert(is_implementation_of_Z::value, "Requires T to be a Z ring"); std::vector LVal = {1}; for (auto &kv : eMap) { std::vector NewVal; @@ -124,7 +142,6 @@ std::vector GetAllFactors(std::map const &eMap) { } template std::vector GetAllFactors(T const &N) { - static_assert(is_implementation_of_Z::value, "Requires T to be a Z ring"); std::vector LFact = FactorsInt(N); std::map eMap; for (auto &eVal : LFact)