HyperGP.tensor.sqrt#
- sqrt(x)[source]#
Compute the non-negative square-root of the array elements, elementwise.
- Parameters:
x (Tensor or array_like) – Elements to compute the non-negative square-root.
- Returns:
the elementwise non-negative square-root of an array.
- Return type:
ret(Tensor)
Examples
import modules
>>> import numpy as np >>> from HyperGP import Tensor >>> import time
array initialization
>>> x1 = np.random.uniform(-1, 1, size=(500, 100000)) >>> x1_t = Tensor(x1)
runtime test
>>> st = time.time() >>> ar = [np.sqrt(x1) for i in range(10)] >>> print("numpy runtime: ", time.time() - st)
>>> st = time.time() >>> ar = [HyperGP.sqrt(x1_t) for i in range(10)] >>> print("HyperGP runtime: ", time.time() - st)
broadcast operation
>>> ar = [np.sqrt(x, axis=1) for i in range(10)] >>> ar = [HyperGP.sqrt(x, dim=1) for i in range(10)] >>> for x in ar: ... x.wait()