Skip to content

Commit

Permalink
Introduce complex conjugate for dense
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Bock <[email protected]>
  • Loading branch information
nicolasbock committed Feb 13, 2020
1 parent 51ca4e2 commit cd557bd
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/C-interface/bml_transpose.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,25 @@ bml_transpose(
break;
}
}

/** Complex conjugate of a matrix.
*
* \ingroup transpose_group_C
*
* \param A Matrix to be complex conjugated
* \return Complex conjugate of A
*/
void
bml_complex_conjugate(
bml_matrix_t * A)
{
switch (bml_get_type(A))
{
case dense:
bml_complex_conjugate_dense(A);
break;
default:
LOG_ERROR("unknown matrix type\n");
break;
}
}
3 changes: 2 additions & 1 deletion src/C-interface/bml_transpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

#include "bml_types.h"

// Transpose A - B = A^T
bml_matrix_t *bml_transpose_new(
bml_matrix_t * A);

void bml_transpose(
bml_matrix_t * A);

void bml_complex_conjugate(bml_matrix_t * A);

#endif
31 changes: 31 additions & 0 deletions src/C-interface/dense/bml_transpose_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,34 @@ bml_transpose_dense(
break;
}
}

/** Complex conjugate a matrix in place.
*
* \ingroup transpose_group
*
* \param A The matrix to be complex conjugated
* \return Complex conjugate of A
*/
void
bml_complex_conjugate_dense(
bml_matrix_dense_t * A)
{
switch (A->matrix_precision)
{
case single_real:
bml_complex_conjugate_dense_single_real(A);
break;
case double_real:
bml_complex_conjugate_dense_double_real(A);
break;
case single_complex:
bml_complex_conjugate_dense_single_complex(A);
break;
case double_complex:
bml_complex_conjugate_dense_double_complex(A);
break;
default:
LOG_ERROR("unknown precision\n");
break;
}
}
15 changes: 15 additions & 0 deletions src/C-interface/dense/bml_transpose_dense.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,19 @@ void bml_transpose_dense_single_complex(
void bml_transpose_dense_double_complex(
bml_matrix_dense_t * A);

void bml_complex_conjugate_dense(
bml_matrix_dense_t * A);

void bml_complex_conjugate_dense_single_real(
bml_matrix_dense_t * A);

void bml_complex_conjugate_dense_double_real(
bml_matrix_dense_t * A);

void bml_complex_conjugate_dense_single_complex(
bml_matrix_dense_t * A);

void bml_complex_conjugate_dense_double_complex(
bml_matrix_dense_t * A);

#endif
29 changes: 29 additions & 0 deletions src/C-interface/dense/bml_transpose_dense_typed.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,32 @@ void TYPED_FUNC(
}
#endif
}

/** Complex conjugate of a matrix.
*
* \ingroup transpose_group_C
*
* \param A Matrix to be complex conjugated
* \return Complex conjugate of A
*/
void TYPED_FUNC(
bml_complex_conjugate_dense) (
bml_matrix_dense_t * A)
{
int N = A->N;

REAL_T *A_matrix = A->matrix;
REAL_T tmp;

#if defined(SINGLE_REAL) || defined(DOUBLE_REAL)
return;
#else
#pragma omp parallel for \
private(tmp) \
shared(N, A_matrix)
for (int i = 0; i < N * N; i++)
{
A_matrix[i] = COMPLEX_CONJUGATE(A_matrix[i]);
}
#endif
}

0 comments on commit cd557bd

Please sign in to comment.