Skip to content

Commit ce4c457

Browse files
CrazyDubyaCopilotopenhands-agent
authored
Add std math translation (#4)
* Map math functions to std equivalents * Update src/converter/code_generator_fixed.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/converter/code_generator_fixed.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/converter/code_generator_fixed.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update documentation for math functions --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 0090105 commit ce4c457

File tree

6 files changed

+1398
-1892
lines changed

6 files changed

+1398
-1892
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ Currently, PyToC++ effectively handles:
159159
- **Method overriding** and polymorphism
160160
- **Constructor translation** with proper initialization
161161

162+
- **Math function translation**: `math.sqrt`, `math.sin`, and `math.cos` are translated to their C++ `std` equivalents.
162163
More complex features are under development, including:
163164
- Exception handling
164165
- Standard library mapping

docs/conversion_patterns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ with open("file.txt") as f:
305305
| Python | C++ |
306306
|--------|-----|
307307
| `math.sqrt(x)` | `std::sqrt(x)` |
308+
| `math.sin(x)` | `std::sin(x)` |
309+
| `math.cos(x)` | `std::cos(x)` |
308310
| `random.random()` | `std::uniform_real_distribution<double>(0.0, 1.0)(generator)` |
309311
| `len(container)` | `container.size()` |
310312
| `min(a, b)` | `std::min(a, b)` |
File renamed without changes.

0 commit comments

Comments
 (0)