complex.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2014, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 #include "af/defines.h"
12 
13 
14 #ifdef __cplusplus
15 #include <ostream>
16 #include <istream>
17 
18 namespace af{
19 #endif
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 typedef struct af_cfloat {
25  float real;
26  float imag;
27 #ifdef __cplusplus
28  af_cfloat(const float real = 0, const float imag = 0) :real(real), imag(imag) {};
29 #endif
30 } af_cfloat;
31 
32 typedef struct af_cdouble {
33  double real;
34  double imag;
35 #ifdef __cplusplus
36  af_cdouble(const double real = 0, const double imag = 0) :real(real), imag(imag) {}
37 #endif
38 } af_cdouble;
39 #ifdef __cplusplus
40 }
41 #endif
42 
43 #ifdef __cplusplus
46 
47 AFAPI float real(af_cfloat val);
48 AFAPI double real(af_cdouble val);
49 
50 AFAPI float imag(af_cfloat val);
51 AFAPI double imag(af_cdouble val);
52 
53 AFAPI af::cfloat operator+(const af::cfloat &lhs, const af::cfloat &rhs);
54 AFAPI af::cfloat operator+(const af::cfloat &lhs, const double &rhs);
55 AFAPI af::cdouble operator+(const af::cdouble &lhs, const af::cdouble &rhs);
56 AFAPI af::cdouble operator+(const af::cdouble &lhs, const double &rhs);
57 
58 AFAPI af::cfloat operator-(const af::cfloat &lhs, const af::cfloat &rhs);
59 AFAPI af::cdouble operator-(const af::cdouble &lhs, const af::cdouble &rhs);
60 
61 AFAPI cfloat operator*(const cfloat &lhs, const cfloat &rhs);
62 AFAPI cdouble operator*(const cdouble &lhs, const cdouble &rhs);
63 
64 AFAPI cfloat operator/(const cfloat &lhs, const cfloat &rhs);
65 AFAPI af::cfloat operator/(const af::cfloat &lhs, const float &rhs);
66 AFAPI cdouble operator/(const cdouble &lhs, const cdouble &rhs);
67 AFAPI af::cdouble operator/(const af::cdouble &lhs, const double &rhs);
68 
69 AFAPI bool operator==(const cfloat &lhs, const cfloat &rhs);
70 AFAPI bool operator==(const cdouble &lhs, const cdouble &rhs);
71 
72 AFAPI bool operator!=(const cfloat &lhs, const cfloat &rhs);
73 AFAPI bool operator!=(const cdouble &lhs, const cdouble &rhs);
74 
75 AFAPI std::istream& operator>> (std::istream &is, cfloat &in);
76 AFAPI std::istream& operator>> (std::istream &is, cdouble &in);
77 
78 AFAPI std::ostream& operator<< (std::ostream &os, const cfloat &in);
79 AFAPI std::ostream& operator<< (std::ostream &os, const cdouble &in);
80 
81 
82 AFAPI float abs(const cfloat &val);
83 AFAPI double abs(const cdouble &val);
84 
85 AFAPI cfloat conj(const cfloat &val);
86 AFAPI cdouble conj(const cdouble &val);
87 
88 }
89 #endif
Definition: algorithm.h:14
double imag
Definition: complex.h:34
AFAPI array operator/(const array &lhs, const array &rhs)
Divides two arrays or an array and a value.
AFAPI array operator==(const array &lhs, const array &rhs)
Performs an equality operation on two arrays or an array and a value.
AFAPI cfloat conj(const cfloat &val)
Definition: complex.h:32
af::af_cfloat cfloat
Definition: complex.h:44
AFAPI array operator*(const array &lhs, const array &rhs)
Multiplies two arrays or an array and a value.
af_cfloat(const float real=0, const float imag=0)
Definition: complex.h:28
AFAPI array operator>>(const array &lhs, const array &rhs)
Performs an right shift operation on two arrays or an array and a value.
float imag
Definition: complex.h:26
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
AFAPI array operator!=(const array &lhs, const array &rhs)
Performs an inequality operation on two arrays or an array and a value.
struct af::af_cdouble af_cdouble
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
#define AFAPI
Definition: defines.h:31
AFAPI array operator<<(const array &lhs, const array &rhs)
Performs an left shift operation on two arrays or an array and a value.
double real
Definition: complex.h:33
Definition: complex.h:24
float real
Definition: complex.h:25
AFAPI array abs(const array &in)
C++ Interface for absolute value.
af_cdouble(const double real=0, const double imag=0)
Definition: complex.h:36
struct af::af_cfloat af_cfloat
af::af_cdouble cdouble
Definition: complex.h:45
AFAPI array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
AFAPI array operator+(const array &lhs, const array &rhs)
Adds two arrays or an array and a value.