Browse Source

cmComplexTypes.h : Added complex arithmetic vector operations.

master
kevin 9 years ago
parent
commit
f481f7f62a
2 changed files with 48 additions and 0 deletions
  1. 42
    0
      cmComplexTypes.c
  2. 6
    0
      cmComplexTypes.h

+ 42
- 0
cmComplexTypes.c View File

@@ -0,0 +1,42 @@
1
+
2
+
3
+void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplex_t* x0, const cmComplexR_t* x1, unsigned n )
4
+{
5
+  unsigned i;
6
+  for(i=0; i<n; ++i)
7
+  {
8
+    cmReal_t ab = x0[i].r * x1[i].r;
9
+    cmReal_t bd = x0[i].i * x1[i].i;
10
+    cmReal_t bc = x0[i].i * x1[i].r;
11
+    cmReal_t ad = x0[i].r * x1[i].i;
12
+    y[i].r = ab - bd;
13
+    y[i].i = bc + ad;    
14
+  }
15
+
16
+}
17
+
18
+void cmVOCR_Abs(     cmReal_t* y, const cmComplexR_t* x, unsigned n )
19
+{
20
+  for(i=0; i<n; ++i)
21
+    y[i] = cmAbsR(x[i]);
22
+}
23
+
24
+void cmVOCR_MultR_VV(  cmComplexR_t* y, const cmReal_t* x, unsigned n )
25
+{
26
+  unsigned i;
27
+  for(i=0; i<n; ++i)
28
+  {
29
+    y[i].r *= x[i];
30
+    y[i].i *= x[i];
31
+  }
32
+}
33
+
34
+void cmVOCR_DivR_VV(   cmComplexR_t* y, const cmReal_t* x, unsigned n )
35
+{
36
+  unsigned i;
37
+  for(i=0; i<n; ++i)
38
+  {
39
+    y[i].r /= x[i];
40
+    y[i].i /= x[i];
41
+  }  
42
+}

+ 6
- 0
cmComplexTypes.h View File

@@ -84,4 +84,10 @@
84 84
 
85 85
 #endif
86 86
 
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 );
89
+void cmVOCR_MultVS(  cmComplexR_t* y, cmReal_t v, unsigned n );
90
+void cmVOCR_DivVS(   cmComplexR_t* y, cmReal_t v, unsigned n );
91
+
92
+
87 93
 #endif

Loading…
Cancel
Save