Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members
alglib::complex Class Reference

#include <ap.h>

Public Member Functions

 complex ()
 
 complex (const double &_x)
 
 complex (const double &_x, const double &_y)
 
 complex (const complex &z)
 
complexoperator= (const double &v)
 
complexoperator+= (const double &v)
 
complexoperator-= (const double &v)
 
complexoperator*= (const double &v)
 
complexoperator/= (const double &v)
 
complexoperator= (const complex &z)
 
complexoperator+= (const complex &z)
 
complexoperator-= (const complex &z)
 
complexoperator*= (const complex &z)
 
complexoperator/= (const complex &z)
 
alglib_impl::ae_complexc_ptr ()
 
const alglib_impl::ae_complexc_ptr () const
 
std::string tostring (int dps) const
 

Public Attributes

double x
 
double y
 

Detailed Description

Definition at line 916 of file ap.h.

Constructor & Destructor Documentation

◆ complex() [1/4]

alglib::complex::complex ( )

Definition at line 4727 of file ap.cpp.

4727  :x(0.0),y(0.0)
4728 {
4729 }
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ complex() [2/4]

alglib::complex::complex ( const double &  _x)

Definition at line 4731 of file ap.cpp.

4731  :x(_x),y(0.0)
4732 {
4733 }
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ complex() [3/4]

alglib::complex::complex ( const double &  _x,
const double &  _y 
)

Definition at line 4735 of file ap.cpp.

4735  :x(_x),y(_y)
4736 {
4737 }
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ complex() [4/4]

alglib::complex::complex ( const complex z)

Definition at line 4739 of file ap.cpp.

4739  :x(z.x),y(z.y)
4740 {
4741 }
double z
double y
Definition: ap.h:941
double x
Definition: ap.h:941

Member Function Documentation

◆ c_ptr() [1/2]

alglib_impl::ae_complex * alglib::complex::c_ptr ( )

Definition at line 4828 of file ap.cpp.

4829 {
4830  return (alglib_impl::ae_complex*)this;
4831 }

◆ c_ptr() [2/2]

const alglib_impl::ae_complex * alglib::complex::c_ptr ( ) const

Definition at line 4833 of file ap.cpp.

4834 {
4835  return (const alglib_impl::ae_complex*)this;
4836 }

◆ operator*=() [1/2]

alglib::complex & alglib::complex::operator*= ( const double &  v)

Definition at line 4762 of file ap.cpp.

4763 {
4764  x *= v;
4765  y *= v;
4766  return *this;
4767 }
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ operator*=() [2/2]

alglib::complex & alglib::complex::operator*= ( const complex z)

Definition at line 4797 of file ap.cpp.

4798 {
4799  double t = x*z.x-y*z.y;
4800  y = x*z.y+y*z.x;
4801  x = t;
4802  return *this;
4803 }
double z
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ operator+=() [1/2]

alglib::complex & alglib::complex::operator+= ( const double &  v)

Definition at line 4750 of file ap.cpp.

4751 {
4752  x += v;
4753  return *this;
4754 }
double x
Definition: ap.h:941

◆ operator+=() [2/2]

alglib::complex & alglib::complex::operator+= ( const complex z)

Definition at line 4783 of file ap.cpp.

4784 {
4785  x += z.x;
4786  y += z.y;
4787  return *this;
4788 }
double z
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ operator-=() [1/2]

alglib::complex & alglib::complex::operator-= ( const double &  v)

Definition at line 4756 of file ap.cpp.

4757 {
4758  x -= v;
4759  return *this;
4760 }
double x
Definition: ap.h:941

◆ operator-=() [2/2]

alglib::complex & alglib::complex::operator-= ( const complex z)

Definition at line 4790 of file ap.cpp.

4791 {
4792  x -= z.x;
4793  y -= z.y;
4794  return *this;
4795 }
double z
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ operator/=() [1/2]

alglib::complex & alglib::complex::operator/= ( const double &  v)

Definition at line 4769 of file ap.cpp.

