00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MMX_POLYNOMIAL_KRONECKER_HPP
00014 #define __MMX_POLYNOMIAL_KRONECKER_HPP
00015 #include <algebramix/polynomial_naive.hpp>
00016
00017 namespace mmx {
00018 #define TMPL template<typename C>
00019
00020
00021
00022
00023
00024 template<typename V>
00025 struct polynomial_kronecker: public V {
00026 typedef typename V::Vec Vec;
00027 typedef typename V::Naive Naive;
00028 typedef typename V::Positive Positive;
00029 typedef polynomial_kronecker<typename V::No_simd> No_simd;
00030 typedef polynomial_kronecker<typename V::No_thread> No_thread;
00031 typedef polynomial_kronecker<typename V::No_scaled> No_scaled;
00032 };
00033
00034 template<typename F, typename V, typename W>
00035 struct implementation<F,V,polynomial_kronecker<W> >:
00036 public implementation<F,V,W> {};
00037
00038
00039
00040
00041
00042 template<typename V,typename W>
00043 struct implementation<polynomial_multiply,V,polynomial_kronecker<W> >:
00044 public implementation<polynomial_linear,V>
00045 {
00046 typedef polynomial_multiply_threshold<polynomial_kronecker<W> > Th;
00047 typedef implementation<polynomial_multiply,W> Fallback;
00048
00049 template<typename C,typename K> static inline void
00050 mul (C* dest, const C* s1, const K* s2, nat n1, nat n2) {
00051 Fallback::mul (dest, s1, s2, n1, n2); }
00052
00053 TMPL static inline void
00054 tmul (C* dest, const C* s1, const C* s2, nat n1, nat n2) {
00055 Fallback::tmul (dest, s1, s2, n1, n2); }
00056
00057 TMPL static inline void
00058 mul (C* dest, const C* s1, const C* s2, nat n1, nat n2) {
00059 if (min (n1, n2) < Threshold(C,Th))
00060 Fallback::mul (dest, s1, s2, n1, n2);
00061 else mul_kronecker (dest, s1, n1, s2, n2); }
00062
00063 TMPL static inline void
00064 square (C* dest, const C* s, nat n) {
00065 if (n < Threshold(C,Th)) Fallback::square (dest, s, n);
00066 else square_kronecker (dest, s, n); }
00067
00068 };
00069
00070 #undef TMPL
00071 }
00072 #endif // __MMX_POLYNOMIAL_KRONECKER_HPP