MCPcopy Create free account
hub / github.com/abess-team/abess / test_constants

Function test_constants

python/include/unsupported/test/cxx11_tensor_expr.cpp:164–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164static void test_constants()
165{
166 Tensor<float, 3> mat1(2,3,7);
167 Tensor<float, 3> mat2(2,3,7);
168 Tensor<float, 3> mat3(2,3,7);
169
170 float val = 1.0f;
171 for (int i = 0; i < 2; ++i) {
172 for (int j = 0; j < 3; ++j) {
173 for (int k = 0; k < 7; ++k) {
174 mat1(i,j,k) = val;
175 val += 1.0f;
176 }
177 }
178 }
179 mat2 = mat1.constant(3.14f);
180 mat3 = mat1.cwiseMax(7.3f).exp();
181
182 val = 1.0f;
183 for (int i = 0; i < 2; ++i) {
184 for (int j = 0; j < 3; ++j) {
185 for (int k = 0; k < 7; ++k) {
186 VERIFY_IS_APPROX(mat2(i,j,k), 3.14f);
187 VERIFY_IS_APPROX(mat3(i,j,k), expf((std::max)(val, 7.3f)));
188 val += 1.0f;
189 }
190 }
191 }
192}
193
194static void test_boolean()
195{

Callers 1

test_cxx11_tensor_exprFunction · 0.85

Calls 3

constantMethod · 0.80
cwiseMaxMethod · 0.80
expMethod · 0.45

Tested by

no test coverage detected