Przeglądaj źródła

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

master
kevin 9 lat temu
rodzic
commit
7669faceba
2 zmienionych plików z 36 dodań i 12 usunięć
  1. 28
    10
      cmComplexTypes.c
  2. 8
    2
      cmComplexTypes.h

+ 28
- 10
cmComplexTypes.c Wyświetl plik

@@ -1,42 +1,60 @@
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 8
   unsigned i;
6 9
   for(i=0; i<n; ++i)
7 10
   {
11
+    y[i] = x0[i] * x1[i];
12
+    /*
8 13
     cmReal_t ab = x0[i].r * x1[i].r;
9 14
     cmReal_t bd = x0[i].i * x1[i].i;
10 15
     cmReal_t bc = x0[i].i * x1[i].r;
11 16
     cmReal_t ad = x0[i].r * x1[i].i;
12 17
     y[i].r = ab - bd;
13 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 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 35
   unsigned i;
27 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 51
 void cmVOCR_DivR_VV(   cmComplexR_t* y, const cmReal_t* x, unsigned n )
35 52
 {
36 53
   unsigned i;
37 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 Wyświetl plik

@@ -11,6 +11,7 @@
11 11
 #define cmCrealS crealf
12 12
 #define cmCimagS cimagf 
13 13
 #define cmCargS  cargf
14
+#define cmCconjS conjf
14 15
 
15 16
 #define cmFftPlanAllocS   fftwf_plan_dft_r2c_1d
16 17
 #define cmFft1dPlanAllocS fftwf_plan_dft_1d
@@ -29,6 +30,7 @@
29 30
 #define cmCrealS creal
30 31
 #define cmCimagS cimag 
31 32
 #define cmCargS  carg
33
+#define cmCconjS conj
32 34
 
33 35
 #define cmFftPlanAllocS   fftw_plan_dft_r2c_1d
34 36
 #define cmFft1dPlanAllocS fftw_plan_dft_1d
@@ -53,6 +55,7 @@
53 55
 #define cmCrealR crealf
54 56
 #define cmCimagR cimagf 
55 57
 #define cmCargR  cargf
58
+#define cmCconjR conjf
56 59
 
57 60
 #define cmFftPlanAllocR   fftwf_plan_dft_r2c_1d
58 61
 #define cmFft1dPlanAllocR fftwf_plan_dft_1d
@@ -71,6 +74,7 @@
71 74
 #define cmCrealR creal
72 75
 #define cmCimagR cimag 
73 76
 #define cmCargR  carg
77
+#define cmCconjR conj
74 78
 
75 79
 #define cmFftPlanAllocR   fftw_plan_dft_r2c_1d
76 80
 #define cmFft1dPlanAllocR fftw_plan_dft_1d
@@ -84,8 +88,10 @@
84 88
 
85 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 95
 void cmVOCR_MultVS(  cmComplexR_t* y, cmReal_t v, unsigned n );
90 96
 void cmVOCR_DivVS(   cmComplexR_t* y, cmReal_t v, unsigned n );
91 97
 

Ładowanie…
Anuluj
Zapisz