00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MMX_MATRIX_INT_HPP
00014 #define __MMX_MATRIX_INT_HPP
00015 #include <basix/int.hpp>
00016 #include <algebramix/vector_unrolled.hpp>
00017 #include <algebramix/vector_simd.hpp>
00018 #include <algebramix/matrix.hpp>
00019 #include <algebramix/matrix_ring_naive.hpp>
00020 #include <algebramix/matrix_strassen.hpp>
00021 #include <algebramix/matrix_threads.hpp>
00022 #include <algebramix/matrix_simd.hpp>
00023 #include <algebramix/matrix_sse.hpp>
00024 namespace mmx {
00025 #define TMPL template<typename V>
00026 #define Matrix matrix<int,V>
00027
00028
00029
00030
00031
00032 TMPL inline Matrix operator + (const Matrix& x, const int& y) {
00033 return x + promote (y, x); }
00034 TMPL inline Matrix operator + (const int& x, const Matrix& y) {
00035 return promote (x, y) + y; }
00036 TMPL inline Matrix operator - (const Matrix& x, const int& y) {
00037 return x - promote (y, x); }
00038 TMPL inline Matrix operator - (const int& x, const Matrix& y) {
00039 return promote (x, y) - y; }
00040 TMPL inline Matrix operator * (const Matrix& x, const int& y) {
00041 return x * promote (y, x); }
00042 TMPL inline Matrix operator * (const int& x, const Matrix& y) {
00043 return promote (x, y) * y; }
00044 TMPL inline Matrix operator / (const Matrix& x, const int& y) {
00045 return x / promote (y, x); }
00046 TMPL inline Matrix operator / (const int& x, const Matrix& y) {
00047 return promote (x, y) / y; }
00048
00049 #undef TMPL
00050 #undef Matrix
00051
00052
00053
00054
00055
00056 DEFINE_VARIANT_1 (typename I, I, matrix_int_simd,
00057 matrix_ring_naive<
00058 matrix_strassen<
00059 matrix_threads<
00060 typename Matrix_simd_variant(I) > > >)
00061
00062 DEFINE_VARIANT (matrix_int,
00063 matrix_ring_naive<
00064 matrix_strassen<
00065 matrix_threads<
00066 matrix_unrolled<4> > > >)
00067
00068 #if defined(BASIX_HAVE_STDINT_H)
00069 STMPL
00070 struct matrix_variant_helper<int8_t> {
00071 typedef matrix_int_simd<int8_t> MV; };
00072 STMPL
00073 struct matrix_variant_helper<uint8_t> {
00074 typedef matrix_int_simd<uint8_t> MV; };
00075 STMPL
00076 struct matrix_variant_helper<int16_t> {
00077 typedef matrix_int_simd<int16_t> MV; };
00078 STMPL
00079 struct matrix_variant_helper<uint16_t> {
00080 typedef matrix_int_simd<uint16_t> MV; };
00081 STMPL
00082 struct matrix_variant_helper<int32_t> {
00083 typedef matrix_int_simd<int32_t> MV; };
00084 STMPL
00085 struct matrix_variant_helper<uint32_t> {
00086 typedef matrix_int_simd<uint32_t> MV; };
00087 STMPL
00088 struct matrix_variant_helper<int64_t> {
00089 typedef matrix_int MV; };
00090 STMPL
00091 struct matrix_variant_helper<uint64_t> {
00092 typedef matrix_int MV; };
00093 #else
00094 STMPL
00095 struct matrix_variant_helper<signed char> {
00096 typedef matrix_int_simd<signed char> MV; };
00097 STMPL
00098 struct matrix_variant_helper<unsigned char> {
00099 typedef matrix_int_simd<unsigned char> MV; };
00100 STMPL
00101 struct matrix_variant_helper<signed short> {
00102 typedef matrix_int_simd<signed short> MV; };
00103 STMPL
00104 struct matrix_variant_helper<unsigned short> {
00105 typedef matrix_int_simd<unsigned short> MV; };
00106 STMPL
00107 struct matrix_variant_helper<int> {
00108 typedef matrix_int_simd<int> MV; };
00109 STMPL
00110 struct matrix_variant_helper<unsigned int> {
00111 typedef matrix_int_simd<unsigned int> MV; };
00112 STMPL
00113 struct matrix_variant_helper<long int> {
00114 typedef matrix_int MV; };
00115 STMPL
00116 struct matrix_variant_helper<unsigned long int> {
00117 typedef matrix_int MV; };
00118 STMPL
00119 struct matrix_variant_helper<long long int> {
00120 typedef matrix_int MV; };
00121 STMPL
00122 struct matrix_variant_helper<unsigned long long int> {
00123 typedef matrix_int MV; };
00124 #endif
00125
00126 #if defined(BASIX_HAVE_INT128) && defined(BASIX_HAVE_STDINT_H)
00127 STMPL
00128 struct matrix_variant_helper<__int128> {
00129 typedef matrix_int MV; };
00130 STMPL
00131 struct matrix_variant_helper<unsigned __int128> {
00132 typedef matrix_int MV; };
00133 #endif
00134
00135
00136
00137
00138
00139 template<typename V>
00140 struct threshold_helper<signed char,
00141 matrix_multiply_threshold<matrix_strassen<V> > > {
00142 typedef fixed_value<nat,2048> impl;
00143 };
00144
00145 template<typename V>
00146 struct threshold_helper<unsigned char,
00147 matrix_multiply_threshold<matrix_strassen<V> > > {
00148 typedef fixed_value<nat,2048> impl;
00149 };
00150
00151 template<typename V>
00152 struct threshold_helper<short int,
00153 matrix_multiply_threshold<matrix_strassen<V> > > {
00154 typedef fixed_value<nat,1024> impl;
00155 };
00156
00157 template<typename V>
00158 struct threshold_helper<unsigned short int,
00159 matrix_multiply_threshold<matrix_strassen<V> > > {
00160 typedef fixed_value<nat,1024> impl;
00161 };
00162
00163 template<typename V>
00164 struct threshold_helper<int,
00165 matrix_multiply_threshold<matrix_strassen<V> > > {
00166 typedef fixed_value<nat,512> impl;
00167 };
00168
00169 template<typename V>
00170 struct threshold_helper<unsigned int,
00171 matrix_multiply_threshold<matrix_strassen<V> > > {
00172 typedef fixed_value<nat,512> impl;
00173 };
00174
00175 template<typename V>
00176 struct threshold_helper<long int,
00177 matrix_multiply_threshold<matrix_strassen<V> > > {
00178 typedef fixed_value<nat,512> impl;
00179 };
00180
00181 template<typename V>
00182 struct threshold_helper<unsigned long int,
00183 matrix_multiply_threshold<matrix_strassen<V> > > {
00184 typedef fixed_value<nat,512> impl;
00185 };
00186
00187 template<typename V>
00188 struct threshold_helper<long long int,
00189 matrix_multiply_threshold<matrix_strassen<V> > > {
00190 typedef fixed_value<nat,512> impl;
00191 };
00192
00193 template<typename V>
00194 struct threshold_helper<unsigned long long int,
00195 matrix_multiply_threshold<matrix_strassen<V> > > {
00196 typedef fixed_value<nat,512> impl;
00197 };
00198
00199 #if defined(BASIX_HAVE_INT128) && defined(BASIX_HAVE_STDINT_H)
00200 template<typename V>
00201 struct threshold_helper<__int128,
00202 matrix_multiply_threshold<matrix_strassen<V> > > {
00203 typedef fixed_value<nat,256> impl;
00204 };
00205
00206 template<typename V>
00207 struct threshold_helper<unsigned __int128,
00208 matrix_multiply_threshold<matrix_strassen<V> > > {
00209 typedef fixed_value<nat,256> impl;
00210 };
00211 #endif
00212
00213 }
00214 #endif // __MMX_MATRIX_INT_HPP