How to calculate rotation, divergence in C/C++

  • Context: C/C++ 
  • Thread starter Thread starter walnutTree
  • Start date Start date
  • Tags Tags
    Divergence Rotation
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 6K views
walnutTree
Messages
5
Reaction score
0
Dear Experts,

I started to look deeper into the electromagnetic fields.
So I would like to write a simple code in C/C++, which is capable of calculating the divergence or rotation of the vector fields.

Could someone helps me please, to get this started?
How to illustrate partial derivatives in the program?

I would be very grateful for your helps!
 
Physics news on Phys.org
Unfortunately your program won't be very simple! Unlike a 4-th generation language such as Matlab, C++ does not natively support mathematical objects such as vectors. You'll need at least to write a "Vector" class, and define your operators (div, curl, etc) based on that.

You might be interested in the uBLAS library in Boost (www.boost.org).

Numerical differentiation is more or less straightforward in C++, Google should help you out with that.