Loading...
Searching...
No Matches
complex number support
Dense LA » MAGMA BLAS and Auxiliary » Math functions (sqrt, etc.), O(1) work

In C++, including magma_operators.h defines the usual unary and binary operators for complex numbers: +, +=, -, -=, *, *=, /, /=, ==, !=. More...

## Macros

#define | MAGMA_Z_MAKE(r, i)
#define | MAGMA_Z_REAL(a)
#define | MAGMA_Z_IMAG(a)
#define | MAGMA_Z_ADD(a, b)
#define | MAGMA_Z_SUB(a, b)
#define | MAGMA_Z_MUL(a, b)
#define | MAGMA_Z_DIV(a, b)
#define | MAGMA_Z_ABS(a)
#define | MAGMA_Z_ABS1(a)
#define | MAGMA_Z_CONJ(a)

## Functions

__host__ static __device__ double | real (const magmaDoubleComplex &x)
__host__ static __device__ double | imag (const double &x)
__host__ static __device__ double | conj (const double &x)
__host__ static __device__ double | fabs (const magmaDoubleComplex &x)
__host__ static __device__ double | abs1 (const magmaDoubleComplex &x)

## Detailed Description

In C++, including magma_operators.h defines the usual unary and binary operators for complex numbers: +, +=, -, -=, *, *=, /, /=, ==, !=.

Additionally, real(), imag(), conj(), fabs(), and abs1() are defined to apply to both complex and real numbers.

In C, there are equivalent macros: MAGMA_Z_{MAKE, REAL, IMAG, ADD, SUB, MUL, DIV, ABS, ABS1, CONJ} for double-complex, MAGMA_C_{...} for float-complex, MAGMA_D_{...} for double, MAGMA_S_{...} for float.

Just the double-complex versions are documented here.

## Macro Definition Documentation

## MAGMA_Z_MAKE

#define MAGMA_Z_MAKE | ( |  | r,
|  |  | i )

Returns
  complex number r + i*sqrt(-1).

## MAGMA_Z_REAL

#define MAGMA_Z_REAL | ( |  | a | ) |

Returns
  real component of a.

## MAGMA_Z_IMAG

#define MAGMA_Z_IMAG | ( |  | a | ) |

Returns
  imaginary component of a.

## MAGMA_Z_ADD

#define MAGMA_Z_ADD | ( |  | a,
|  |  | b )

Returns
  (a + b).

## MAGMA_Z_SUB

#define MAGMA_Z_SUB | ( |  | a,
|  |  | b )

Returns
  (a - b).

## MAGMA_Z_MUL

#define MAGMA_Z_MUL | ( |  | a,
|  |  | b )

Returns
  (a * b).

## MAGMA_Z_DIV

#define MAGMA_Z_DIV | ( |  | a,
|  |  | b )

Returns
  (a / b).

## MAGMA_Z_ABS

#define MAGMA_Z_ABS | ( |  | a | ) |

Returns
  absolute value, |a| = sqrt( real(a)^2 + imag(a)^2 ).

## MAGMA_Z_ABS1

#define MAGMA_Z_ABS1 | ( |  | a | ) |

Returns
  1-norm absolute value, | real(a) | + | imag(a) |.

## MAGMA_Z_CONJ

#define MAGMA_Z_CONJ | ( |  | a | ) |

Returns
  conjugate of a.

## Function Documentation

## real()

__host__ static __device__ double real | ( | const magmaDoubleComplex & | x | ) |

inline static

Returns
  real component of complex number x; x for real number.

## imag()

__host__ static __device__ double imag | ( | const double & | x | ) |

inline static

Returns
  imaginary component of complex number x; 0 for real number.

## conj()

__host__ static __device__ double conj | ( | const double & | x | ) |

inline static

Returns
  conjugate of complex number x; x for real number.

## fabs()

__host__ static __device__ double fabs | ( | const magmaDoubleComplex & | x | ) |

inline static

Returns
  2-norm absolute value of complex number x: sqrt( real(x)^2 + imag(x)^2 ). math.h or cmath provide fabs for real numbers.

## abs1()

__host__ static __device__ double abs1 | ( | const magmaDoubleComplex & | x | ) |

inline static

Returns
  1-norm absolute value of complex nmuber x: | real(x) | + | imag(x) |.