taichi.lang.ops

Module Contents

Functions

cast(obj, dtype)

bit_cast(obj, dtype)

sin(a)

The sine function.

cos(a)

The cosine function.

asin(a)

The inverses function of sine.

acos(a)

The inverses function of cosine.

sqrt(a)

The square root function.

rsqrt(a)

The reciprocal of the square root function.

round(a)

The round function.

floor(a)

The floor function.

ceil(a)

The ceil function.

tan(a)

The tangent function.

tanh(a)

The hyperbolic tangent function.

exp(a)

The exp function.

log(a)

The natural logarithm function.

random(dtype=float)

The random function.

atan2(a, b)

The inverses of the tangent function.

raw_div(a, b)

Raw_div function.

raw_mod(a, b)

Raw_mod function. Both a and b can be float.

bit_shr(a, b)

Compute bitwise shift right (in taichi scope)

select(cond, a, b)

atomic_add(a, b)

atomic_sub(a, b)

atomic_min(a, b)

atomic_max(a, b)

atomic_and(a, b)

atomic_or(a, b)

atomic_xor(a, b)

max(*args)

min(*args)

taichi.lang.ops.cast(obj, dtype)
taichi.lang.ops.bit_cast(obj, dtype)
taichi.lang.ops.sin(a)

The sine function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

Sine of a.

taichi.lang.ops.cos(a)

The cosine function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

Cosine of a.

taichi.lang.ops.asin(a)

The inverses function of sine.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix with elements in [-1,1].

Returns

The inverses function of sine of a.

taichi.lang.ops.acos(a)

The inverses function of cosine.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix with elements in [-1,1].

Returns

The inverses function of cosine of a.

taichi.lang.ops.sqrt(a)

The square root function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix with elements not less than zero.

Returns

x such that x>=0 and x^2=a.

taichi.lang.ops.rsqrt(a)

The reciprocal of the square root function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

The reciprocal of sqrt(a).

taichi.lang.ops.round(a)

The round function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

The nearest integer of a.

taichi.lang.ops.floor(a)

The floor function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

The greatest integer less than or equal to a.

taichi.lang.ops.ceil(a)

The ceil function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

The least integer greater than or equal to a.

taichi.lang.ops.tan(a)

The tangent function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

Tangent of a.

taichi.lang.ops.tanh(a)

The hyperbolic tangent function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

(e**x - e**(-x)) / (e**x + e**(-x)).

taichi.lang.ops.exp(a)

The exp function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix.

Returns

e to the a.

taichi.lang.ops.log(a)

The natural logarithm function.

Parameters

a (Union[Expr, Matrix]) – A number or a matrix with elements greater than zero.

Returns

The natural logarithm of a.

taichi.lang.ops.random(dtype=float)

The random function.

Parameters

dtype (DataType) – Type of the random variable.

Returns

A random variable whose type is dtype.

taichi.lang.ops.atan2(a, b)

The inverses of the tangent function.

Parameters
  • a (Union[Expr, Matrix]) – A number or a matrix.

  • b (Union[Expr, Matrix]) – A number or a matrix with elements not equal to zero.

Returns

The inverses function of tangent of b/a.

taichi.lang.ops.raw_div(a, b)

Raw_div function.

Parameters
  • a (Union[Expr, Matrix]) – A number or a matrix.

  • b (Union[Expr, Matrix]) – A number or a matrix with elements not equal to zero.

Returns

If a is a int and b is a int, then return a//b. Else return a/b.

taichi.lang.ops.raw_mod(a, b)

Raw_mod function. Both a and b can be float.

Parameters
  • a (Union[Expr, Matrix]) – A number or a matrix.

  • b (Union[Expr, Matrix]) – A number or a matrix with elements not equal to zero.

Returns

The remainder of a divided by b.

taichi.lang.ops.bit_shr(a, b)

Compute bitwise shift right (in taichi scope)

Parameters
Returns

LHS >> RHS

Return type

Union[Expr, int]

taichi.lang.ops.select(cond, a, b)
taichi.lang.ops.atomic_add(a, b)
taichi.lang.ops.atomic_sub(a, b)
taichi.lang.ops.atomic_min(a, b)
taichi.lang.ops.atomic_max(a, b)
taichi.lang.ops.atomic_and(a, b)
taichi.lang.ops.atomic_or(a, b)
taichi.lang.ops.atomic_xor(a, b)
taichi.lang.ops.max(*args)
taichi.lang.ops.min(*args)