CalCulus is a fast, lightweight scientific computing library written in C++ and exposed to Python using pybind11.
๐ฌ NumPy vs CalCulus Comparison
| Feature | NumPy | CalCulus |
|---|---|---|
| Core Language | C + Python | Pure C++ (pybind11) |
| Focus | Array-based numerical computing | Scientific math, physics & robotics |
| Scalar Operations | numpy.float64 |
Scalar C++ class |
| Trigonometric Functions | โ Vectorized | โ High-precision scalar |
| Vector Algebra | Limited (manual) | โ Built-in Vec3
|
| Dot Product | โ | โ |
| Cross Product | โ (via np.cross) |
โ Native |
| Numerical Integration | Limited | โ Simpsonโs Rule |
| Physical Constants | Partial | โ Built-in |
| Robotics Use | Medium | โ High |
| Physics Simulations | Medium | โ High |
| C++ Performance | โ | โ |
| SIMD / Low-level Control | โ | โ |
| Learning Curve | Easy | Moderate |
| Best Use Case | Data science, ML | Robotics, physics engines |
| Python Dependency | Heavy | Minimal |
| Custom Math Engine | โ | โ |
| Real-Time Applications | โ | โ |
๐ When to Use Which?
-
Use NumPy when:
- Working with large datasets
- Doing machine learning or statistics
- Needing array broadcasting
-
Use CalCulus when:
- Building robotics or physics engines
- Needing C++-level performance
- Working with vectors, forces, motion, integration
## ๐งฎ API Overview
๐ข Scalar
The Scalar class represents a single numerical value with advanced scientific operations.
| Method / Operator | Description |
|---|---|
+ - * / |
Arithmetic operations |
sin() |
Sine |
cos() |
Cosine |
tan() |
Tangent |
asin() |
Inverse sine |
acos() |
Inverse cosine |
atan() |
Inverse tangent |
sinh() |
Hyperbolic sine |
cosh() |
Hyperbolic cosine |
tanh() |
Hyperbolic tangent |
exp() |
Exponential |
log() |
Natural logarithm |
log10() |
Base-10 logarithm |
pow(n) |
Power |
sqrt() |
Square root |
cbrt() |
Cube root |
abs() |
Absolute value |
๐ Vec3 (3D Vector)
The Vec3 class is designed for physics, robotics, and linear algebra.
| Method | Description |
|---|---|
+ - |
Vector addition / subtraction |
* |
Scalar multiplication |
dot(v) |
Dot product |
cross(v) |
Cross product |
magnitude() |
Vector length |
normalize() |
Unit vector |
๐ง Solver
Numerical calculus utilities.
| Method | Description |
|---|---|
integrate(func, a, b, n) |
Simpsonโs Rule integration |
๐ Constants
Physical and mathematical constants.
| Constant | Description |
|---|---|
pi |
ฯ |
e |
Eulerโs number |
c |
Speed of light |
h |
Planck constant |
k |
Boltzmann constant |
g |
Gravity |
See the Official library page - https://github.com/LegedsDaD/CalCulus
Top comments (0)