DEV Community

Cover image for CalCulus
LEGEND'S DaD
LEGEND'S DaD

Posted on

CalCulus

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)