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

Function af_skew

src/api/c/transform.cpp:259–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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,
261 const af_interp_type method, const bool inverse) {
262 try {
263 float tx = std::tan(skew0);
264 float ty = std::tan(skew1);
265
266 float trans_mat[6] = {1, 0, 0, 0, 1, 0};
267 trans_mat[1] = ty;
268 trans_mat[3] = tx;
269
270 if (inverse) {
271 if (tx == 0 || ty == 0) {
272 trans_mat[1] = tx;
273 trans_mat[3] = ty;
274 } else {
275 // calc_tranform_inverse(trans_mat);
276 // short cut of calc_transform_inverse
277 float d = 1.0f / (1.0f - tx * ty);
278 trans_mat[0] = d;
279 trans_mat[1] = ty * d;
280 trans_mat[3] = tx * d;
281 trans_mat[4] = d;
282 }
283 }
284 const dim4 tdims(3, 2, 1, 1);
285 af_array t = 0;
286 AF_CHECK(
287 af_create_array(&t, trans_mat, tdims.ndims(), tdims.get(), f32));
288 AF_CHECK(af_transform(out, in, t, odim0, odim1, method, true));
289 AF_CHECK(af_release_array(t));
290 }
291 CATCHALL;
292
293 return AF_SUCCESS;
294}

Callers 1

skewFunction · 0.50

Calls 6

tanFunction · 0.85
af_create_arrayFunction · 0.70
af_transformFunction · 0.70
af_release_arrayFunction · 0.70
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected