OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
TestGSLComplex.cpp File Reference

Unit tests for GSL complex number operations. More...

#include <gtest/gtest.h>
#include <cmath>
#include <complex>
#include "Utilities/GSLComplex.h"
Include dependency graph for TestGSLComplex.cpp:

Go to the source code of this file.

Classes

class  GSLComplexTest
 

Functions

 TEST_F (GSLComplexTest, CreateRectangular)
 
 TEST_F (GSLComplexTest, CreatePolar)
 
 TEST_F (GSLComplexTest, Addition)
 
 TEST_F (GSLComplexTest, Subtraction)
 
 TEST_F (GSLComplexTest, Multiplication)
 
 TEST_F (GSLComplexTest, Division)
 
 TEST_F (GSLComplexTest, Conjugate)
 
 TEST_F (GSLComplexTest, Absolute)
 
 TEST_F (GSLComplexTest, Argument)
 
 TEST_F (GSLComplexTest, Tanh)
 
 TEST_F (GSLComplexTest, Exp)
 
 TEST_F (GSLComplexTest, Log)
 

Detailed Description

Unit tests for GSL complex number operations.

This file contains unit tests for GSL-compatible complex number operations. The implementation provides a wrapper around std::complex<double> with GSL-compatible function names and interfaces.

Test:
GSLComplexTest::CreateRectangular Tests creation of complex numbers in rectangular form \(z = a + bi\). Verifies that real and imaginary parts are correctly stored and can be retrieved using GSL_REAL and GSL_IMAG macros.
Test:
GSLComplexTest::CreatePolar Tests creation of complex numbers in polar form \(z = r e^{i\theta}\). Verifies that polar coordinates are correctly converted to rectangular form: \(a = r\cos\theta\), \(b = r\sin\theta\).
Test:
GSLComplexTest::Addition Tests complex number addition: \((a_1 + b_1i) + (a_2 + b_2i) = (a_1+a_2) + (b_1+b_2)i\). Verifies correct computation of real and imaginary parts.
Test:
GSLComplexTest::Subtraction Tests complex number subtraction: \((a_1 + b_1i) - (a_2 + b_2i) = (a_1-a_2) + (b_1-b_2)i\).
Test:
GSLComplexTest::Multiplication Tests complex number multiplication using the identity: \((a_1 + b_1i)(a_2 + b_2i) = (a_1a_2 - b_1b_2) + (a_1b_2 + a_2b_1)i\).
Test:
GSLComplexTest::Division Tests complex number division. Verifies special case: \(1/i = -i\).
Test:
GSLComplexTest::Conjugate Tests complex conjugate: \(\overline{a + bi} = a - bi\). Verifies that the real part remains unchanged and the imaginary part is negated.
Test:
GSLComplexTest::Absolute Tests complex absolute value (modulus): \(|a + bi| = \sqrt{a^2 + b^2}\). Verifies correct computation for a 3-4-5 right triangle case.
Test:
GSLComplexTest::Argument Tests complex argument (phase): \(\arg(a + bi) = \arctan(b/a)\). Verifies correct computation for \(1 + i\) (should be \(\pi/4\)).
Test:
GSLComplexTest::Tanh Tests complex hyperbolic tangent function. Verifies behavior for real arguments ( \(\tanh(1)\)) and purely imaginary arguments ( \(\tanh(i) = i\tan(1)\)).
Test:
GSLComplexTest::Exp Tests complex exponential function. Verifies Euler's identity: \(e^{i\pi} = -1\).
Test:
GSLComplexTest::Log Tests complex logarithm function. Verifies that \(\ln(1) = 0\) for the principal branch.

Definition in file TestGSLComplex.cpp.

Function Documentation

◆ TEST_F() [1/12]

TEST_F ( GSLComplexTest  ,
Absolute   
)

Definition at line 129 of file TestGSLComplex.cpp.

References gsl_complex_abs(), and gsl_complex_rect().

Here is the call graph for this function:

◆ TEST_F() [2/12]

TEST_F ( GSLComplexTest  ,
Addition   
)

Definition at line 83 of file TestGSLComplex.cpp.

References gsl_complex_add(), gsl_complex_rect(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [3/12]

TEST_F ( GSLComplexTest  ,
Argument   
)

Definition at line 136 of file TestGSLComplex.cpp.

References gsl_complex_arg(), and gsl_complex_rect().

Here is the call graph for this function:

◆ TEST_F() [4/12]

TEST_F ( GSLComplexTest  ,
Conjugate   
)

Definition at line 121 of file TestGSLComplex.cpp.

References gsl_complex_conjugate(), gsl_complex_rect(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [5/12]

TEST_F ( GSLComplexTest  ,
CreatePolar   
)

Definition at line 77 of file TestGSLComplex.cpp.

References gsl_complex_polar(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [6/12]

TEST_F ( GSLComplexTest  ,
CreateRectangular   
)

Definition at line 71 of file TestGSLComplex.cpp.

References gsl_complex_rect(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [7/12]

TEST_F ( GSLComplexTest  ,
Division   
)

Definition at line 111 of file TestGSLComplex.cpp.

References gsl_complex_div(), gsl_complex_rect(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [8/12]

TEST_F ( GSLComplexTest  ,
Exp   
)

Definition at line 159 of file TestGSLComplex.cpp.

References gsl_complex_exp(), gsl_complex_rect(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [9/12]

TEST_F ( GSLComplexTest  ,
Log   
)

Definition at line 168 of file TestGSLComplex.cpp.

References gsl_complex_log(), gsl_complex_rect(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [10/12]

TEST_F ( GSLComplexTest  ,
Multiplication   
)

Definition at line 101 of file TestGSLComplex.cpp.

References gsl_complex_mul(), gsl_complex_rect(), GSL_IMAG, GSL_REAL, and prod().

Here is the call graph for this function:

◆ TEST_F() [11/12]

TEST_F ( GSLComplexTest  ,
Subtraction   
)

Definition at line 92 of file TestGSLComplex.cpp.

References gsl_complex_rect(), gsl_complex_sub(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function:

◆ TEST_F() [12/12]

TEST_F ( GSLComplexTest  ,
Tanh   
)

Definition at line 143 of file TestGSLComplex.cpp.

References gsl_complex_rect(), gsl_complex_tanh(), GSL_IMAG, and GSL_REAL.

Here is the call graph for this function: