taichi.lang.ops

Module Contents

Functions

stack_info()

is_taichi_expr(a)

wrap_if_not_expr(a)

unary(foo)

binary(foo)

ternary(foo)

writeback_binary(foo)

cast(obj, dtype)

bit_cast(obj, dtype)

neg(a)

The negate function.

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.

abs(a)

The absolute value function.

bit_not(a)

The bit not function.

logical_not(a)

The logical not function.

random(dtype=float)

The random function.

add(a, b)

The add function.

sub(a, b)

The sub function.

mul(a, b)

The multiply function.

mod(a, b)

The remainder function.

pow(a, b)

The power function.

floordiv(a, b)

The floor division function.

truediv(a, b)

True division function.

max(a, b)

The maxnimum function.

min(a, b)

The minimum 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.

cmp_lt(a, b)

Compare two values (less than)

cmp_le(a, b)

Compare two values (less than or equal to)

cmp_gt(a, b)

Compare two values (greater than)

cmp_ge(a, b)

Compare two values (greater than or equal to)

cmp_eq(a, b)

Compare two values (equal to)

cmp_ne(a, b)

Compare two values (not equal to)

bit_or(a, b)

Computes bitwise-or

bit_and(a, b)

Compute bitwise-and

bit_xor(a, b)

Compute bitwise-xor

bit_shl(a, b)

Compute bitwise shift left

bit_sar(a, b)

Compute bitwise shift right

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)

assign(a, b)

ti_max(*args)

ti_min(*args)

ti_any(a)

ti_all(a)

Attributes

unary_ops

binary_ops

ternary_ops

writeback_binary_ops

logical_or

logical_and

taichi.lang.ops.unary_ops = []
taichi.lang.ops.stack_info()
taichi.lang.ops.is_taichi_expr(a)
taichi.lang.ops.wrap_if_not_expr(a)
taichi.lang.ops.unary(foo)
taichi.lang.ops.binary_ops = []
taichi.lang.ops.binary(foo)
taichi.lang.ops.ternary_ops = []
taichi.lang.ops.ternary(foo)
taichi.lang.ops.writeback_binary_ops = []
taichi.lang.ops.writeback_binary(foo)
taichi.lang.ops.cast(obj, dtype)
taichi.lang.ops.bit_cast(obj, dtype)
taichi.lang.ops.neg(a)

The negate function.

Parameters

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

Returns

The negative value of a.

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.abs(a)

The absolute value function.

Parameters

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

Returns

The absolute value of a.

taichi.lang.ops.bit_not(a)

The bit not function.

Parameters

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

Returns

Bitwise not of a.

taichi.lang.ops.logical_not(a)

The logical not function.

Parameters

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

Returns

1 iff a=0, otherwise 0.

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.add(a, b)

The add function.

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

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

Returns

sum of a and b.

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

The sub function.

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

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

Returns

a subtract b.

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

The multiply function.

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

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

Returns

a multiplied by b.

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

The remainder 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 remainder of a divided by b.

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

The power function.

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

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

Returns

a to the b.

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

The floor division 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 floor function of a divided by b.

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

True division 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 true value of a divided by b.

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

The maxnimum function.

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

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

Returns

The maxnimum of a and b.

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

The minimum function.

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

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

Returns

The minimum of a and b.

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.cmp_lt(a, b)

Compare two values (less than)

Parameters
Returns

True if LHS is strictly smaller than RHS, False otherwise

Return type

Union[Expr, bool]

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

Compare two values (less than or equal to)

Parameters
Returns

True if LHS is smaller than or equal to RHS, False otherwise

Return type

Union[Expr, bool]

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

Compare two values (greater than)

Parameters
Returns

True if LHS is strictly larger than RHS, False otherwise

Return type

Union[Expr, bool]

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

Compare two values (greater than or equal to)

Parameters
Returns

True if LHS is greater than or equal to RHS, False otherwise

Return type

bool

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

Compare two values (equal to)

Parameters
Returns

True if LHS is equal to RHS, False otherwise.

Return type

Union[Expr, bool]

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

Compare two values (not equal to)

Parameters
Returns

True if LHS is not equal to RHS, False otherwise

Return type

Union[Expr, bool]

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

Computes bitwise-or

Parameters
Returns

LHS bitwise-or with RHS

Return type

Union[Expr, bool]

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

Compute bitwise-and

Parameters
Returns

LHS bitwise-and with RHS

Return type

Union[Expr, bool]

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

Compute bitwise-xor

Parameters
Returns

LHS bitwise-xor with RHS

Return type

Union[Expr, bool]

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

Compute bitwise shift left

Parameters
Returns

LHS << RHS

Return type

Union[Expr, int]

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

Compute bitwise shift right

Parameters
Returns

LHS >> RHS

Return type

Union[Expr, int]

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.logical_or
taichi.lang.ops.logical_and
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.assign(a, b)
taichi.lang.ops.ti_max(*args)
taichi.lang.ops.ti_min(*args)
taichi.lang.ops.ti_any(a)
taichi.lang.ops.ti_all(a)