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

Click For Summary
The discussion focuses on creating a C/C++ program to calculate the divergence and rotation of vector fields, particularly in the context of electromagnetic fields. It highlights the challenge of implementing mathematical operations in C++, as the language does not natively support vector objects. A suggestion is made to create a "Vector" class and define necessary operators for divergence and curl. Additionally, the uBLAS library from Boost is recommended as a potential resource. The conversation also notes that while numerical differentiation can be implemented in C++, it may require additional research to effectively execute.
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!
 
Technology 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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 23 ·
Replies
23
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
81
Views
7K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 29 ·
Replies
29
Views
8K
  • · Replies 25 ·
Replies
25
Views
724
  • · Replies 1 ·
Replies
1
Views
2K