gstaichi 0.1.23.dev0__cp310-cp310-win_amd64.whl → 1.0.1__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. gstaichi/CHANGELOG.md +6 -0
  2. gstaichi/__init__.py +40 -0
  3. {taichi → gstaichi}/_funcs.py +8 -8
  4. {taichi → gstaichi}/_kernels.py +19 -19
  5. gstaichi/_lib/__init__.py +3 -0
  6. taichi/_lib/core/taichi_python.cp310-win_amd64.pyd → gstaichi/_lib/core/gstaichi_python.cp310-win_amd64.pyd +0 -0
  7. taichi/_lib/core/taichi_python.pyi → gstaichi/_lib/core/gstaichi_python.pyi +382 -522
  8. {taichi → gstaichi}/_lib/runtime/runtime_cuda.bc +0 -0
  9. {taichi → gstaichi}/_lib/runtime/runtime_x64.bc +0 -0
  10. {taichi → gstaichi}/_lib/utils.py +15 -15
  11. {taichi → gstaichi}/_logging.py +1 -1
  12. gstaichi/_snode/__init__.py +5 -0
  13. {taichi → gstaichi}/_snode/fields_builder.py +27 -29
  14. {taichi → gstaichi}/_snode/snode_tree.py +5 -5
  15. gstaichi/_test_tools/__init__.py +0 -0
  16. gstaichi/_test_tools/load_kernel_string.py +30 -0
  17. gstaichi/_version.py +1 -0
  18. {taichi → gstaichi}/_version_check.py +8 -5
  19. gstaichi/ad/__init__.py +3 -0
  20. {taichi → gstaichi}/ad/_ad.py +26 -26
  21. {taichi → gstaichi}/algorithms/_algorithms.py +7 -7
  22. {taichi → gstaichi}/examples/minimal.py +1 -1
  23. {taichi → gstaichi}/experimental.py +1 -1
  24. gstaichi/lang/__init__.py +50 -0
  25. {taichi → gstaichi}/lang/_ndarray.py +30 -26
  26. {taichi → gstaichi}/lang/_ndrange.py +8 -8
  27. gstaichi/lang/_template_mapper.py +199 -0
  28. {taichi → gstaichi}/lang/_texture.py +19 -19
  29. {taichi → gstaichi}/lang/_wrap_inspect.py +7 -7
  30. {taichi → gstaichi}/lang/any_array.py +13 -13
  31. {taichi → gstaichi}/lang/argpack.py +29 -29
  32. gstaichi/lang/ast/__init__.py +5 -0
  33. {taichi → gstaichi}/lang/ast/ast_transformer.py +94 -582
  34. {taichi → gstaichi}/lang/ast/ast_transformer_utils.py +54 -41
  35. gstaichi/lang/ast/ast_transformers/__init__.py +0 -0
  36. gstaichi/lang/ast/ast_transformers/call_transformer.py +267 -0
  37. gstaichi/lang/ast/ast_transformers/function_def_transformer.py +320 -0
  38. {taichi → gstaichi}/lang/ast/checkers.py +5 -5
  39. gstaichi/lang/ast/transform.py +9 -0
  40. {taichi → gstaichi}/lang/common_ops.py +12 -12
  41. gstaichi/lang/exception.py +80 -0
  42. {taichi → gstaichi}/lang/expr.py +22 -22
  43. {taichi → gstaichi}/lang/field.py +29 -27
  44. {taichi → gstaichi}/lang/impl.py +116 -121
  45. {taichi → gstaichi}/lang/kernel_arguments.py +16 -16
  46. {taichi → gstaichi}/lang/kernel_impl.py +330 -363
  47. {taichi → gstaichi}/lang/matrix.py +119 -115
  48. {taichi → gstaichi}/lang/matrix_ops.py +6 -6
  49. {taichi → gstaichi}/lang/matrix_ops_utils.py +4 -4
  50. {taichi → gstaichi}/lang/mesh.py +22 -22
  51. {taichi → gstaichi}/lang/misc.py +39 -68
  52. {taichi → gstaichi}/lang/ops.py +146 -141
  53. {taichi → gstaichi}/lang/runtime_ops.py +2 -2
  54. {taichi → gstaichi}/lang/shell.py +3 -3
  55. {taichi → gstaichi}/lang/simt/__init__.py +1 -1
  56. {taichi → gstaichi}/lang/simt/block.py +7 -7
  57. {taichi → gstaichi}/lang/simt/grid.py +1 -1
  58. {taichi → gstaichi}/lang/simt/subgroup.py +1 -1
  59. {taichi → gstaichi}/lang/simt/warp.py +1 -1
  60. {taichi → gstaichi}/lang/snode.py +46 -44
  61. {taichi → gstaichi}/lang/source_builder.py +13 -13
  62. {taichi → gstaichi}/lang/struct.py +33 -33
  63. {taichi → gstaichi}/lang/util.py +24 -24
  64. gstaichi/linalg/__init__.py +8 -0
  65. {taichi → gstaichi}/linalg/matrixfree_cg.py +14 -14
  66. {taichi → gstaichi}/linalg/sparse_cg.py +10 -10
  67. {taichi → gstaichi}/linalg/sparse_matrix.py +23 -23
  68. {taichi → gstaichi}/linalg/sparse_solver.py +21 -21
  69. {taichi → gstaichi}/math/__init__.py +1 -1
  70. {taichi → gstaichi}/math/_complex.py +21 -20
  71. {taichi → gstaichi}/math/mathimpl.py +56 -56
  72. gstaichi/profiler/__init__.py +6 -0
  73. {taichi → gstaichi}/profiler/kernel_metrics.py +11 -11
  74. {taichi → gstaichi}/profiler/kernel_profiler.py +30 -36
  75. {taichi → gstaichi}/profiler/memory_profiler.py +1 -1
  76. {taichi → gstaichi}/profiler/scoped_profiler.py +2 -2
  77. {taichi → gstaichi}/sparse/_sparse_grid.py +7 -7
  78. {taichi → gstaichi}/tools/__init__.py +4 -4
  79. {taichi → gstaichi}/tools/diagnose.py +10 -17
  80. gstaichi/types/__init__.py +19 -0
  81. {taichi → gstaichi}/types/annotations.py +1 -1
  82. {taichi → gstaichi}/types/compound_types.py +8 -8
  83. {taichi → gstaichi}/types/enums.py +1 -1
  84. {taichi → gstaichi}/types/ndarray_type.py +7 -7
  85. {taichi → gstaichi}/types/primitive_types.py +17 -14
  86. {taichi → gstaichi}/types/quant.py +9 -9
  87. {taichi → gstaichi}/types/texture_type.py +5 -5
  88. {taichi → gstaichi}/types/utils.py +1 -1
  89. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/bin/SPIRV-Tools-shared.dll +0 -0
  90. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-diff.lib +0 -0
  91. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-link.lib +0 -0
  92. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-lint.lib +0 -0
  93. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-opt.lib +0 -0
  94. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-reduce.lib +0 -0
  95. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-shared.lib +0 -0
  96. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools.lib +0 -0
  97. {gstaichi-0.1.23.dev0.dist-info → gstaichi-1.0.1.dist-info}/METADATA +13 -16
  98. gstaichi-1.0.1.dist-info/RECORD +135 -0
  99. gstaichi-1.0.1.dist-info/top_level.txt +1 -0
  100. gstaichi-0.1.23.dev0.data/data/include/GLFW/glfw3.h +0 -6389
  101. gstaichi-0.1.23.dev0.data/data/include/GLFW/glfw3native.h +0 -594
  102. gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3Config.cmake +0 -3
  103. gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3ConfigVersion.cmake +0 -65
  104. gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3Targets-release.cmake +0 -19
  105. gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3Targets.cmake +0 -107
  106. gstaichi-0.1.23.dev0.data/data/lib/glfw3.lib +0 -0
  107. gstaichi-0.1.23.dev0.dist-info/RECORD +0 -198
  108. gstaichi-0.1.23.dev0.dist-info/entry_points.txt +0 -2
  109. gstaichi-0.1.23.dev0.dist-info/top_level.txt +0 -1
  110. taichi/CHANGELOG.md +0 -20
  111. taichi/__init__.py +0 -44
  112. taichi/__main__.py +0 -5
  113. taichi/_lib/__init__.py +0 -3
  114. taichi/_lib/c_api/bin/taichi_c_api.dll +0 -0
  115. taichi/_lib/c_api/include/taichi/cpp/taichi.hpp +0 -1401
  116. taichi/_lib/c_api/include/taichi/taichi.h +0 -29
  117. taichi/_lib/c_api/include/taichi/taichi_core.h +0 -1111
  118. taichi/_lib/c_api/include/taichi/taichi_cpu.h +0 -29
  119. taichi/_lib/c_api/include/taichi/taichi_cuda.h +0 -36
  120. taichi/_lib/c_api/include/taichi/taichi_platform.h +0 -55
  121. taichi/_lib/c_api/include/taichi/taichi_unity.h +0 -64
  122. taichi/_lib/c_api/include/taichi/taichi_vulkan.h +0 -151
  123. taichi/_lib/c_api/lib/taichi_c_api.lib +0 -0
  124. taichi/_lib/c_api/runtime/runtime_cuda.bc +0 -0
  125. taichi/_lib/c_api/runtime/runtime_x64.bc +0 -0
  126. taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiConfig.cmake +0 -29
  127. taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiConfigVersion.cmake +0 -65
  128. taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiTargets.cmake +0 -121
  129. taichi/_lib/runtime/slim_libdevice.10.bc +0 -0
  130. taichi/_main.py +0 -552
  131. taichi/_snode/__init__.py +0 -5
  132. taichi/_ti_module/__init__.py +0 -3
  133. taichi/_ti_module/cppgen.py +0 -309
  134. taichi/_ti_module/module.py +0 -145
  135. taichi/_version.py +0 -1
  136. taichi/ad/__init__.py +0 -3
  137. taichi/aot/__init__.py +0 -12
  138. taichi/aot/_export.py +0 -28
  139. taichi/aot/conventions/__init__.py +0 -3
  140. taichi/aot/conventions/gfxruntime140/__init__.py +0 -38
  141. taichi/aot/conventions/gfxruntime140/dr.py +0 -244
  142. taichi/aot/conventions/gfxruntime140/sr.py +0 -613
  143. taichi/aot/module.py +0 -253
  144. taichi/aot/utils.py +0 -151
  145. taichi/graph/__init__.py +0 -3
  146. taichi/graph/_graph.py +0 -292
  147. taichi/lang/__init__.py +0 -50
  148. taichi/lang/ast/__init__.py +0 -5
  149. taichi/lang/ast/transform.py +0 -9
  150. taichi/lang/exception.py +0 -80
  151. taichi/linalg/__init__.py +0 -8
  152. taichi/profiler/__init__.py +0 -6
  153. taichi/shaders/Circles_vk.frag +0 -29
  154. taichi/shaders/Circles_vk.vert +0 -45
  155. taichi/shaders/Circles_vk_frag.spv +0 -0
  156. taichi/shaders/Circles_vk_vert.spv +0 -0
  157. taichi/shaders/Lines_vk.frag +0 -9
  158. taichi/shaders/Lines_vk.vert +0 -11
  159. taichi/shaders/Lines_vk_frag.spv +0 -0
  160. taichi/shaders/Lines_vk_vert.spv +0 -0
  161. taichi/shaders/Mesh_vk.frag +0 -71
  162. taichi/shaders/Mesh_vk.vert +0 -68
  163. taichi/shaders/Mesh_vk_frag.spv +0 -0
  164. taichi/shaders/Mesh_vk_vert.spv +0 -0
  165. taichi/shaders/Particles_vk.frag +0 -95
  166. taichi/shaders/Particles_vk.vert +0 -73
  167. taichi/shaders/Particles_vk_frag.spv +0 -0
  168. taichi/shaders/Particles_vk_vert.spv +0 -0
  169. taichi/shaders/SceneLines2quad_vk_comp.spv +0 -0
  170. taichi/shaders/SceneLines_vk.frag +0 -9
  171. taichi/shaders/SceneLines_vk.vert +0 -12
  172. taichi/shaders/SceneLines_vk_frag.spv +0 -0
  173. taichi/shaders/SceneLines_vk_vert.spv +0 -0
  174. taichi/shaders/SetImage_vk.frag +0 -21
  175. taichi/shaders/SetImage_vk.vert +0 -15
  176. taichi/shaders/SetImage_vk_frag.spv +0 -0
  177. taichi/shaders/SetImage_vk_vert.spv +0 -0
  178. taichi/shaders/Triangles_vk.frag +0 -16
  179. taichi/shaders/Triangles_vk.vert +0 -29
  180. taichi/shaders/Triangles_vk_frag.spv +0 -0
  181. taichi/shaders/Triangles_vk_vert.spv +0 -0
  182. taichi/shaders/lines2quad_vk_comp.spv +0 -0
  183. taichi/types/__init__.py +0 -19
  184. {taichi → gstaichi}/_lib/core/__init__.py +0 -0
  185. {taichi → gstaichi}/_lib/core/py.typed +0 -0
  186. {taichi/_lib/c_api → gstaichi/_lib}/runtime/slim_libdevice.10.bc +0 -0
  187. {taichi → gstaichi}/algorithms/__init__.py +0 -0
  188. {taichi → gstaichi}/assets/.git +0 -0
  189. {taichi → gstaichi}/assets/Go-Regular.ttf +0 -0
  190. {taichi → gstaichi}/assets/static/imgs/ti_gallery.png +0 -0
  191. {taichi → gstaichi}/lang/ast/symbol_resolver.py +0 -0
  192. {taichi → gstaichi}/sparse/__init__.py +0 -0
  193. {taichi → gstaichi}/tools/np2ply.py +0 -0
  194. {taichi → gstaichi}/tools/vtk.py +0 -0
  195. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools/cmake/SPIRV-ToolsConfig.cmake +0 -0
  196. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget-release.cmake +0 -0
  197. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget.cmake +0 -0
  198. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffConfig.cmake +0 -0
  199. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets-release.cmake +0 -0
  200. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets.cmake +0 -0
  201. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkConfig.cmake +0 -0
  202. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets-release.cmake +0 -0
  203. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets.cmake +0 -0
  204. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintConfig.cmake +0 -0
  205. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets-release.cmake +0 -0
  206. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets.cmake +0 -0
  207. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optConfig.cmake +0 -0
  208. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets-release.cmake +0 -0
  209. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets.cmake +0 -0
  210. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceConfig.cmake +0 -0
  211. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget-release.cmake +0 -0
  212. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget.cmake +0 -0
  213. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/instrument.hpp +0 -0
  214. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/libspirv.h +0 -0
  215. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/libspirv.hpp +0 -0
  216. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/linker.hpp +0 -0
  217. {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/optimizer.hpp +0 -0
  218. {gstaichi-0.1.23.dev0.dist-info → gstaichi-1.0.1.dist-info}/WHEEL +0 -0
  219. {gstaichi-0.1.23.dev0.dist-info → gstaichi-1.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -8,10 +8,10 @@ import warnings
8
8
  import numpy as np
9
9
  from colorama import Fore, Style
10
10
 
11
- from taichi._lib import core as _ti_core
12
- from taichi._logging import is_logging_effective
13
- from taichi.lang import impl
14
- from taichi.types.primitive_types import (
11
+ from gstaichi._lib import core as _ti_core
12
+ from gstaichi._logging import is_logging_effective
13
+ from gstaichi.lang import impl
14
+ from gstaichi.types.primitive_types import (
15
15
  f16,
16
16
  f32,
17
17
  f64,
@@ -67,7 +67,7 @@ def has_paddle():
67
67
  def get_clangpp():
68
68
  from distutils.spawn import find_executable # pylint: disable=C0415
69
69
 
70
- # Taichi itself uses llvm-10.0.0 to compile.
70
+ # GsTaichi itself uses llvm-10.0.0 to compile.
71
71
  # There will be some issues compiling CUDA with other clang++ version.
72
72
  _clangpp_candidates = ["clang++-10"]
73
73
  for c in _clangpp_candidates:
@@ -91,18 +91,18 @@ def is_matrix_class(rhs):
91
91
  return matrix_class
92
92
 
93
93
 
94
- def is_taichi_class(rhs):
95
- taichi_class = False
94
+ def is_gstaichi_class(rhs):
95
+ gstaichi_class = False
96
96
  try:
97
- if rhs._is_taichi_class:
98
- taichi_class = True
97
+ if rhs._is_gstaichi_class:
98
+ gstaichi_class = True
99
99
  except:
100
100
  pass
101
- return taichi_class
101
+ return gstaichi_class
102
102
 
103
103
 
104
104
  def to_numpy_type(dt):
105
- """Convert taichi data type to its counterpart in numpy.
105
+ """Convert gstaichi data type to its counterpart in numpy.
106
106
 
107
107
  Args:
108
108
  dt (DataType): The desired data type to convert.
@@ -139,7 +139,7 @@ def to_numpy_type(dt):
139
139
 
140
140
 
141
141
  def to_pytorch_type(dt):
142
- """Convert taichi data type to its counterpart in torch.
142
+ """Convert gstaichi data type to its counterpart in torch.
143
143
 
144
144
  Args:
145
145
  dt (DataType): The desired data type to convert.
@@ -184,7 +184,7 @@ def to_pytorch_type(dt):
184
184
 
185
185
 
186
186
  def to_paddle_type(dt):
187
- """Convert taichi data type to its counterpart in paddle.
187
+ """Convert gstaichi data type to its counterpart in paddle.
188
188
 
189
189
  Args:
190
190
  dt (DataType): The desired data type to convert.
@@ -218,17 +218,17 @@ def to_paddle_type(dt):
218
218
  assert False
219
219
 
220
220
 
221
- def to_taichi_type(dt):
222
- """Convert numpy or torch or paddle data type to its counterpart in taichi.
221
+ def to_gstaichi_type(dt):
222
+ """Convert numpy or torch or paddle data type to its counterpart in gstaichi.
223
223
 
224
224
  Args:
225
225
  dt (DataType): The desired data type to convert.
226
226
 
227
227
  Returns:
228
- DataType: The counterpart data type in taichi.
228
+ DataType: The counterpart data type in gstaichi.
229
229
 
230
230
  """
231
- if type(dt) == _ti_core.DataType:
231
+ if type(dt) == _ti_core.DataTypeCxx:
232
232
  return dt
233
233
 
234
234
  if dt == np.float32:
@@ -317,10 +317,10 @@ def to_taichi_type(dt):
317
317
 
318
318
 
319
319
  def cook_dtype(dtype):
320
- if isinstance(dtype, _ti_core.DataType):
320
+ if isinstance(dtype, _ti_core.DataTypeCxx):
321
321
  return dtype
322
322
  if isinstance(dtype, _ti_core.Type):
323
- return _ti_core.DataType(dtype)
323
+ return _ti_core.DataTypeCxx(dtype)
324
324
  if dtype is float:
325
325
  return impl.get_runtime().default_fp
326
326
  if dtype is int:
@@ -330,18 +330,18 @@ def cook_dtype(dtype):
330
330
  raise ValueError(f"Invalid data type {dtype}")
331
331
 
332
332
 
333
- def in_taichi_scope():
333
+ def in_gstaichi_scope():
334
334
  return impl.inside_kernel()
335
335
 
336
336
 
337
337
  def in_python_scope():
338
- return not in_taichi_scope()
338
+ return not in_gstaichi_scope()
339
339
 
340
340
 
341
- def taichi_scope(func):
341
+ def gstaichi_scope(func):
342
342
  @functools.wraps(func)
343
343
  def wrapped(*args, **kwargs):
344
- assert in_taichi_scope(), f"{func.__name__} cannot be called in Python-scope"
344
+ assert in_gstaichi_scope(), f"{func.__name__} cannot be called in Python-scope"
345
345
  return func(*args, **kwargs)
346
346
 
347
347
  return wrapped
@@ -350,7 +350,7 @@ def taichi_scope(func):
350
350
  def python_scope(func):
351
351
  @functools.wraps(func)
352
352
  def wrapped(*args, **kwargs):
353
- assert in_python_scope(), f"{func.__name__} cannot be called in Taichi-scope"
353
+ assert in_python_scope(), f"{func.__name__} cannot be called in GsTaichi-scope"
354
354
  return func(*args, **kwargs)
355
355
 
356
356
  return wrapped
@@ -0,0 +1,8 @@
1
+ # type: ignore
2
+
3
+ """GsTaichi support module for sparse matrix operations."""
4
+
5
+ from gstaichi.linalg.matrixfree_cg import *
6
+ from gstaichi.linalg.sparse_cg import SparseCG
7
+ from gstaichi.linalg.sparse_matrix import *
8
+ from gstaichi.linalg.sparse_solver import SparseSolver
@@ -2,11 +2,11 @@
2
2
 
3
3
  from math import sqrt
4
4
 
5
- from taichi.lang import misc
6
- from taichi.lang.exception import TaichiRuntimeError, TaichiTypeError
7
- from taichi.lang.impl import FieldsBuilder, field, grouped
8
- from taichi.lang.kernel_impl import data_oriented, kernel
9
- from taichi.types import primitive_types, template
5
+ from gstaichi.lang import misc
6
+ from gstaichi.lang.exception import GsTaichiRuntimeError, GsTaichiTypeError
7
+ from gstaichi.lang.impl import FieldsBuilder, field, grouped
8
+ from gstaichi.lang.kernel_impl import data_oriented, kernel
9
+ from gstaichi.types import primitive_types, template
10
10
 
11
11
 
12
12
  @data_oriented
@@ -16,7 +16,7 @@ class LinearOperator:
16
16
 
17
17
  def matvec(self, x, Ax):
18
18
  if x.shape != Ax.shape:
19
- raise TaichiRuntimeError(f"Dimension mismatch x.shape{x.shape} != Ax.shape{Ax.shape}.")
19
+ raise GsTaichiRuntimeError(f"Dimension mismatch x.shape{x.shape} != Ax.shape{Ax.shape}.")
20
20
  self._matvec(x, Ax)
21
21
 
22
22
 
@@ -36,15 +36,15 @@ def MatrixFreeCG(A, b, x, tol=1e-6, maxiter=5000, quiet=True):
36
36
  """
37
37
 
38
38
  if b.dtype != x.dtype:
39
- raise TaichiTypeError(f"Dtype mismatch b.dtype({b.dtype}) != x.dtype({x.dtype}).")
39
+ raise GsTaichiTypeError(f"Dtype mismatch b.dtype({b.dtype}) != x.dtype({x.dtype}).")
40
40
  if str(b.dtype) == "f32":
41
41
  solver_dtype = primitive_types.f32
42
42
  elif str(b.dtype) == "f64":
43
43
  solver_dtype = primitive_types.f64
44
44
  else:
45
- raise TaichiTypeError(f"Not supported dtype: {b.dtype}")
45
+ raise GsTaichiTypeError(f"Not supported dtype: {b.dtype}")
46
46
  if b.shape != x.shape:
47
- raise TaichiRuntimeError(f"Dimension mismatch b.shape{b.shape} != x.shape{x.shape}.")
47
+ raise GsTaichiRuntimeError(f"Dimension mismatch b.shape{b.shape} != x.shape{x.shape}.")
48
48
 
49
49
  size = b.shape
50
50
  vector_fields_builder = FieldsBuilder()
@@ -59,7 +59,7 @@ def MatrixFreeCG(A, b, x, tol=1e-6, maxiter=5000, quiet=True):
59
59
  elif len(size) == 3:
60
60
  axes = misc.ijk
61
61
  else:
62
- raise TaichiRuntimeError(f"MatrixFreeCG only support 1D, 2D, 3D inputs; your inputs is {len(size)}-D.")
62
+ raise GsTaichiRuntimeError(f"MatrixFreeCG only support 1D, 2D, 3D inputs; your inputs is {len(size)}-D.")
63
63
  vector_fields_builder.dense(axes, size).place(p, r, Ap, Ax)
64
64
  vector_fields_snode_tree = vector_fields_builder.finalize()
65
65
 
@@ -157,15 +157,15 @@ def MatrixFreeBICGSTAB(A, b, x, tol=1e-6, maxiter=5000, quiet=True):
157
157
  """
158
158
 
159
159
  if b.dtype != x.dtype:
160
- raise TaichiTypeError(f"Dtype mismatch b.dtype({b.dtype}) != x.dtype({x.dtype}).")
160
+ raise GsTaichiTypeError(f"Dtype mismatch b.dtype({b.dtype}) != x.dtype({x.dtype}).")
161
161
  if str(b.dtype) == "f32":
162
162
  solver_dtype = primitive_types.f32
163
163
  elif str(b.dtype) == "f64":
164
164
  solver_dtype = primitive_types.f64
165
165
  else:
166
- raise TaichiTypeError(f"Not supported dtype: {b.dtype}")
166
+ raise GsTaichiTypeError(f"Not supported dtype: {b.dtype}")
167
167
  if b.shape != x.shape:
168
- raise TaichiRuntimeError(f"Dimension mismatch b.shape{b.shape} != x.shape{x.shape}.")
168
+ raise GsTaichiRuntimeError(f"Dimension mismatch b.shape{b.shape} != x.shape{x.shape}.")
169
169
 
170
170
  size = b.shape
171
171
  vector_fields_builder = FieldsBuilder()
@@ -186,7 +186,7 @@ def MatrixFreeBICGSTAB(A, b, x, tol=1e-6, maxiter=5000, quiet=True):
186
186
  elif len(size) == 3:
187
187
  axes = misc.ijk
188
188
  else:
189
- raise TaichiRuntimeError(f"MatrixFreeBICGSTAB only support 1D, 2D, 3D inputs; your inputs is {len(size)}-D.")
189
+ raise GsTaichiRuntimeError(f"MatrixFreeBICGSTAB only support 1D, 2D, 3D inputs; your inputs is {len(size)}-D.")
190
190
  vector_fields_builder.dense(axes, size).place(p, p_hat, r, r_tld, s, s_hat, t, Ap, Ax, Ashat)
191
191
  vector_fields_snode_tree = vector_fields_builder.finalize()
192
192
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  import numpy as np
4
4
 
5
- from taichi._lib import core as _ti_core
6
- from taichi.lang._ndarray import Ndarray, ScalarNdarray
7
- from taichi.lang.exception import TaichiRuntimeError
8
- from taichi.lang.impl import get_runtime
9
- from taichi.types import f32, f64
5
+ from gstaichi._lib import core as _ti_core
6
+ from gstaichi.lang._ndarray import Ndarray, ScalarNdarray
7
+ from gstaichi.lang.exception import GsTaichiRuntimeError
8
+ from gstaichi.lang.impl import get_runtime
9
+ from gstaichi.types import f32, f64
10
10
 
11
11
 
12
12
  class SparseCG:
@@ -16,8 +16,8 @@ class SparseCG:
16
16
 
17
17
  Args:
18
18
  A (SparseMatrix): The coefficient matrix A of the linear system.
19
- b (numpy ndarray, taichi Ndarray): The right-hand side of the linear system.
20
- x0 (numpy ndarray, taichi Ndarray): The initial guess for the solution.
19
+ b (numpy ndarray, gstaichi Ndarray): The right-hand side of the linear system.
20
+ x0 (numpy ndarray, gstaichi Ndarray): The initial guess for the solution.
21
21
  max_iter (int): Maximum number of iterations.
22
22
  atol: Tolerance(absolute) for convergence.
23
23
  """
@@ -35,7 +35,7 @@ class SparseCG:
35
35
  elif self.dtype == f64:
36
36
  self.cg_solver = _ti_core.make_double_cg_solver(A.matrix, max_iter, atol, True)
37
37
  else:
38
- raise TaichiRuntimeError(f"Unsupported CG dtype: {self.dtype}")
38
+ raise GsTaichiRuntimeError(f"Unsupported CG dtype: {self.dtype}")
39
39
  if isinstance(b, Ndarray):
40
40
  self.cg_solver.set_b_ndarray(get_runtime().prog, b.arr)
41
41
  elif isinstance(b, np.ndarray):
@@ -45,7 +45,7 @@ class SparseCG:
45
45
  elif isinstance(x0, np.ndarray):
46
46
  self.cg_solver.set_x(x0)
47
47
  else:
48
- raise TaichiRuntimeError(f"Unsupported CG arch: {self.ti_arch}")
48
+ raise GsTaichiRuntimeError(f"Unsupported CG arch: {self.ti_arch}")
49
49
 
50
50
  def solve(self):
51
51
  if self.ti_arch == _ti_core.Arch.cuda:
@@ -53,7 +53,7 @@ class SparseCG:
53
53
  x = ScalarNdarray(self.b.dtype, [self.matrix.m])
54
54
  self.cg_solver.solve(get_runtime().prog, x.arr, self.b.arr)
55
55
  return x, True
56
- raise TaichiRuntimeError(f"Unsupported CG RHS type: {type(self.b)}")
56
+ raise GsTaichiRuntimeError(f"Unsupported CG RHS type: {type(self.b)}")
57
57
  else:
58
58
  self.cg_solver.solve()
59
59
  return self.cg_solver.get_x(), self.cg_solver.is_success()
@@ -4,16 +4,16 @@ from functools import reduce
4
4
 
5
5
  import numpy as np
6
6
 
7
- from taichi._lib import core as _ti_core
8
- from taichi.lang._ndarray import Ndarray, ScalarNdarray
9
- from taichi.lang.exception import TaichiRuntimeError
10
- from taichi.lang.field import Field
11
- from taichi.lang.impl import get_runtime
12
- from taichi.types import f32
7
+ from gstaichi._lib import core as _ti_core
8
+ from gstaichi.lang._ndarray import Ndarray, ScalarNdarray
9
+ from gstaichi.lang.exception import GsTaichiRuntimeError
10
+ from gstaichi.lang.field import Field
11
+ from gstaichi.lang.impl import get_runtime
12
+ from gstaichi.types import f32
13
13
 
14
14
 
15
15
  class SparseMatrix:
16
- """Taichi's Sparse Matrix class
16
+ """GsTaichi's Sparse Matrix class
17
17
 
18
18
  A sparse matrix allows the programmer to solve a large linear system.
19
19
 
@@ -151,13 +151,13 @@ class SparseMatrix:
151
151
  return self.matrix.mat_vec_mul(other)
152
152
  if isinstance(other, Ndarray):
153
153
  if self.m != other.shape[0]:
154
- raise TaichiRuntimeError(
154
+ raise GsTaichiRuntimeError(
155
155
  f"Dimension mismatch between sparse matrix ({self.n}, {self.m}) and vector ({other.shape})"
156
156
  )
157
157
  res = ScalarNdarray(dtype=other.dtype, arr_shape=(self.n,))
158
158
  self.matrix.spmv(get_runtime().prog, other.arr, res.arr)
159
159
  return res
160
- raise TaichiRuntimeError(
160
+ raise GsTaichiRuntimeError(
161
161
  f"Sparse matrix-matrix/vector multiplication does not support {type(other)} for now. Supported types are SparseMatrix, ti.field, and numpy ndarray."
162
162
  )
163
163
 
@@ -186,7 +186,7 @@ class SparseMatrix:
186
186
  ndarray (Union[ti.ndarray, ti.Vector.ndarray, ti.Matrix.ndarray]): the ndarray to build the sparse matrix from.
187
187
 
188
188
  Raises:
189
- TaichiRuntimeError: If the input is not a ndarray or the length is not divisible by 3.
189
+ GsTaichiRuntimeError: If the input is not a ndarray or the length is not divisible by 3.
190
190
 
191
191
  Example::
192
192
  >>> N = 5
@@ -208,10 +208,10 @@ class SparseMatrix:
208
208
  if isinstance(ndarray, Ndarray):
209
209
  num_scalars = reduce(lambda x, y: x * y, ndarray.shape + ndarray.element_shape)
210
210
  if num_scalars % 3 != 0:
211
- raise TaichiRuntimeError("The number of ndarray elements must have a length that is divisible by 3.")
211
+ raise GsTaichiRuntimeError("The number of ndarray elements must have a length that is divisible by 3.")
212
212
  get_runtime().prog.make_sparse_matrix_from_ndarray(self.matrix, ndarray.arr)
213
213
  else:
214
- raise TaichiRuntimeError(
214
+ raise GsTaichiRuntimeError(
215
215
  "Sparse matrix only supports building from [ti.ndarray, ti.Vector.ndarray, ti.Matrix.ndarray]"
216
216
  )
217
217
 
@@ -249,8 +249,8 @@ class SparseMatrixBuilder:
249
249
  self.num_cols = num_cols if num_cols else num_rows
250
250
  self.dtype = dtype
251
251
  if num_rows is not None:
252
- taichi_arch = get_runtime().prog.config().arch
253
- if taichi_arch in [
252
+ gstaichi_arch = get_runtime().prog.config().arch
253
+ if gstaichi_arch in [
254
254
  _ti_core.Arch.x64,
255
255
  _ti_core.Arch.arm64,
256
256
  _ti_core.Arch.cuda,
@@ -264,7 +264,7 @@ class SparseMatrixBuilder:
264
264
  )
265
265
  self.ptr.create_ndarray(get_runtime().prog)
266
266
  else:
267
- raise TaichiRuntimeError("SparseMatrix only supports CPU and CUDA for now.")
267
+ raise GsTaichiRuntimeError("SparseMatrix only supports CPU and CUDA for now.")
268
268
 
269
269
  def _get_addr(self):
270
270
  """Get the address of the sparse matrix"""
@@ -276,24 +276,24 @@ class SparseMatrixBuilder:
276
276
 
277
277
  def print_triplets(self):
278
278
  """Print the triplets stored in the builder"""
279
- taichi_arch = get_runtime().prog.config().arch
280
- if taichi_arch in [_ti_core.Arch.x64, _ti_core.Arch.arm64]:
279
+ gstaichi_arch = get_runtime().prog.config().arch
280
+ if gstaichi_arch in [_ti_core.Arch.x64, _ti_core.Arch.arm64]:
281
281
  self.ptr.print_triplets_eigen()
282
- elif taichi_arch == _ti_core.Arch.cuda:
282
+ elif gstaichi_arch == _ti_core.Arch.cuda:
283
283
  self.ptr.print_triplets_cuda()
284
284
 
285
285
  def build(self, dtype=f32, _format="CSR"):
286
286
  """Create a sparse matrix using the triplets"""
287
- taichi_arch = get_runtime().prog.config().arch
288
- if taichi_arch in [_ti_core.Arch.x64, _ti_core.Arch.arm64]:
287
+ gstaichi_arch = get_runtime().prog.config().arch
288
+ if gstaichi_arch in [_ti_core.Arch.x64, _ti_core.Arch.arm64]:
289
289
  sm = self.ptr.build()
290
290
  return SparseMatrix(sm=sm, dtype=self.dtype)
291
- if taichi_arch == _ti_core.Arch.cuda:
291
+ if gstaichi_arch == _ti_core.Arch.cuda:
292
292
  if self.dtype != f32:
293
- raise TaichiRuntimeError("CUDA sparse matrix only supports f32.")
293
+ raise GsTaichiRuntimeError("CUDA sparse matrix only supports f32.")
294
294
  sm = self.ptr.build_cuda()
295
295
  return SparseMatrix(sm=sm, dtype=self.dtype)
296
- raise TaichiRuntimeError("Sparse matrix only supports CPU and CUDA backends.")
296
+ raise GsTaichiRuntimeError("Sparse matrix only supports CPU and CUDA backends.")
297
297
 
298
298
  def __del__(self):
299
299
  if get_runtime() is not None and get_runtime().prog is not None:
@@ -2,14 +2,14 @@
2
2
 
3
3
  import numpy as np
4
4
 
5
- import taichi.lang
6
- from taichi._lib import core as _ti_core
7
- from taichi.lang._ndarray import Ndarray, ScalarNdarray
8
- from taichi.lang.exception import TaichiRuntimeError
9
- from taichi.lang.field import Field
10
- from taichi.lang.impl import get_runtime
11
- from taichi.linalg.sparse_matrix import SparseMatrix
12
- from taichi.types.primitive_types import f32
5
+ import gstaichi.lang
6
+ from gstaichi._lib import core as _ti_core
7
+ from gstaichi.lang._ndarray import Ndarray, ScalarNdarray
8
+ from gstaichi.lang.exception import GsTaichiRuntimeError
9
+ from gstaichi.lang.field import Field
10
+ from gstaichi.lang.impl import get_runtime
11
+ from gstaichi.linalg.sparse_matrix import SparseMatrix
12
+ from gstaichi.types.primitive_types import f32
13
13
 
14
14
 
15
15
  class SparseSolver:
@@ -28,24 +28,24 @@ class SparseSolver:
28
28
  solver_type_list = ["LLT", "LDLT", "LU"]
29
29
  solver_ordering = ["AMD", "COLAMD"]
30
30
  if solver_type in solver_type_list and ordering in solver_ordering:
31
- taichi_arch = taichi.lang.impl.get_runtime().prog.config().arch
31
+ gstaichi_arch = gstaichi.lang.impl.get_runtime().prog.config().arch
32
32
  assert (
33
- taichi_arch == _ti_core.Arch.x64
34
- or taichi_arch == _ti_core.Arch.arm64
35
- or taichi_arch == _ti_core.Arch.cuda
33
+ gstaichi_arch == _ti_core.Arch.x64
34
+ or gstaichi_arch == _ti_core.Arch.arm64
35
+ or gstaichi_arch == _ti_core.Arch.cuda
36
36
  ), "SparseSolver only supports CPU and CUDA for now."
37
- if taichi_arch == _ti_core.Arch.cuda:
37
+ if gstaichi_arch == _ti_core.Arch.cuda:
38
38
  self.solver = _ti_core.make_cusparse_solver(dtype, solver_type, ordering)
39
39
  else:
40
40
  self.solver = _ti_core.make_sparse_solver(dtype, solver_type, ordering)
41
41
  else:
42
- raise TaichiRuntimeError(
42
+ raise GsTaichiRuntimeError(
43
43
  f"The solver type {solver_type} with {ordering} is not supported for now. Only {solver_type_list} with {solver_ordering} are supported."
44
44
  )
45
45
 
46
46
  @staticmethod
47
47
  def _type_assert(sparse_matrix):
48
- raise TaichiRuntimeError(
48
+ raise GsTaichiRuntimeError(
49
49
  f"The parameter type: {type(sparse_matrix)} is not supported in linear solvers for now."
50
50
  )
51
51
 
@@ -57,10 +57,10 @@ class SparseSolver:
57
57
  """
58
58
  if isinstance(sparse_matrix, SparseMatrix):
59
59
  self.matrix = sparse_matrix
60
- taichi_arch = taichi.lang.impl.get_runtime().prog.config().arch
61
- if taichi_arch == _ti_core.Arch.x64 or taichi_arch == _ti_core.Arch.arm64:
60
+ gstaichi_arch = gstaichi.lang.impl.get_runtime().prog.config().arch
61
+ if gstaichi_arch == _ti_core.Arch.x64 or gstaichi_arch == _ti_core.Arch.arm64:
62
62
  self.solver.compute(sparse_matrix.matrix)
63
- elif taichi_arch == _ti_core.Arch.cuda:
63
+ elif gstaichi_arch == _ti_core.Arch.cuda:
64
64
  self.analyze_pattern(self.matrix)
65
65
  self.factorize(self.matrix)
66
66
  else:
@@ -75,7 +75,7 @@ class SparseSolver:
75
75
  if isinstance(sparse_matrix, SparseMatrix):
76
76
  self.matrix = sparse_matrix
77
77
  if self.matrix.dtype != self.dtype:
78
- raise TaichiRuntimeError(
78
+ raise GsTaichiRuntimeError(
79
79
  f"The SparseSolver's dtype {self.dtype} is not consistent with the SparseMatrix's dtype {self.matrix.dtype}."
80
80
  )
81
81
  self.solver.analyze_pattern(sparse_matrix.matrix)
@@ -103,7 +103,7 @@ class SparseSolver:
103
103
  numpy.array: The solution of linear systems.
104
104
  """
105
105
  if self.matrix is None:
106
- raise TaichiRuntimeError("Please call compute() before calling solve().")
106
+ raise GsTaichiRuntimeError("Please call compute() before calling solve().")
107
107
  if isinstance(b, Field):
108
108
  return self.solver.solve(b.to_numpy())
109
109
  if isinstance(b, np.ndarray):
@@ -112,7 +112,7 @@ class SparseSolver:
112
112
  x = ScalarNdarray(b.dtype, [self.matrix.m])
113
113
  self.solver.solve_rf(get_runtime().prog, self.matrix.matrix, b.arr, x.arr)
114
114
  return x
115
- raise TaichiRuntimeError(f"The parameter type: {type(b)} is not supported in linear solvers for now.")
115
+ raise GsTaichiRuntimeError(f"The parameter type: {type(b)} is not supported in linear solvers for now.")
116
116
 
117
117
  def info(self):
118
118
  """Check if the linear systems are solved successfully.
@@ -1,6 +1,6 @@
1
1
  # type: ignore
2
2
 
3
- """Taichi math module.
3
+ """GsTaichi math module.
4
4
 
5
5
  The math module supports glsl-style vectors, matrices and functions.
6
6
  """
@@ -1,8 +1,9 @@
1
1
  # type: ignore
2
2
 
3
+ from gstaichi.lang import ops
4
+ from gstaichi.lang.kernel_impl import func
5
+
3
6
  from .mathimpl import dot, vec2
4
- from taichi.lang import ops
5
- from taichi.lang.kernel_impl import func
6
7
 
7
8
 
8
9
  @func
@@ -13,8 +14,8 @@ def cmul(z1, z2):
13
14
  when `z1` and `z2` are treated as complex numbers.
14
15
 
15
16
  Args:
16
- z1 (:class:`~taichi.math.vec2`): The first input.
17
- z2 (:class:`~taichi.math.vec2`): The second input.
17
+ z1 (:class:`~gstaichi.math.vec2`): The first input.
18
+ z2 (:class:`~gstaichi.math.vec2`): The second input.
18
19
 
19
20
  Example::
20
21
 
@@ -25,7 +26,7 @@ def cmul(z1, z2):
25
26
  >>> ti.math.cmul(z1, z2) # [-1, 1]
26
27
 
27
28
  Returns:
28
- :class:`~taichi.math.vec2`: the complex multiplication `z1 * z2`.
29
+ :class:`~gstaichi.math.vec2`: the complex multiplication `z1 * z2`.
29
30
  """
30
31
  x1, y1 = z1[0], z1[1]
31
32
  x2, y2 = z2[0], z2[1]
@@ -39,10 +40,10 @@ def cconj(z):
39
40
  If `z=(x, y)` then the conjugate of `z` is `(x, -y)`.
40
41
 
41
42
  Args:
42
- z (:class:`~taichi.math.vec2`): The input.
43
+ z (:class:`~gstaichi.math.vec2`): The input.
43
44
 
44
45
  Returns:
45
- :class:`~taichi.math.vec2`: The complex conjugate of `z`.
46
+ :class:`~gstaichi.math.vec2`: The complex conjugate of `z`.
46
47
  """
47
48
  return vec2(z[0], -z[1])
48
49
 
@@ -55,8 +56,8 @@ def cdiv(z1, z2):
55
56
  when `z1` and `z2` are treated as complex numbers.
56
57
 
57
58
  Args:
58
- z1 (:class:`~taichi.math.vec2`): The first input.
59
- z2 (:class:`~taichi.math.vec2`): The second input.
59
+ z1 (:class:`~gstaichi.math.vec2`): The first input.
60
+ z2 (:class:`~gstaichi.math.vec2`): The second input.
60
61
 
61
62
  Example::
62
63
 
@@ -67,7 +68,7 @@ def cdiv(z1, z2):
67
68
  >>> ti.math.cdiv(z1, z2) # [1, -1]
68
69
 
69
70
  Returns:
70
- :class:`~taichi.math.vec2`: the complex division of `z1 / z2`.
71
+ :class:`~gstaichi.math.vec2`: the complex division of `z1 / z2`.
71
72
  """
72
73
  x1, y1 = z1[0], z1[1]
73
74
  x2, y2 = z2[0], z2[1]
@@ -84,7 +85,7 @@ def csqrt(z):
84
85
  are zero, the one with non-negative imaginary part is returned.
85
86
 
86
87
  Args:
87
- z (:class:`~taichi.math.vec2`): The input.
88
+ z (:class:`~gstaichi.math.vec2`): The input.
88
89
 
89
90
  Example::
90
91
 
@@ -94,7 +95,7 @@ def csqrt(z):
94
95
  >>> w = ti.math.csqrt(z) # [0, 1]
95
96
 
96
97
  Returns:
97
- :class:`~taichi.math.vec2`: The complex square root.
98
+ :class:`~gstaichi.math.vec2`: The complex square root.
98
99
  """
99
100
  result = vec2(0.0)
100
101
  if any(z):
@@ -110,7 +111,7 @@ def cinv(z):
110
111
  """Computes the reciprocal of a complex `z`.
111
112
 
112
113
  Args:
113
- z (:class:`~taichi.math.vec2`): The input.
114
+ z (:class:`~gstaichi.math.vec2`): The input.
114
115
 
115
116
  Example::
116
117
 
@@ -120,7 +121,7 @@ def cinv(z):
120
121
  >>> w = ti.math.cinv(z) # [0.5, -0.5]
121
122
 
122
123
  Returns:
123
- :class:`~taichi.math.vec2`: The reciprocal of `z`.
124
+ :class:`~gstaichi.math.vec2`: The reciprocal of `z`.
124
125
  """
125
126
  return cconj(z) / dot(z, z)
126
127
 
@@ -130,7 +131,7 @@ def cpow(z, n):
130
131
  """Computes the power of a complex `z`: :math:`z^a`.
131
132
 
132
133
  Args:
133
- z (:class:`~taichi.math.vec2`): The base.
134
+ z (:class:`~gstaichi.math.vec2`): The base.
134
135
  a (float): The exponent.
135
136
 
136
137
  Example::
@@ -141,7 +142,7 @@ def cpow(z, n):
141
142
  >>> w = ti.math.cpow(z) # [-2, 2]
142
143
 
143
144
  Returns:
144
- :class:`~taichi.math.vec2`: The power :math:`z^a`.
145
+ :class:`~gstaichi.math.vec2`: The power :math:`z^a`.
145
146
  """
146
147
  result = vec2(0.0)
147
148
  if any(z):
@@ -159,7 +160,7 @@ def cexp(z):
159
160
  `z` is a 2d vector treated as a complex number.
160
161
 
161
162
  Args:
162
- z (:class:`~taichi.math.vec2`): The exponent.
163
+ z (:class:`~gstaichi.math.vec2`): The exponent.
163
164
 
164
165
  Example::
165
166
 
@@ -169,7 +170,7 @@ def cexp(z):
169
170
  >>> w = ti.math.cexp(z) # [1.468694, 2.287355]
170
171
 
171
172
  Returns:
172
- :class:`~taichi.math.vec2`: The power :math:`exp(z)`
173
+ :class:`~gstaichi.math.vec2`: The power :math:`exp(z)`
173
174
  """
174
175
  r = ops.exp(z[0])
175
176
  return vec2(r * ops.cos(z[1]), r * ops.sin(z[1]))
@@ -184,7 +185,7 @@ def clog(z):
184
185
  lies in the range (-pi, pi].
185
186
 
186
187
  Args:
187
- z (:class:`~taichi.math.vec2`): The input.
188
+ z (:class:`~gstaichi.math.vec2`): The input.
188
189
 
189
190
  Example::
190
191
 
@@ -194,7 +195,7 @@ def clog(z):
194
195
  >>> w = ti.math.clog(z) # [0.346574, 0.785398]
195
196
 
196
197
  Returns:
197
- :class:`~taichi.math.vec2`: The logarithm of `z`.
198
+ :class:`~gstaichi.math.vec2`: The logarithm of `z`.
198
199
  """
199
200
  ang = ops.atan2(z[1], z[0])
200
201
  r2 = dot(z, z)