MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / af_scale

Function af_scale

src/api/c/transform.cpp:215–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215af_err af_scale(af_array *out, const af_array in, const float scale0,
216 const float scale1, const dim_t odim0, const dim_t odim1,
217 const af_interp_type method) {
218 try {
219 const ArrayInfo &i_info = getInfo(in);
220 dim4 idims = i_info.dims();
221
222 dim_t _odim0 = odim0, _odim1 = odim1;
223 float sx, sy;
224
225 if (_odim0 == 0 || _odim1 == 0) {
226 DIM_ASSERT(2, scale0 != 0);
227 DIM_ASSERT(3, scale1 != 0);
228
229 sx = 1.f / scale0, sy = 1.f / scale1;
230 _odim0 = idims[0] / sx;
231 _odim1 = idims[1] / sy;
232
233 } else if (scale0 == 0 || scale1 == 0) {
234 DIM_ASSERT(4, odim0 != 0);
235 DIM_ASSERT(5, odim1 != 0);
236
237 sx = idims[0] / static_cast<float>(_odim0);
238 sy = idims[1] / static_cast<float>(_odim1);
239
240 } else {
241 sx = 1.f / scale0, sy = 1.f / scale1;
242 }
243
244 float trans_mat[6] = {1, 0, 0, 0, 1, 0};
245 trans_mat[0] = sx;
246 trans_mat[4] = sy;
247
248 const dim4 tdims(3, 2, 1, 1);
249 af_array t = 0;
250 AF_CHECK(
251 af_create_array(&t, trans_mat, tdims.ndims(), tdims.get(), f32));
252 AF_CHECK(af_transform(out, in, t, _odim0, _odim1, method, true));
253 AF_CHECK(af_release_array(t));
254 }
255 CATCHALL;
256 return AF_SUCCESS;
257}
258
259af_err af_skew(af_array *out, const af_array in, const float skew0,
260 const float skew1, const dim_t odim0, const dim_t odim1,

Callers 2

af_resizeFunction · 0.70
scaleFunction · 0.50

Calls 6

af_create_arrayFunction · 0.70
af_transformFunction · 0.70
af_release_arrayFunction · 0.70
dimsMethod · 0.45
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected