-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1) Added comment to matrix rotation operation
2) Added function for vector modifications
- Loading branch information
1 parent
9144569
commit 2aeb0d4
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
sources/jvxLibraries/jvx-dsp-base/include/jvx_vector/jvx_vector.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef __JVX_VECTOR_H__ | ||
#define __JVX_VECTOR_H__ | ||
|
||
#include "jvx_dsp_base.h" | ||
|
||
#include <math.h> | ||
|
||
JVX_DSP_LIB_BEGIN | ||
|
||
void jvx_vector_cross_product(jvxData* in1, jvxData* in2, jvxData* out, jvxSize n); | ||
void jvx_vector_mat_comp(jvxData* in, jvxData* out, jvxData** mat, jvxSize n, jvxCBool transpMode); | ||
|
||
JVX_DSP_LIB_END | ||
|
||
#endif |
49 changes: 49 additions & 0 deletions
49
sources/jvxLibraries/jvx-dsp-base/src/jvx_vector/jvx_vector.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "jvx_dsp_base.h" | ||
#include "jvx_vector/jvx_vector.h" | ||
|
||
void jvx_vector_cross_product(jvxData* in1, jvxData* in2, jvxData* out, jvxSize n) | ||
{ | ||
for (jvxSize i = 0; i < n; i++) | ||
{ | ||
jvxData tmp = 0; | ||
|
||
// Circular addressing | ||
jvxSize j0 = (i + 1) % n; | ||
jvxSize j1 = (i + 2) % n; | ||
out[i] = in1[j0] * in2[j1] - in1[j1] * in2[j0]; | ||
} | ||
} | ||
|
||
// Non-transpMode | ||
// | mat[0][0] mat[0,1] mat[0,2] | | ||
// [in in in] * | mat[1,0] mat[1,1] mat[1,2] | | ||
// | mat[2,0] mat[2,1] mat[2,2] | | ||
|
||
// TranspMode | ||
// | mat[0,0] mat[0,1] mat[0,2] |^T | ||
// [in in in] * | mat[1,0] mat[1,1] mat[1,2] | | ||
// | mat[2,0] mat[2,1] mat[2,2] | | ||
|
||
void jvx_vector_mat_comp(jvxData* in, jvxData* out, jvxData** mat, jvxSize n, jvxCBool transpMode) | ||
{ | ||
for (jvxSize i = 0; i < n; i++) | ||
{ | ||
jvxData tmp = 0; | ||
|
||
if (transpMode) | ||
{ | ||
for (jvxSize j = 0; j < n; j++) | ||
{ | ||
tmp += in[j] * mat[i][j]; | ||
} | ||
} | ||
else | ||
{ | ||
for (jvxSize j = 0; j < n; j++) | ||
{ | ||
tmp += in[j] * mat[j][i]; | ||
} | ||
} | ||
out[i] = tmp; | ||
} | ||
} |