/usr/include/falcon/complex.h is in falconpl-dev 0.9.6.9-git20120606-2.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /*
FALCON - The Falcon Programming Language.
FILE: complex.h
Complex class for Falcon
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Wed, 09 Sep 2009 23:09:25 +0200
-------------------------------------------------------------------
(C) Copyright 2009: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
/** \file
Complex class for Falcon
Internal logic functions - declarations.
*/
#ifndef FALCON_complex_H
#define FALCON_complex_H
#include <falcon/setup.h>
#include <falcon/types.h>
#include <falcon/basealloc.h>
namespace Falcon {
class Complex: public BaseAlloc
{
numeric m_real;
numeric m_imag;
void throw_div_by_zero();
public:
Complex( numeric r=0, numeric i=0 ):
m_real(r),
m_imag(i)
{}
Complex( const Complex& other ):
m_real( other.m_real ),
m_imag( other.m_imag )
{}
~Complex ( ) {}
inline numeric real() const { return m_real; }
inline numeric imag() const { return m_imag; }
inline void real( numeric r ) { m_real = r; }
inline void imag( numeric i ) { m_imag = i; }
//=============================================
// Math operators
//
inline Complex operator +( const Complex &other )
{
return Complex( m_real + other.m_real, m_imag + other.m_imag );
}
inline Complex operator -( const Complex &other )
{
return Complex( m_real - other.m_real, m_imag - other.m_imag );
}
// (ac−bd,bc+ad)
inline Complex operator *( const Complex &other )
{
return Complex( m_real * other.m_real - m_imag * other.m_imag,
m_imag * other.m_real + m_real * other.m_imag );
}
//(ac+bd+i(bc-ad))/(c2+d2)
inline Complex operator /( const Complex &other )
{
numeric divisor = other.m_real*other.m_real + other.m_imag * other.m_imag;
if ( divisor == 0 )
throw_div_by_zero(); // don't want this inline.
return Complex(
(m_real * other.m_real + m_imag * other.m_imag) / divisor,
(m_imag * other.m_real - m_real * other.m_imag) / divisor );
}
numeric abs() const;
Complex conj() const;
//=============================================
// Assignment operators
//
inline Complex &operator =( const Complex &other )
{
m_real = other.m_real;
m_imag = other.m_imag;
return *this;
}
inline Complex& operator +=( const Complex &other )
{
m_real += other.m_real;
m_imag += other.m_imag;
return *this;
}
inline Complex& operator -=( const Complex &other )
{
m_real -= other.m_real;
m_imag -= other.m_imag;
return *this;
}
inline Complex& operator *=( const Complex &other )
{
m_real = m_real * other.m_real - m_imag * other.m_imag;
m_imag = m_imag * other.m_real + m_real * other.m_imag;
return *this;
}
inline Complex& operator /=( const Complex &other )
{
*this = *this / other;
return *this;
}
//=============================================
// Relational operators
//
inline bool operator ==( const Complex &other )
{
return m_real == other.m_real && m_imag == other.m_imag;
}
inline bool operator !=( const Complex &other )
{
return m_real != other.m_real || m_imag != other.m_imag;
}
inline bool operator >( const Complex &other )
{
return m_real > other.m_real || (m_real == other.m_real && m_imag > other.m_imag);
}
inline bool operator >=( const Complex &other )
{
return m_real >= other.m_real || (m_real == other.m_real && m_imag >= other.m_imag);
}
inline bool operator <( const Complex &other )
{
return m_real < other.m_real || (m_real == other.m_real && m_imag < other.m_imag);
}
inline bool operator <=( const Complex &other )
{
return m_real <= other.m_real || (m_real == other.m_real && m_imag <= other.m_imag);
}
};
}
#endif
/* end of complex.h */
|