4770 {
4771  x /= v;
4772  y /= v;
4773  return *this;
4774 }
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ operator/=() [2/2]

alglib::complex & alglib::complex::operator/= ( const complex z)

Definition at line 4805 of file ap.cpp.

4806 {
4807  alglib::complex result;
4808  double e;
4809  double f;
4810  if( fabs(z.y)<fabs(z.x) )
4811  {
4812  e = z.y/z.x;
4813  f = z.x+z.y*e;
4814  result.x = (x+y*e)/f;
4815  result.y = (y-x*e)/f;
4816  }
4817  else
4818  {
4819  e = z.x/z.y;
4820  f = z.y+z.x*e;
4821  result.x = (y+x*e)/f;
4822  result.y = (-x+y*e)/f;
4823  }
4824  *this = result;
4825  return *this;
4826 }
double * f
double z
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ operator=() [1/2]

alglib::complex & alglib::complex::operator= ( const double &  v)

Definition at line 4743 of file ap.cpp.

4744 {
4745  x = v;
4746  y = 0.0;
4747  return *this;
4748 }
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ operator=() [2/2]

alglib::complex & alglib::complex::operator= ( const complex z)

Definition at line 4776 of file ap.cpp.

4777 {
4778  x = z.x;
4779  y = z.y;
4780  return *this;
4781 }
double z
double y
Definition: ap.h:941
double x
Definition: ap.h:941

◆ tostring()

std::string alglib::complex::tostring ( int  dps) const

Definition at line 4838 of file ap.cpp.

4839 {
4840  char mask[32];
4841  char buf_x[32];
4842  char buf_y[32];
4843  char buf_zero[32];
4844  int dps = _dps>=0 ? _dps : -_dps;
4845  if( dps<=0 || dps>=20 )
4846  throw ap_error("complex::tostring(): incorrect dps");
4847 
4848  // handle IEEE special quantities
4849  if( fp_isnan(x) || fp_isnan(y) )
4850  return "NAN";
4851  if( fp_isinf(x) || fp_isinf(y) )
4852  return "INF";
4853 
4854  // generate mask
4855  if( sprintf(mask, "%%.%d%s", dps, _dps>=0 ? "f" : "e")>=(int)sizeof(mask) )
4856  throw ap_error("complex::tostring(): buffer overflow");
4857 
4858  // print |x|, |y| and zero with same mask and compare
4859  if( sprintf(buf_x, mask, (double)(fabs(x)))>=(int)sizeof(buf_x) )
4860  throw ap_error("complex::tostring(): buffer overflow");
4861  if( sprintf(buf_y, mask, (double)(fabs(y)))>=(int)sizeof(buf_y) )
4862  throw ap_error("complex::tostring(): buffer overflow");
4863  if( sprintf(buf_zero, mask, (double)0)>=(int)sizeof(buf_zero) )
4864  throw ap_error("complex::tostring(): buffer overflow");
4865 
4866  // different zero/nonzero patterns
4867  if( strcmp(buf_x,buf_zero)!=0 && strcmp(buf_y,buf_zero)!=0 )
4868  return std::string(x>0 ? "" : "-")+buf_x+(y>0 ? "+" : "-")+buf_y+"i";
4869  if( strcmp(buf_x,buf_zero)!=0 && strcmp(buf_y,buf_zero)==0 )
4870  return std::string(x>0 ? "" : "-")+buf_x;
4871  if( strcmp(buf_x,buf_zero)==0 && strcmp(buf_y,buf_zero)!=0 )
4872  return std::string(y>0 ? "" : "-")+buf_y+"i";
4873  return std::string("0");
4874 }
bool fp_isinf(double x)
Definition: ap.cpp:7344
bool fp_isnan(double x)
Definition: ap.cpp:7329
double y
Definition: ap.h:941
double x
Definition: ap.h:941

Member Data Documentation

◆ x

double alglib::complex::x

Definition at line 941 of file ap.h.

◆ y

double alglib::complex::y

Definition at line 941 of file ap.h.


The documentation for this class was generated from the following files: