MCPcopy
hub / github.com/mne-tools/mne-python / fast_cross_3d

Function fast_cross_3d

mne/surface.py:335–367  ·  view source on GitHub ↗

Compute cross product between list of 3D vectors. Much faster than np.cross() when the number of cross products becomes large (>= 500). This is because np.cross() methods become less memory efficient at this stage. Parameters ---------- x : array Input array 1, shap

(x, y)

Source from the content-addressed store, hash-verified

333
334
335def fast_cross_3d(x, y):
336 """Compute cross product between list of 3D vectors.
337
338 Much faster than np.cross() when the number of cross products
339 becomes large (>= 500). This is because np.cross() methods become
340 less memory efficient at this stage.
341
342 Parameters
343 ----------
344 x : array
345 Input array 1, shape (..., 3).
346 y : array
347 Input array 2, shape (..., 3).
348
349 Returns
350 -------
351 z : array, shape (..., 3)
352 Cross product of x and y along the last dimension.
353
354 Notes
355 -----
356 x and y must broadcast against each other.
357 """
358 assert x.ndim >= 1
359 assert y.ndim >= 1
360 assert x.shape[-1] == 3
361 assert y.shape[-1] == 3
362 if max(x.size, y.size) >= 500:
363 out = np.empty(np.broadcast(x, y).shape)
364 _jit_cross(out, x, y)
365 return out
366 else:
367 return np.cross(x, y)
368
369
370@jit()

Callers 6

test_fast_cross_3dFunction · 0.90
split_labelFunction · 0.85
complete_surface_infoFunction · 0.85
_get_tri_supp_geomFunction · 0.85

Calls 1

_jit_crossFunction · 0.85

Tested by 1

test_fast_cross_3dFunction · 0.72