Browse Source

cmComplexTypes.h/c : Added cmVOCR_MultVFV() and cmVOCR_DivVFV(). Implemented cmVOCR_Abs().

master
kevin 9 years ago
parent
commit
7669faceba
2 changed files with 36 additions and 12 deletions
  1. 28
    10
      cmComplexTypes.c
  2. 8
    2
      cmComplexTypes.h

+ 28
- 10
cmComplexTypes.c View File

1
+#include "cmPrefix.h"
2
+#include "cmGlobal.h"
3
+#include "cmFloatTypes.h"
4
+#include "cmComplexTypes.h"
1
 
5
 
2
-
3
-void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplex_t* x0, const cmComplexR_t* x1, unsigned n )
6
+void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplexS_t* x0, const cmComplexR_t* x1, unsigned n )
4
 {
7
 {
5
   unsigned i;
8
   unsigned i;
6
   for(i=0; i<n; ++i)
9
   for(i=0; i<n; ++i)
7
   {
10
   {
11
+    y[i] = x0[i] * x1[i];
12
+    /*
8
     cmReal_t ab = x0[i].r * x1[i].r;
13
     cmReal_t ab = x0[i].r * x1[i].r;
9
     cmReal_t bd = x0[i].i * x1[i].i;
14
     cmReal_t bd = x0[i].i * x1[i].i;
10
     cmReal_t bc = x0[i].i * x1[i].r;
15
     cmReal_t bc = x0[i].i * x1[i].r;
11
     cmReal_t ad = x0[i].r * x1[i].i;
16
     cmReal_t ad = x0[i].r * x1[i].i;
12
     y[i].r = ab - bd;
17
     y[i].r = ab - bd;
13
     y[i].i = bc + ad;    
18
     y[i].i = bc + ad;    
19
+    */
14
   }
20
   }
15
 
21
 
16
 }
22
 }
17
 
23
 
18
-void cmVOCR_Abs(     cmReal_t* y, const cmComplexR_t* x, unsigned n )
24
+void cmVOCR_MultVFV(  cmComplexR_t* y, const float* x, unsigned n )
19
 {
25
 {
26
+  unsigned i;
20
   for(i=0; i<n; ++i)
27
   for(i=0; i<n; ++i)
21
-    y[i] = cmAbsR(x[i]);
28
+  {
29
+    y[i] *= x[i];
30
+  }
22
 }
31
 }
23
 
32
 
24
-void cmVOCR_MultR_VV(  cmComplexR_t* y, const cmReal_t* x, unsigned n )
33
+void cmVOCR_DivVFV(   cmComplexR_t* y, const float* x, unsigned n )
25
 {
34
 {
26
   unsigned i;
35
   unsigned i;
27
   for(i=0; i<n; ++i)
36
   for(i=0; i<n; ++i)
28
   {
37
   {
29
-    y[i].r *= x[i];
30
-    y[i].i *= x[i];
31
-  }
38
+    y[i] /= x[i];
39
+  }  
32
 }
40
 }
33
 
41
 
42
+
43
+void cmVOCR_Abs(     cmSample_t* y, const cmComplexR_t* x, unsigned n )
44
+{
45
+  unsigned i;
46
+  for(i=0; i<n; ++i)
47
+    y[i] = (cmSample_t)cmCabsR(x[i]);
48
+}
49
+
50
+
34
 void cmVOCR_DivR_VV(   cmComplexR_t* y, const cmReal_t* x, unsigned n )
51
 void cmVOCR_DivR_VV(   cmComplexR_t* y, const cmReal_t* x, unsigned n )
35
 {
52
 {
36
   unsigned i;
53
   unsigned i;
37
   for(i=0; i<n; ++i)
54
   for(i=0; i<n; ++i)
38
   {
55
   {
39
-    y[i].r /= x[i];
40
-    y[i].i /= x[i];
56
+    y[i] /= x[i];
57
+    //y[i].r /= x[i];
58
+    //y[i].i /= x[i];
41
   }  
59
   }  
42
 }
60
 }

+ 8
- 2
cmComplexTypes.h View File

11
 #define cmCrealS crealf
11
 #define cmCrealS crealf
12
 #define cmCimagS cimagf 
12
 #define cmCimagS cimagf 
13
 #define cmCargS  cargf
13
 #define cmCargS  cargf
14
+#define cmCconjS conjf
14
 
15
 
15
 #define cmFftPlanAllocS   fftwf_plan_dft_r2c_1d
16
 #define cmFftPlanAllocS   fftwf_plan_dft_r2c_1d
16
 #define cmFft1dPlanAllocS fftwf_plan_dft_1d
17
 #define cmFft1dPlanAllocS fftwf_plan_dft_1d
29
 #define cmCrealS creal
30
 #define cmCrealS creal
30
 #define cmCimagS cimag 
31
 #define cmCimagS cimag 
31
 #define cmCargS  carg
32
 #define cmCargS  carg
33
+#define cmCconjS conj
32
 
34
 
33
 #define cmFftPlanAllocS   fftw_plan_dft_r2c_1d
35
 #define cmFftPlanAllocS   fftw_plan_dft_r2c_1d
34
 #define cmFft1dPlanAllocS fftw_plan_dft_1d
36
 #define cmFft1dPlanAllocS fftw_plan_dft_1d
53
 #define cmCrealR crealf
55
 #define cmCrealR crealf
54
 #define cmCimagR cimagf 
56
 #define cmCimagR cimagf 
55
 #define cmCargR  cargf
57
 #define cmCargR  cargf
58
+#define cmCconjR conjf
56
 
59
 
57
 #define cmFftPlanAllocR   fftwf_plan_dft_r2c_1d
60
 #define cmFftPlanAllocR   fftwf_plan_dft_r2c_1d
58
 #define cmFft1dPlanAllocR fftwf_plan_dft_1d
61
 #define cmFft1dPlanAllocR fftwf_plan_dft_1d
71
 #define cmCrealR creal
74
 #define cmCrealR creal
72
 #define cmCimagR cimag 
75
 #define cmCimagR cimag 
73
 #define cmCargR  carg
76
 #define cmCargR  carg
77
+#define cmCconjR conj
74
 
78
 
75
 #define cmFftPlanAllocR   fftw_plan_dft_r2c_1d
79
 #define cmFftPlanAllocR   fftw_plan_dft_r2c_1d
76
 #define cmFft1dPlanAllocR fftw_plan_dft_1d
80
 #define cmFft1dPlanAllocR fftw_plan_dft_1d
84
 
88
 
85
 #endif
89
 #endif
86
 
90
 
87
-void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplexR_t* x0, const cmComplexR_t* x1, unsigned n );
88
-void cmVOCR_Abs(     cmReal_t*     y, const cmComplexR_t* x, unsigned n );
91
+void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplexS_t* x0, const cmComplexR_t* x1, unsigned n );
92
+void cmVOCR_MultVFV(  cmComplexR_t* y, const float* x, unsigned n );
93
+void cmVOCR_DivVFV(   cmComplexR_t* y, const float_t* x, unsigned n );
94
+void cmVOCR_Abs(     cmSample_t*   y, const cmComplexR_t* x, unsigned n );
89
 void cmVOCR_MultVS(  cmComplexR_t* y, cmReal_t v, unsigned n );
95
 void cmVOCR_MultVS(  cmComplexR_t* y, cmReal_t v, unsigned n );
90
 void cmVOCR_DivVS(   cmComplexR_t* y, cmReal_t v, unsigned n );
96
 void cmVOCR_DivVS(   cmComplexR_t* y, cmReal_t v, unsigned n );
91
 
97
 

Loading…
Cancel
Save