Skip to content

Commit

Permalink
1) Added comment to matrix rotation operation
Browse files Browse the repository at this point in the history
2) Added function for vector modifications
  • Loading branch information
hkbinaurics committed Jun 27, 2024
1 parent 9144569 commit 2aeb0d4
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sources/jvxLibraries/jvx-dsp-base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ set(LOCAL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/jvx_matrix/jvx_matrix.c
${CMAKE_CURRENT_SOURCE_DIR}/src/jvx_matrix/jvx_matrix_mult.c
${CMAKE_CURRENT_SOURCE_DIR}/src/jvx_matrix/jvx_matrix_rot.c
${CMAKE_CURRENT_SOURCE_DIR}/src/jvx_vector/jvx_vector.c
${CMAKE_CURRENT_SOURCE_DIR}/src/jvx_profiler/jvx_profiler_data_entry.c

${CMAKE_CURRENT_SOURCE_DIR}/src/jvx_conv/jvx_conv.c
Expand All @@ -63,7 +64,7 @@ set(LOCAL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/include/jvx_matrix/jvx_matrix.h
${CMAKE_CURRENT_SOURCE_DIR}/include/jvx_matrix/jvx_matrix_mult.h
${CMAKE_CURRENT_SOURCE_DIR}/include/jvx_matrix/jvx_matrix_rot.h

${CMAKE_CURRENT_SOURCE_DIR}/include/jvx_vector/jvx_vector.h
${CMAKE_CURRENT_SOURCE_DIR}/include/jvx_windows/jvx_windows.h
${CMAKE_CURRENT_SOURCE_DIR}/include/jvx_math/jvx_complex.h
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,30 @@

JVX_DSP_LIB_BEGIN

// This computes a rotation matrix Rx * Ry * Rz. That is, it runs rotation
// along z-axis first, then along y-axis and finally along x-axis

/* Test totation
*
jvxData tmp1[3] = { 0 };
jvxData tmp2[3] = { 0 };
jvxData rrp_rho_delta[3] = { 0,0,0 };
tmp1[0] = 1;
tmp1[1] = 0;
tmp1[2] = 0;
rrp_rho_delta[0] = 90;
rrp_rho_delta[1] = 90;
rrp_rho_delta[2] = 90;
// z: [1 0 0] -> [0 1 0] -- y: [0 1 0] -> [0 1 0] -- x: [0 1 0] -> [0 0 1]
jvx_matrix_process_rotmatrix_xyz_real(&rotMat, rrp_rho_delta);
jvx_matrix_process_rotmatrix_xyz_vec_real(&rotMat, tmp1, tmp2);
*/

jvxErrorType jvx_matrix_process_rotmatrix_xyz_real(jvx_matrix* mat, jvxData* rotxyz_deg);

jvxErrorType jvx_matrix_process_rotmatrix_xyz_vec_real(jvx_matrix* mat, jvxData* xyz_in, jvxData* out);

JVX_DSP_LIB_END
Expand Down
15 changes: 15 additions & 0 deletions sources/jvxLibraries/jvx-dsp-base/include/jvx_vector/jvx_vector.h
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 sources/jvxLibraries/jvx-dsp-base/src/jvx_vector/jvx_vector.c
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;
}
}

0 comments on commit 2aeb0d4

Please sign in to comment.