PDA

View Full Version : How to calculate rotation, divergence in C/C++


walnutTree
Dec14-10, 05:37 PM
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!

p1ayaone1
Dec14-10, 09:09 PM
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.