00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "main.h"
00026
00027 float *ptr;
00028 const float *const_ptr;
00029
00030 template<typename PlainObjectType,
00031 bool IsDynamicSize = PlainObjectType::SizeAtCompileTime == Dynamic,
00032 bool IsVector = PlainObjectType::IsVectorAtCompileTime
00033 >
00034 struct mapstaticmethods_impl {};
00035
00036 template<typename PlainObjectType, bool IsVector>
00037 struct mapstaticmethods_impl<PlainObjectType, false, IsVector>
00038 {
00039 static void run(const PlainObjectType& m)
00040 {
00041 mapstaticmethods_impl<PlainObjectType, true, IsVector>::run(m);
00042
00043 int i = internal::random<int>(2,5), j = internal::random<int>(2,5);
00044
00045 PlainObjectType::Map(ptr).setZero();
00046 PlainObjectType::MapAligned(ptr).setZero();
00047 PlainObjectType::Map(const_ptr).sum();
00048 PlainObjectType::MapAligned(const_ptr).sum();
00049
00050 PlainObjectType::Map(ptr, InnerStride<>(i)).setZero();
00051 PlainObjectType::MapAligned(ptr, InnerStride<>(i)).setZero();
00052 PlainObjectType::Map(const_ptr, InnerStride<>(i)).sum();
00053 PlainObjectType::MapAligned(const_ptr, InnerStride<>(i)).sum();
00054
00055 PlainObjectType::Map(ptr, InnerStride<2>()).setZero();
00056 PlainObjectType::MapAligned(ptr, InnerStride<3>()).setZero();
00057 PlainObjectType::Map(const_ptr, InnerStride<4>()).sum();
00058 PlainObjectType::MapAligned(const_ptr, InnerStride<5>()).sum();
00059
00060 PlainObjectType::Map(ptr, OuterStride<>(i)).setZero();
00061 PlainObjectType::MapAligned(ptr, OuterStride<>(i)).setZero();
00062 PlainObjectType::Map(const_ptr, OuterStride<>(i)).sum();
00063 PlainObjectType::MapAligned(const_ptr, OuterStride<>(i)).sum();
00064
00065 PlainObjectType::Map(ptr, OuterStride<2>()).setZero();
00066 PlainObjectType::MapAligned(ptr, OuterStride<3>()).setZero();
00067 PlainObjectType::Map(const_ptr, OuterStride<4>()).sum();
00068 PlainObjectType::MapAligned(const_ptr, OuterStride<5>()).sum();
00069
00070 PlainObjectType::Map(ptr, Stride<Dynamic, Dynamic>(i,j)).setZero();
00071 PlainObjectType::MapAligned(ptr, Stride<2,Dynamic>(2,i)).setZero();
00072 PlainObjectType::Map(const_ptr, Stride<Dynamic,3>(i,3)).sum();
00073 PlainObjectType::MapAligned(const_ptr, Stride<Dynamic, Dynamic>(i,j)).sum();
00074
00075 PlainObjectType::Map(ptr, Stride<2,3>()).setZero();
00076 PlainObjectType::MapAligned(ptr, Stride<3,4>()).setZero();
00077 PlainObjectType::Map(const_ptr, Stride<2,4>()).sum();
00078 PlainObjectType::MapAligned(const_ptr, Stride<5,3>()).sum();
00079 }
00080 };
00081
00082 template<typename PlainObjectType>
00083 struct mapstaticmethods_impl<PlainObjectType, true, false>
00084 {
00085 static void run(const PlainObjectType& m)
00086 {
00087 int rows = m.rows(), cols = m.cols();
00088
00089 int i = internal::random<int>(2,5), j = internal::random<int>(2,5);
00090
00091 PlainObjectType::Map(ptr, rows, cols).setZero();
00092 PlainObjectType::MapAligned(ptr, rows, cols).setZero();
00093 PlainObjectType::Map(const_ptr, rows, cols).sum();
00094 PlainObjectType::MapAligned(const_ptr, rows, cols).sum();
00095
00096 PlainObjectType::Map(ptr, rows, cols, InnerStride<>(i)).setZero();
00097 PlainObjectType::MapAligned(ptr, rows, cols, InnerStride<>(i)).setZero();
00098 PlainObjectType::Map(const_ptr, rows, cols, InnerStride<>(i)).sum();
00099 PlainObjectType::MapAligned(const_ptr, rows, cols, InnerStride<>(i)).sum();
00100
00101 PlainObjectType::Map(ptr, rows, cols, InnerStride<2>()).setZero();
00102 PlainObjectType::MapAligned(ptr, rows, cols, InnerStride<3>()).setZero();
00103 PlainObjectType::Map(const_ptr, rows, cols, InnerStride<4>()).sum();
00104 PlainObjectType::MapAligned(const_ptr, rows, cols, InnerStride<5>()).sum();
00105
00106 PlainObjectType::Map(ptr, rows, cols, OuterStride<>(i)).setZero();
00107 PlainObjectType::MapAligned(ptr, rows, cols, OuterStride<>(i)).setZero();
00108 PlainObjectType::Map(const_ptr, rows, cols, OuterStride<>(i)).sum();
00109 PlainObjectType::MapAligned(const_ptr, rows, cols, OuterStride<>(i)).sum();
00110
00111 PlainObjectType::Map(ptr, rows, cols, OuterStride<2>()).setZero();
00112 PlainObjectType::MapAligned(ptr, rows, cols, OuterStride<3>()).setZero();
00113 PlainObjectType::Map(const_ptr, rows, cols, OuterStride<4>()).sum();
00114 PlainObjectType::MapAligned(const_ptr, rows, cols, OuterStride<5>()).sum();
00115
00116 PlainObjectType::Map(ptr, rows, cols, Stride<Dynamic, Dynamic>(i,j)).setZero();
00117 PlainObjectType::MapAligned(ptr, rows, cols, Stride<2,Dynamic>(2,i)).setZero();
00118 PlainObjectType::Map(const_ptr, rows, cols, Stride<Dynamic,3>(i,3)).sum();
00119 PlainObjectType::MapAligned(const_ptr, rows, cols, Stride<Dynamic, Dynamic>(i,j)).sum();
00120
00121 PlainObjectType::Map(ptr, rows, cols, Stride<2,3>()).setZero();
00122 PlainObjectType::MapAligned(ptr, rows, cols, Stride<3,4>()).setZero();
00123 PlainObjectType::Map(const_ptr, rows, cols, Stride<2,4>()).sum();
00124 PlainObjectType::MapAligned(const_ptr, rows, cols, Stride<5,3>()).sum();
00125 }
00126 };
00127
00128 template<typename PlainObjectType>
00129 struct mapstaticmethods_impl<PlainObjectType, true, true>
00130 {
00131 static void run(const PlainObjectType& v)
00132 {
00133 int size = v.size();
00134
00135 int i = internal::random<int>(2,5);
00136
00137 PlainObjectType::Map(ptr, size).setZero();
00138 PlainObjectType::MapAligned(ptr, size).setZero();
00139 PlainObjectType::Map(const_ptr, size).sum();
00140 PlainObjectType::MapAligned(const_ptr, size).sum();
00141
00142 PlainObjectType::Map(ptr, size, InnerStride<>(i)).setZero();
00143 PlainObjectType::MapAligned(ptr, size, InnerStride<>(i)).setZero();
00144 PlainObjectType::Map(const_ptr, size, InnerStride<>(i)).sum();
00145 PlainObjectType::MapAligned(const_ptr, size, InnerStride<>(i)).sum();
00146
00147 PlainObjectType::Map(ptr, size, InnerStride<2>()).setZero();
00148 PlainObjectType::MapAligned(ptr, size, InnerStride<3>()).setZero();
00149 PlainObjectType::Map(const_ptr, size, InnerStride<4>()).sum();
00150 PlainObjectType::MapAligned(const_ptr, size, InnerStride<5>()).sum();
00151 }
00152 };
00153
00154 template<typename PlainObjectType>
00155 void mapstaticmethods(const PlainObjectType& m)
00156 {
00157 mapstaticmethods_impl<PlainObjectType>::run(m);
00158 VERIFY(true);
00159 }
00160
00161 void test_mapstaticmethods()
00162 {
00163 ptr = internal::aligned_new<float>(1000);
00164 for(int i = 0; i < 1000; i++) ptr[i] = float(i);
00165
00166 const_ptr = ptr;
00167
00168 CALL_SUBTEST_1(( mapstaticmethods(Matrix<float, 1, 1>()) ));
00169 CALL_SUBTEST_1(( mapstaticmethods(Vector2f()) ));
00170 CALL_SUBTEST_2(( mapstaticmethods(Vector3f()) ));
00171 CALL_SUBTEST_2(( mapstaticmethods(Matrix2f()) ));
00172 CALL_SUBTEST_3(( mapstaticmethods(Matrix4f()) ));
00173 CALL_SUBTEST_3(( mapstaticmethods(Array4f()) ));
00174 CALL_SUBTEST_4(( mapstaticmethods(Array3f()) ));
00175 CALL_SUBTEST_4(( mapstaticmethods(Array33f()) ));
00176 CALL_SUBTEST_5(( mapstaticmethods(Array44f()) ));
00177 CALL_SUBTEST_5(( mapstaticmethods(VectorXf(1)) ));
00178 CALL_SUBTEST_5(( mapstaticmethods(VectorXf(8)) ));
00179 CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(1,1)) ));
00180 CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(5,7)) ));
00181 CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(1)) ));
00182 CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(5)) ));
00183 CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(1,1)) ));
00184 CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(8,6)) ));
00185
00186 internal::aligned_delete(ptr, 1000);
00187 }
00188