Skip to content

Commit 4e8d136

Browse files
committed
Added docs for ComplexFloat
1 parent 62cfd46 commit 4e8d136

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

LibSource/ComplexFloatArray.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,64 @@
33

44
#include "FloatArray.h"
55
#include "basicmaths.h"
6-
6+
/**
7+
* A structure defining a floating point complex number as two members of type float.
8+
*/
79
struct ComplexFloat {
10+
/**
11+
The real part of the complex number.
12+
*/
813
float re;
14+
15+
/**
16+
The imaginary part of the complex number.
17+
*/
918
float im;
19+
20+
/**
21+
Get the magnitude of the complex number.
22+
Computes and returns the magnitude of the complex number.
23+
@return The magnitude of the complex number.
24+
*/
1025
float getMagnitude(){
1126
return sqrtf(re*re+im*im);
1227
}
28+
29+
/**
30+
Get the phase of the complex number.
31+
Computes and returns the phase of the complex number.
32+
@return The phase of the complex number.
33+
*/
1334
float getPhase(){
1435
return atan2(im,re);
1536
}
37+
38+
/**
39+
Set the phase of the complex number.
40+
Set the phase of the complex number, keeping the magnitude unaltered.
41+
@param phase The new phase of the complex number
42+
*/
1643
void setPhase(float phase){
1744
float magnitude=getMagnitude();
1845
setPolar(magnitude, phase);
1946
}
47+
48+
/**
49+
Set the magnitude of the complex number.
50+
Set the magnitude of the complex number, keeping the phase unaltered.
51+
@param magnitude The new magnitude of the complex number
52+
*/
2053
void setMagnitude(float magnitude){
2154
float phase=getPhase();
2255
setPolar(magnitude, phase);
2356
}
57+
58+
59+
/**
60+
Set magnitude and phase of the complex number.
61+
@param magnitude The new magnitude of the complex number
62+
@param phase The new phase of the complex number
63+
*/
2464
void setPolar(float magnitude, float phase){
2565
re=magnitude*cosf(phase);
2666
im=magnitude*sinf(phase);

0 commit comments

Comments
 (0)