Skip to content

Commit

Permalink
Removed complex int (#91)
Browse files Browse the repository at this point in the history
* Removed complex int

* removed hr_complex_int from tests
  • Loading branch information
sofiemartins authored May 7, 2024
1 parent 420c291 commit c1f43d1
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 96 deletions.
1 change: 0 additions & 1 deletion Include/Core/cpu_complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@

typedef double complex hr_complex;
typedef float complex hr_complex_flt;
typedef int complex hr_complex_int;

#endif
5 changes: 2 additions & 3 deletions Include/Core/gpu_complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,13 @@ auto visible inline __attribute__((always_inline)) operator/(const hr_complex_t<
(x.im * c.re - x.re * c.im) / (c.re * c.re + c.im * c.im));
}

typedef struct hr_complex_t<int> hr_complex_int;
typedef struct hr_complex_t<double> hr_complex;
typedef struct hr_complex_t<float> hr_complex_flt;

#ifndef HIP
#define I (hr_complex_int(0, 1))
#define I (hr_complex_flt(0.0f, 1.0f))
#else
constexpr hr_complex I = hr_complex_int(0, 1);
constexpr hr_complex I = hr_complex_flt(0.0f, 1.0f);
#endif
#define creal(a) ((a).re)
#define cimag(a) ((a).im)
Expand Down
4 changes: 0 additions & 4 deletions Include/Inverters/test_complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ int test_overload_prod_hr_complex();
int test_overload_div_hr_complex();
int test_negate();
int test_cast_double();
int test_overload_plus_rhs_integer();
int test_overload_plus_lhs_integer();
int test_overload_div_rhs_integer();
int test_overload_div_lhs_integer();
int test_I_add();
int test_I_prod();

Expand Down
84 changes: 0 additions & 84 deletions LibHR/Inverters/test_complex.cu
Original file line number Diff line number Diff line change
Expand Up @@ -200,74 +200,6 @@ int test_cast_double() {
return result;
}

int test_overload_plus_rhs_integer() {
lprintf("TEST", 0, __func__);
int result = 0;
hr_complex c = hr_complex(1.1, 2.2);
hr_complex a;
hr_complex_int b = hr_complex_int(3, 4);
a = c + b;

result += check_diff_norm(4.1 - a.re, EPSILON_TEST);
result += check_diff_norm(6.2 - a.im, EPSILON_TEST);
result += check_diff_norm(1.1 - c.re, EPSILON_TEST);
result += check_diff_norm(2.2 - c.im, EPSILON_TEST);
result += check_diff_norm(3 - b.re, EPSILON_TEST);
result += check_diff_norm(4 - b.im, EPSILON_TEST);
return result;
}

int test_overload_plus_lhs_integer() {
lprintf("TEST", 0, __func__);
int result = 0;
hr_complex c = hr_complex(1.1, 2.2);
hr_complex a;
hr_complex_int b = hr_complex_int(3, 4);
a = b + c;

result += check_diff_norm(4.1 - a.re, EPSILON_TEST);
result += check_diff_norm(6.2 - a.im, EPSILON_TEST);
result += check_diff_norm(1.1 - c.re, EPSILON_TEST);
result += check_diff_norm(2.2 - c.im, EPSILON_TEST);
result += check_diff_norm(3 - b.re, EPSILON_TEST);
result += check_diff_norm(4 - b.im, EPSILON_TEST);
return result;
}

int test_overload_div_rhs_integer() {
lprintf("TEST", 0, __func__);
int result = 0;
hr_complex c = hr_complex(1.1, 2.2);
hr_complex_int b = hr_complex_int(3, 4);
hr_complex a;
a = c / b;

result += check_diff_norm(0.484 - a.re, EPSILON_TEST);
result += check_diff_norm(0.088 - a.im, EPSILON_TEST);
result += check_diff_norm(1.1 - c.re, EPSILON_TEST);
result += check_diff_norm(2.2 - c.im, EPSILON_TEST);
result += check_diff_norm(3 - b.re, EPSILON_TEST);
result += check_diff_norm(4 - b.im, EPSILON_TEST);
return result;
}

int test_overload_div_lhs_integer() {
lprintf("TEST", 0, __func__);
int result = 0;
hr_complex c = hr_complex(1.1, 2.2);
hr_complex_int b = hr_complex_int(3, 4);
hr_complex a;
a = b / c;

result += check_diff_norm(2.0 - a.re, EPSILON_TEST);
result += check_diff_norm(-4.0 / 11.0 - a.im, EPSILON_TEST);
result += check_diff_norm(1.1 - c.re, EPSILON_TEST);
result += check_diff_norm(2.2 - c.im, EPSILON_TEST);
result += check_diff_norm(3 - b.re, EPSILON_TEST);
result += check_diff_norm(4 - b.im, EPSILON_TEST);
return result;
}

int test_I_add() {
lprintf("TEST", 0, __func__);
int result = 0;
Expand Down Expand Up @@ -407,30 +339,14 @@ template <class L> void random_number(hr_complex_t<L> &c) {
result += __fname__##_tmpl<hr_complex_flt, float>(EPSILON_FLT_TEST); \
lprintf("TEST", 0, "Check hr_complex_flt -- int\n"); \
result += __fname__##_tmpl<hr_complex_flt, int>(EPSILON_FLT_TEST); \
lprintf("TEST", 0, "Check hr_complex_int -- double\n"); \
result += __fname__##_tmpl<hr_complex_int, double>(EPSILON_TEST); \
lprintf("TEST", 0, "Check hr_complex_int -- float\n"); \
result += __fname__##_tmpl<hr_complex_int, float>(EPSILON_TEST); \
lprintf("TEST", 0, "Check hr_complex_int -- int\n"); \
result += __fname__##_tmpl<hr_complex_int, int>(EPSILON_TEST); \
lprintf("TEST", 0, "Check hr_complex -- hr_complex\n"); \
result += __fname__##_tmpl<hr_complex, hr_complex>(EPSILON_TEST); \
lprintf("TEST", 0, "Check hr_complex -- hr_complex_flt\n"); \
result += __fname__##_tmpl<hr_complex, hr_complex_flt>(EPSILON_FLT_TEST); \
lprintf("TEST", 0, "Check hr_complex -- hr_complex_int\n"); \
result += __fname__##_tmpl<hr_complex, hr_complex_int>(EPSILON_TEST); \
lprintf("TEST", 0, "Check hr_complex_flt -- hr_complex\n"); \
result += __fname__##_tmpl<hr_complex_flt, hr_complex>(EPSILON_FLT_TEST); \
lprintf("TEST", 0, "Check hr_complex_flt -- hr_complex_flt\n"); \
result += __fname__##_tmpl<hr_complex_flt, hr_complex_flt>(EPSILON_FLT_TEST); \
lprintf("TEST", 0, "Check hr_complex_flt -- hr_complex_int\n"); \
result += __fname__##_tmpl<hr_complex_flt, hr_complex_flt>(EPSILON_FLT_TEST); \
lprintf("TEST", 0, "Check hr_complex_int -- hr_complex\n"); \
result += __fname__##_tmpl<hr_complex_int, hr_complex>(EPSILON_TEST); \
lprintf("TEST", 0, "Check hr_complex_int -- hr_complex_flt\n"); \
result += __fname__##_tmpl<hr_complex_int, hr_complex_flt>(EPSILON_FLT_TEST); \
lprintf("TEST", 0, "Check hr_complex_int -- hr_complex_int\n"); \
result += __fname__##_tmpl<hr_complex_int, hr_complex_int>(0.0); \
return result; \
}

Expand Down
4 changes: 0 additions & 4 deletions TestProgram/ComplexNumbers/check_complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ int main(int argc, char *argv[]) {
return_value += test_overload_div_hr_complex();
return_value += test_negate();
return_value += test_cast_double();
return_value += test_overload_plus_rhs_integer();
return_value += test_overload_plus_lhs_integer();
return_value += test_overload_div_rhs_integer();
return_value += test_overload_div_lhs_integer();
return_value += test_I_add();
return_value += test_I_prod();

Expand Down

0 comments on commit c1f43d1

Please sign in to comment.