@@ -609,8 +609,58 @@ const MathCalcCommon<f32>::LogSample MathCalcCommon<f32>::cLogTbl[256 + 1]{
609609 {0.6931471824645996 , 0.0019512200960889459 },
610610};
611611
612- template <typename T>
613- T MathCalcCommon<T>::gcd(T x, T y)
612+ template <>
613+ s32 MathCalcCommon<s32>::gcd(s32 x, s32 y)
614+ {
615+ if (x == 0 || y == 0 )
616+ return 0 ;
617+
618+ while (x != y)
619+ {
620+ if (x > y)
621+ x -= y;
622+ else
623+ y -= x;
624+ }
625+
626+ return x;
627+ }
628+
629+ template <>
630+ s32 MathCalcCommon<s32>::lcm(s32 x, s32 y)
631+ {
632+ if (x == 0 || y == 0 )
633+ return 0 ;
634+ return x / gcd (x, y) * y;
635+ }
636+
637+ template <>
638+ u32 MathCalcCommon<u32 >::gcd(u32 x, u32 y)
639+ {
640+ if (x == 0 || y == 0 )
641+ return 0 ;
642+
643+ while (x != y)
644+ {
645+ if (x > y)
646+ x -= y;
647+ else
648+ y -= x;
649+ }
650+
651+ return x;
652+ }
653+
654+ template <>
655+ u32 MathCalcCommon<u32 >::lcm(u32 x, u32 y)
656+ {
657+ if (x == 0 || y == 0 )
658+ return 0 ;
659+ return x / gcd (x, y) * y;
660+ }
661+
662+ template <>
663+ s64 MathCalcCommon<s64>::gcd(s64 x, s64 y)
614664{
615665 if (x == 0 || y == 0 )
616666 return 0 ;
@@ -626,18 +676,38 @@ T MathCalcCommon<T>::gcd(T x, T y)
626676 return x;
627677}
628678
629- template <typename T >
630- T MathCalcCommon<T >::lcm(T x, T y)
679+ template <>
680+ s64 MathCalcCommon<s64 >::lcm(s64 x, s64 y)
631681{
632682 if (x == 0 || y == 0 )
633683 return 0 ;
634684 return x / gcd (x, y) * y;
635685}
636686
637- template s32 MathCalcCommon<s32>::gcd(s32 x, s32 y);
638- template s32 MathCalcCommon<s32>::lcm(s32 x, s32 y);
639- template u32 MathCalcCommon<u32 >::gcd(u32 x, u32 y);
640- template u32 MathCalcCommon<u32 >::lcm(u32 x, u32 y);
687+ template <>
688+ u64 MathCalcCommon<u64 >::gcd(u64 x, u64 y)
689+ {
690+ if (x == 0 || y == 0 )
691+ return 0 ;
692+
693+ while (x != y)
694+ {
695+ if (x > y)
696+ x -= y;
697+ else
698+ y -= x;
699+ }
700+
701+ return x;
702+ }
703+
704+ template <>
705+ u64 MathCalcCommon<u64 >::lcm(u64 x, u64 y)
706+ {
707+ if (x == 0 || y == 0 )
708+ return 0 ;
709+ return x / gcd (x, y) * y;
710+ }
641711
642712template <>
643713u32 MathCalcCommon<f32 >::atanIdx_(f32 t)
0 commit comments