1# This file was automatically generated by SWIG (http://www.swig.org). 2# Version 4.0.1 3# 4# Do not make changes to this file unless you know what you are doing--modify 5# the SWIG interface file instead. 6 7package Math::GSL::Complex; 8use base qw(Exporter); 9use base qw(DynaLoader); 10package Math::GSL::Complexc; 11bootstrap Math::GSL::Complex; 12package Math::GSL::Complex; 13@EXPORT = qw(); 14 15# ---------- BASE METHODS ------------- 16 17package Math::GSL::Complex; 18 19sub TIEHASH { 20 my ($classname,$obj) = @_; 21 return bless $obj, $classname; 22} 23 24sub CLEAR { } 25 26sub FIRSTKEY { } 27 28sub NEXTKEY { } 29 30sub FETCH { 31 my ($self,$field) = @_; 32 my $member_func = "swig_${field}_get"; 33 $self->$member_func(); 34} 35 36sub STORE { 37 my ($self,$field,$newval) = @_; 38 my $member_func = "swig_${field}_set"; 39 $self->$member_func($newval); 40} 41 42sub this { 43 my $ptr = shift; 44 return tied(%$ptr); 45} 46 47 48# ------- FUNCTION WRAPPERS -------- 49 50package Math::GSL::Complex; 51 52*gsl_error = *Math::GSL::Complexc::gsl_error; 53*gsl_stream_printf = *Math::GSL::Complexc::gsl_stream_printf; 54*gsl_strerror = *Math::GSL::Complexc::gsl_strerror; 55*gsl_set_error_handler = *Math::GSL::Complexc::gsl_set_error_handler; 56*gsl_set_error_handler_off = *Math::GSL::Complexc::gsl_set_error_handler_off; 57*gsl_set_stream_handler = *Math::GSL::Complexc::gsl_set_stream_handler; 58*gsl_set_stream = *Math::GSL::Complexc::gsl_set_stream; 59*gsl_complex_polar = *Math::GSL::Complexc::gsl_complex_polar; 60*gsl_complex_rect = *Math::GSL::Complexc::gsl_complex_rect; 61*gsl_complex_arg = *Math::GSL::Complexc::gsl_complex_arg; 62*gsl_complex_abs = *Math::GSL::Complexc::gsl_complex_abs; 63*gsl_complex_abs2 = *Math::GSL::Complexc::gsl_complex_abs2; 64*gsl_complex_logabs = *Math::GSL::Complexc::gsl_complex_logabs; 65*gsl_complex_add = *Math::GSL::Complexc::gsl_complex_add; 66*gsl_complex_sub = *Math::GSL::Complexc::gsl_complex_sub; 67*gsl_complex_mul = *Math::GSL::Complexc::gsl_complex_mul; 68*gsl_complex_div = *Math::GSL::Complexc::gsl_complex_div; 69*gsl_complex_add_real = *Math::GSL::Complexc::gsl_complex_add_real; 70*gsl_complex_sub_real = *Math::GSL::Complexc::gsl_complex_sub_real; 71*gsl_complex_mul_real = *Math::GSL::Complexc::gsl_complex_mul_real; 72*gsl_complex_div_real = *Math::GSL::Complexc::gsl_complex_div_real; 73*gsl_complex_add_imag = *Math::GSL::Complexc::gsl_complex_add_imag; 74*gsl_complex_sub_imag = *Math::GSL::Complexc::gsl_complex_sub_imag; 75*gsl_complex_mul_imag = *Math::GSL::Complexc::gsl_complex_mul_imag; 76*gsl_complex_div_imag = *Math::GSL::Complexc::gsl_complex_div_imag; 77*gsl_complex_conjugate = *Math::GSL::Complexc::gsl_complex_conjugate; 78*gsl_complex_inverse = *Math::GSL::Complexc::gsl_complex_inverse; 79*gsl_complex_negative = *Math::GSL::Complexc::gsl_complex_negative; 80*gsl_complex_sqrt = *Math::GSL::Complexc::gsl_complex_sqrt; 81*gsl_complex_sqrt_real = *Math::GSL::Complexc::gsl_complex_sqrt_real; 82*gsl_complex_pow = *Math::GSL::Complexc::gsl_complex_pow; 83*gsl_complex_pow_real = *Math::GSL::Complexc::gsl_complex_pow_real; 84*gsl_complex_exp = *Math::GSL::Complexc::gsl_complex_exp; 85*gsl_complex_log = *Math::GSL::Complexc::gsl_complex_log; 86*gsl_complex_log10 = *Math::GSL::Complexc::gsl_complex_log10; 87*gsl_complex_log_b = *Math::GSL::Complexc::gsl_complex_log_b; 88*gsl_complex_sin = *Math::GSL::Complexc::gsl_complex_sin; 89*gsl_complex_cos = *Math::GSL::Complexc::gsl_complex_cos; 90*gsl_complex_sec = *Math::GSL::Complexc::gsl_complex_sec; 91*gsl_complex_csc = *Math::GSL::Complexc::gsl_complex_csc; 92*gsl_complex_tan = *Math::GSL::Complexc::gsl_complex_tan; 93*gsl_complex_cot = *Math::GSL::Complexc::gsl_complex_cot; 94*gsl_complex_arcsin = *Math::GSL::Complexc::gsl_complex_arcsin; 95*gsl_complex_arcsin_real = *Math::GSL::Complexc::gsl_complex_arcsin_real; 96*gsl_complex_arccos = *Math::GSL::Complexc::gsl_complex_arccos; 97*gsl_complex_arccos_real = *Math::GSL::Complexc::gsl_complex_arccos_real; 98*gsl_complex_arcsec = *Math::GSL::Complexc::gsl_complex_arcsec; 99*gsl_complex_arcsec_real = *Math::GSL::Complexc::gsl_complex_arcsec_real; 100*gsl_complex_arccsc = *Math::GSL::Complexc::gsl_complex_arccsc; 101*gsl_complex_arccsc_real = *Math::GSL::Complexc::gsl_complex_arccsc_real; 102*gsl_complex_arctan = *Math::GSL::Complexc::gsl_complex_arctan; 103*gsl_complex_arccot = *Math::GSL::Complexc::gsl_complex_arccot; 104*gsl_complex_sinh = *Math::GSL::Complexc::gsl_complex_sinh; 105*gsl_complex_cosh = *Math::GSL::Complexc::gsl_complex_cosh; 106*gsl_complex_sech = *Math::GSL::Complexc::gsl_complex_sech; 107*gsl_complex_csch = *Math::GSL::Complexc::gsl_complex_csch; 108*gsl_complex_tanh = *Math::GSL::Complexc::gsl_complex_tanh; 109*gsl_complex_coth = *Math::GSL::Complexc::gsl_complex_coth; 110*gsl_complex_arcsinh = *Math::GSL::Complexc::gsl_complex_arcsinh; 111*gsl_complex_arccosh = *Math::GSL::Complexc::gsl_complex_arccosh; 112*gsl_complex_arccosh_real = *Math::GSL::Complexc::gsl_complex_arccosh_real; 113*gsl_complex_arcsech = *Math::GSL::Complexc::gsl_complex_arcsech; 114*gsl_complex_arccsch = *Math::GSL::Complexc::gsl_complex_arccsch; 115*gsl_complex_arctanh = *Math::GSL::Complexc::gsl_complex_arctanh; 116*gsl_complex_arctanh_real = *Math::GSL::Complexc::gsl_complex_arctanh_real; 117*gsl_complex_arccoth = *Math::GSL::Complexc::gsl_complex_arccoth; 118*new_doubleArray = *Math::GSL::Complexc::new_doubleArray; 119*delete_doubleArray = *Math::GSL::Complexc::delete_doubleArray; 120*doubleArray_getitem = *Math::GSL::Complexc::doubleArray_getitem; 121*doubleArray_setitem = *Math::GSL::Complexc::doubleArray_setitem; 122 123############# Class : Math::GSL::Complex::gsl_complex ############## 124 125package Math::GSL::Complex::gsl_complex; 126use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); 127@ISA = qw( Math::GSL::Complex ); 128%OWNER = (); 129%ITERATORS = (); 130*swig_dat_get = *Math::GSL::Complexc::gsl_complex_dat_get; 131*swig_dat_set = *Math::GSL::Complexc::gsl_complex_dat_set; 132sub new { 133 my $pkg = shift; 134 my $self = Math::GSL::Complexc::new_gsl_complex(@_); 135 bless $self, $pkg if defined($self); 136} 137 138sub DESTROY { 139 return unless $_[0]->isa('HASH'); 140 my $self = tied(%{$_[0]}); 141 return unless defined $self; 142 delete $ITERATORS{$self}; 143 if (exists $OWNER{$self}) { 144 Math::GSL::Complexc::delete_gsl_complex($self); 145 delete $OWNER{$self}; 146 } 147} 148 149sub DISOWN { 150 my $self = shift; 151 my $ptr = tied(%$self); 152 delete $OWNER{$ptr}; 153} 154 155sub ACQUIRE { 156 my $self = shift; 157 my $ptr = tied(%$self); 158 $OWNER{$ptr} = 1; 159} 160 161 162############# Class : Math::GSL::Complex::gsl_complex_long_double ############## 163 164package Math::GSL::Complex::gsl_complex_long_double; 165use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); 166@ISA = qw( Math::GSL::Complex ); 167%OWNER = (); 168%ITERATORS = (); 169*swig_dat_get = *Math::GSL::Complexc::gsl_complex_long_double_dat_get; 170*swig_dat_set = *Math::GSL::Complexc::gsl_complex_long_double_dat_set; 171sub new { 172 my $pkg = shift; 173 my $self = Math::GSL::Complexc::new_gsl_complex_long_double(@_); 174 bless $self, $pkg if defined($self); 175} 176 177sub DESTROY { 178 return unless $_[0]->isa('HASH'); 179 my $self = tied(%{$_[0]}); 180 return unless defined $self; 181 delete $ITERATORS{$self}; 182 if (exists $OWNER{$self}) { 183 Math::GSL::Complexc::delete_gsl_complex_long_double($self); 184 delete $OWNER{$self}; 185 } 186} 187 188sub DISOWN { 189 my $self = shift; 190 my $ptr = tied(%$self); 191 delete $OWNER{$ptr}; 192} 193 194sub ACQUIRE { 195 my $self = shift; 196 my $ptr = tied(%$self); 197 $OWNER{$ptr} = 1; 198} 199 200 201############# Class : Math::GSL::Complex::gsl_complex_float ############## 202 203package Math::GSL::Complex::gsl_complex_float; 204use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); 205@ISA = qw( Math::GSL::Complex ); 206%OWNER = (); 207%ITERATORS = (); 208*swig_dat_get = *Math::GSL::Complexc::gsl_complex_float_dat_get; 209*swig_dat_set = *Math::GSL::Complexc::gsl_complex_float_dat_set; 210sub new { 211 my $pkg = shift; 212 my $self = Math::GSL::Complexc::new_gsl_complex_float(@_); 213 bless $self, $pkg if defined($self); 214} 215 216sub DESTROY { 217 return unless $_[0]->isa('HASH'); 218 my $self = tied(%{$_[0]}); 219 return unless defined $self; 220 delete $ITERATORS{$self}; 221 if (exists $OWNER{$self}) { 222 Math::GSL::Complexc::delete_gsl_complex_float($self); 223 delete $OWNER{$self}; 224 } 225} 226 227sub DISOWN { 228 my $self = shift; 229 my $ptr = tied(%$self); 230 delete $OWNER{$ptr}; 231} 232 233sub ACQUIRE { 234 my $self = shift; 235 my $ptr = tied(%$self); 236 $OWNER{$ptr} = 1; 237} 238 239 240# ------- VARIABLE STUBS -------- 241 242package Math::GSL::Complex; 243 244*GSL_VERSION = *Math::GSL::Complexc::GSL_VERSION; 245*GSL_MAJOR_VERSION = *Math::GSL::Complexc::GSL_MAJOR_VERSION; 246*GSL_MINOR_VERSION = *Math::GSL::Complexc::GSL_MINOR_VERSION; 247*GSL_POSZERO = *Math::GSL::Complexc::GSL_POSZERO; 248*GSL_NEGZERO = *Math::GSL::Complexc::GSL_NEGZERO; 249*GSL_SUCCESS = *Math::GSL::Complexc::GSL_SUCCESS; 250*GSL_FAILURE = *Math::GSL::Complexc::GSL_FAILURE; 251*GSL_CONTINUE = *Math::GSL::Complexc::GSL_CONTINUE; 252*GSL_EDOM = *Math::GSL::Complexc::GSL_EDOM; 253*GSL_ERANGE = *Math::GSL::Complexc::GSL_ERANGE; 254*GSL_EFAULT = *Math::GSL::Complexc::GSL_EFAULT; 255*GSL_EINVAL = *Math::GSL::Complexc::GSL_EINVAL; 256*GSL_EFAILED = *Math::GSL::Complexc::GSL_EFAILED; 257*GSL_EFACTOR = *Math::GSL::Complexc::GSL_EFACTOR; 258*GSL_ESANITY = *Math::GSL::Complexc::GSL_ESANITY; 259*GSL_ENOMEM = *Math::GSL::Complexc::GSL_ENOMEM; 260*GSL_EBADFUNC = *Math::GSL::Complexc::GSL_EBADFUNC; 261*GSL_ERUNAWAY = *Math::GSL::Complexc::GSL_ERUNAWAY; 262*GSL_EMAXITER = *Math::GSL::Complexc::GSL_EMAXITER; 263*GSL_EZERODIV = *Math::GSL::Complexc::GSL_EZERODIV; 264*GSL_EBADTOL = *Math::GSL::Complexc::GSL_EBADTOL; 265*GSL_ETOL = *Math::GSL::Complexc::GSL_ETOL; 266*GSL_EUNDRFLW = *Math::GSL::Complexc::GSL_EUNDRFLW; 267*GSL_EOVRFLW = *Math::GSL::Complexc::GSL_EOVRFLW; 268*GSL_ELOSS = *Math::GSL::Complexc::GSL_ELOSS; 269*GSL_EROUND = *Math::GSL::Complexc::GSL_EROUND; 270*GSL_EBADLEN = *Math::GSL::Complexc::GSL_EBADLEN; 271*GSL_ENOTSQR = *Math::GSL::Complexc::GSL_ENOTSQR; 272*GSL_ESING = *Math::GSL::Complexc::GSL_ESING; 273*GSL_EDIVERGE = *Math::GSL::Complexc::GSL_EDIVERGE; 274*GSL_EUNSUP = *Math::GSL::Complexc::GSL_EUNSUP; 275*GSL_EUNIMPL = *Math::GSL::Complexc::GSL_EUNIMPL; 276*GSL_ECACHE = *Math::GSL::Complexc::GSL_ECACHE; 277*GSL_ETABLE = *Math::GSL::Complexc::GSL_ETABLE; 278*GSL_ENOPROG = *Math::GSL::Complexc::GSL_ENOPROG; 279*GSL_ENOPROGJ = *Math::GSL::Complexc::GSL_ENOPROGJ; 280*GSL_ETOLF = *Math::GSL::Complexc::GSL_ETOLF; 281*GSL_ETOLX = *Math::GSL::Complexc::GSL_ETOLX; 282*GSL_ETOLG = *Math::GSL::Complexc::GSL_ETOLG; 283*GSL_EOF = *Math::GSL::Complexc::GSL_EOF; 284 285use Scalar::Util 'blessed'; 286use Math::GSL::Errno qw/$GSL_SUCCESS gsl_strerror/; 287use Data::Dumper; 288 289use strict; 290use warnings; 291use Carp qw/croak/; 292use Scalar::Util 'blessed'; 293 294use overload 295 '*' => \&_multiplication, 296 '/' => \&_division, 297 '+' => \&_addition, 298 '-' => \&_subtract, 299 '==' => \&_equal, 300 '!=' => \&_not_equal, 301 fallback => 1; 302 303our @EXPORT_OK = qw( 304 gsl_complex_arg gsl_complex_abs gsl_complex_rect gsl_complex_polar doubleArray_getitem 305 gsl_complex_rect gsl_complex_polar gsl_complex_arg gsl_complex_abs gsl_complex_abs2 306 gsl_complex_logabs gsl_complex_add gsl_complex_sub gsl_complex_mul gsl_complex_div 307 gsl_complex_add_real gsl_complex_sub_real gsl_complex_mul_real gsl_complex_div_real 308 gsl_complex_add_imag gsl_complex_sub_imag gsl_complex_mul_imag gsl_complex_div_imag 309 gsl_complex_conjugate gsl_complex_inverse gsl_complex_negative gsl_complex_sqrt 310 gsl_complex_sqrt_real gsl_complex_pow gsl_complex_pow_real gsl_complex_exp 311 gsl_complex_log gsl_complex_log10 gsl_complex_log_b gsl_complex_sin 312 gsl_complex_cos gsl_complex_sec gsl_complex_csc gsl_complex_tan 313 gsl_complex_cot gsl_complex_arcsin gsl_complex_arcsin_real gsl_complex_arccos 314 gsl_complex_arccos_real gsl_complex_arcsec gsl_complex_arcsec_real gsl_complex_arccsc 315 gsl_complex_arccsc_real gsl_complex_arctan gsl_complex_arccot gsl_complex_sinh 316 gsl_complex_cosh gsl_complex_sech gsl_complex_csch gsl_complex_tanh 317 gsl_complex_coth gsl_complex_arcsinh gsl_complex_arccosh gsl_complex_arccosh_real 318 gsl_complex_arcsech gsl_complex_arccsch gsl_complex_arctanh gsl_complex_arctanh_real 319 gsl_complex_arccoth new_doubleArray delete_doubleArray doubleArray_setitem 320 gsl_real gsl_imag gsl_parts 321 gsl_complex_eq gsl_set_real gsl_set_imag gsl_set_complex 322 $GSL_COMPLEX_ONE $GSL_COMPLEX_ZERO $GSL_COMPLEX_NEGONE 323); 324# macros to implement 325# gsl_set_complex gsl_set_complex_packed 326our ($GSL_COMPLEX_ONE, $GSL_COMPLEX_ZERO, $GSL_COMPLEX_NEGONE) = map { gsl_complex_rect($_, 0) } qw(1 0 -1); 327 328 329our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); 330 331=encoding utf8 332 333=head2 copy() 334 335Returns a copy of the Complex number, which resides at a different location in 336memory. 337 338 my $z = Math::GSL::Complex->new([10,5]); 339 my $copy = $z->copy; 340 341=cut 342 343 344sub copy { 345 my $self = shift; 346 my $copy = Math::GSL::Complex->new( 347 gsl_real($self->raw), gsl_imag($self->raw) 348 ); 349 350 return $copy; 351} 352 353sub _not_equal { 354 my ($left, $right) = @_; 355 return ! _equal($left, $right); 356} 357 358sub _equal { 359 my ($left, $right) = @_; 360 361 if ( blessed $right && $right->isa('Math::GSL::Complex') && blessed $left && $left->isa('Math::GSL::Complex') ) { 362 return gsl_complex_eq($left->raw, $right->raw); 363 } else { 364 # If both are not Complex objects, they can't be the same 365 return 0; 366 } 367} 368 369sub _division { 370 my ($left, $right) = @_; 371 my $raw; 372 373 if ( blessed $right && $right->isa('Math::GSL::Complex') && blessed $left && $left->isa('Math::GSL::Complex') ) { 374 my $rcopy = $right->copy; 375 $raw = gsl_complex_div($left->raw, $right->raw); 376 $rcopy->set_raw( $raw ); 377 return $rcopy; 378 } else { 379 my $lcopy = $left->copy; 380 $raw = gsl_complex_div_real($lcopy->raw, $right); 381 $lcopy->set_raw($raw); 382 return $lcopy; 383 } 384} 385 386sub _multiplication { 387 my ($left, $right) = @_; 388 my $raw; 389 390 if ( blessed $right && $right->isa('Math::GSL::Complex') && blessed $left && $left->isa('Math::GSL::Complex') ) { 391 my $rcopy = $right->copy; 392 $raw = gsl_complex_mul($left->raw, $right->raw); 393 $rcopy->set_raw( $raw ); 394 return $rcopy; 395 } else { 396 my $lcopy = $left->copy; 397 $raw = gsl_complex_mul_real($lcopy->raw, $right); 398 $lcopy->set_raw($raw); 399 return $lcopy; 400 } 401} 402 403sub _subtract { 404 my ($left, $right) = @_; 405 my $rcopy = $right->copy; 406 my $raw = gsl_complex_negative($right->raw); 407 408 $rcopy->set_raw($raw); 409 410 return _addition($left, $rcopy); 411} 412 413sub _addition { 414 my ($left, $right) = @_; 415 416 my $lcopy = $left->copy; 417 my $raw; 418 419 if ( blessed $right && $right->isa('Math::GSL::Complex') && blessed $left && $left->isa('Math::GSL::Complex') ) { 420 $raw = gsl_complex_add($lcopy->raw, $right->raw); 421 } else { 422 $raw = gsl_complex_add_constant($lcopy->raw, $right); 423 } 424 $lcopy->set_raw($raw); 425 return $lcopy; 426} 427 428sub set_raw { 429 my ($self, $raw) = @_; 430 $self->{_complex} = $raw; 431 return $self; 432} 433 434sub new { 435 my ($class, @values) = @_; 436 my $this = {}; 437 $this->{_complex} = gsl_complex_rect($values[0], $values[1]); 438 bless $this, $class; 439} 440sub real { 441 my ($self) = @_; 442 gsl_real($self->raw); 443} 444 445sub imag { 446 my ($self) = @_; 447 gsl_imag($self->raw); 448} 449 450sub parts { 451 my ($self) = @_; 452 gsl_parts($self->raw); 453} 454 455sub raw { (shift)->{_complex} } 456 457 458### some important macros that are in gsl_complex.h 459sub gsl_complex_eq { 460 my ($z,$w) = @_; 461 gsl_real($z) == gsl_real($w) && gsl_imag($z) == gsl_imag($w) ? 1 : 0; 462} 463 464sub gsl_set_real { 465 my ($z,$r) = @_; 466 doubleArray_setitem($z->{dat}, 0, $r); 467} 468 469sub gsl_set_imag { 470 my ($z,$i) = @_; 471 doubleArray_setitem($z->{dat}, 1, $i); 472} 473 474sub gsl_real { 475 my $z = shift; 476 return doubleArray_getitem($z->{dat}, 0 ); 477} 478 479sub gsl_imag { 480 my $z = shift; 481 return doubleArray_getitem($z->{dat}, 1 ); 482} 483 484sub gsl_parts { 485 my $z = shift; 486 return (gsl_real($z), gsl_imag($z)); 487} 488 489sub gsl_set_complex { 490 my ($z, $r, $i) = @_; 491 gsl_set_real($z, $r); 492 gsl_set_imag($z, $i); 493} 494 495=head1 NAME 496 497Math::GSL::Complex - Complex Numbers 498 499=head1 SYNOPSIS 500 501 use Math::GSL::Complex qw/:all/; 502 my $complex = Math::GSL::Complex->new([3,2]); # creates a complex number 3+2*i 503 my $real = $complex->real; # returns the real part 504 my $imag = $complex->imag; # returns the imaginary part 505 $complex->gsl_set_real(5); # changes the real part to 5 506 $complex->gsl_set_imag(4); # changes the imaginary part to 4 507 $complex->gsl_set_complex(7,6); # changes it to 7 + 6*i 508 ($real, $imag) = $complex->parts; # get both at once 509 510=head1 DESCRIPTION 511 512Here is a list of all the functions included in this module : 513 514=over 1 515 516=item C<gsl_complex_arg($z)> 517 518Return the argument of the complex number $z 519 520=item C<gsl_complex_abs($z)> 521 522Return |$z|, the magnitude of the complex number $z 523 524=item C<gsl_complex_rect($x,$y)> 525 526Create a complex number in cartesian form $x + $y*i 527 528=item C<gsl_complex_polar($r,$theta)> 529 530Create a complex number in polar form $r*exp(i*$theta) 531 532=item C<gsl_complex_abs2($z)> 533 534Return |$z|^2, the squared magnitude of the complex number $z 535 536=item C<gsl_complex_logabs($z)> 537 538Return log(|$z|), the natural logarithm of the magnitude of the complex number $z 539 540=item C<gsl_complex_add($c1, $c2)> 541 542Return a complex number which is the sum of the complex numbers $c1 and $c2 543 544=item C<gsl_complex_sub($c1, $c2)> 545 546Return a complex number which is the difference between $c1 and $c2 ($c1 - $c2) 547 548=item C<gsl_complex_mul($c1, $c2)> 549 550Return a complex number which is the product of the complex numbers $c1 and $c2 551 552=item C<gsl_complex_div($c1, $c2)> 553 554Return a complex number which is the quotient of the complex numbers $c1 and $c2 ($c1 / $c2) 555 556=item C<gsl_complex_add_real($c, $x)> 557 558Return the sum of the complex number $c and the real number $x 559 560=item C<gsl_complex_sub_real($c, $x)> 561 562Return the difference of the complex number $c and the real number $x 563 564=item C<gsl_complex_mul_real($c, $x)> 565 566Return the product of the complex number $c and the real number $x 567 568=item C<gsl_complex_div_real($c, $x)> 569 570Return the quotient of the complex number $c and the real number $x 571 572=item C<gsl_complex_add_imag($c, $y)> 573 574Return sum of the complex number $c and the imaginary number i*$x 575 576=item C<gsl_complex_sub_imag($c, $y)> 577 578Return the diffrence of the complex number $c and the imaginary number i*$x 579 580=item C<gsl_complex_mul_imag($c, $y)> 581 582Return the product of the complex number $c and the imaginary number i*$x 583 584=item C<gsl_complex_div_imag($c, $y)> 585 586Return the quotient of the complex number $c and the imaginary number i*$x 587 588=item C<gsl_complex_conjugate($c)> 589 590Return the conjugate of the of the complex number $c (x - i*y) 591 592=item C<gsl_complex_inverse($c)> 593 594Return the inverse, or reciprocal of the complex number $c (1/$c) 595 596=item C<gsl_complex_negative($c)> 597 598Return the negative of the complex number $c (-x -i*y) 599 600=item C<gsl_complex_sqrt($c)> 601 602Return the square root of the complex number $c 603 604=item C<gsl_complex_sqrt_real($x)> 605 606Return the complex square root of the real number $x, where $x may be negative 607 608=item C<gsl_complex_pow($c1, $c2)> 609 610Return the complex number $c1 raised to the complex power $c2 611 612=item C<gsl_complex_pow_real($c, $x)> 613 614Return the complex number raised to the real power $x 615 616=item C<gsl_complex_exp($c)> 617 618Return the complex exponential of the complex number $c 619 620=item C<gsl_complex_log($c)> 621 622Return the complex natural logarithm (base e) of the complex number $c 623 624=item C<gsl_complex_log10($c)> 625 626Return the complex base-10 logarithm of the complex number $c 627 628=item C<gsl_complex_log_b($c, $b)> 629 630Return the complex base-$b of the complex number $c 631 632=item C<gsl_complex_sin($c)> 633 634Return the complex sine of the complex number $c 635 636=item C<gsl_complex_cos($c)> 637 638Return the complex cosine of the complex number $c 639 640=item C<gsl_complex_sec($c)> 641 642Return the complex secant of the complex number $c 643 644=item C<gsl_complex_csc($c)> 645 646Return the complex cosecant of the complex number $c 647 648=item C<gsl_complex_tan($c)> 649 650Return the complex tangent of the complex number $c 651 652=item C<gsl_complex_cot($c)> 653 654Return the complex cotangent of the complex number $c 655 656=item C<gsl_complex_arcsin($c)> 657 658Return the complex arcsine of the complex number $c 659 660=item C<gsl_complex_arcsin_real($x)> 661 662Return the complex arcsine of the real number $x 663 664=item C<gsl_complex_arccos($c)> 665 666Return the complex arccosine of the complex number $c 667 668=item C<gsl_complex_arccos_real($x)> 669 670Return the complex arccosine of the real number $x 671 672=item C<gsl_complex_arcsec($c)> 673 674Return the complex arcsecant of the complex number $c 675 676=item C<gsl_complex_arcsec_real($x)> 677 678Return the complex arcsecant of the real number $x 679 680=item C<gsl_complex_arccsc($c)> 681 682Return the complex arccosecant of the complex number $c 683 684=item C<gsl_complex_arccsc_real($x)> 685 686Return the complex arccosecant of the real number $x 687 688=item C<gsl_complex_arctan($c)> 689 690Return the complex arctangent of the complex number $c 691 692=item C<gsl_complex_arccot($c)> 693 694Return the complex arccotangent of the complex number $c 695 696=item C<gsl_complex_sinh($c)> 697 698Return the complex hyperbolic sine of the complex number $c 699 700=item C<gsl_complex_cosh($c)> 701 702Return the complex hyperbolic cosine of the complex number $cy 703 704=item C<gsl_complex_sech($c)> 705 706Return the complex hyperbolic secant of the complex number $c 707 708=item C<gsl_complex_csch($c)> 709 710Return the complex hyperbolic cosecant of the complex number $c 711 712=item C<gsl_complex_tanh($c)> 713 714Return the complex hyperbolic tangent of the complex number $c 715 716=item C<gsl_complex_coth($c)> 717 718Return the complex hyperbolic cotangent of the complex number $c 719 720=item C<gsl_complex_arcsinh($c)> 721 722Return the complex hyperbolic arcsine of the complex number $c 723 724=item C<gsl_complex_arccosh($c)> 725 726Return the complex hyperbolic arccosine of the complex number $c 727 728=item C<gsl_complex_arccosh_real($x)> 729 730Return the complex hyperbolic arccosine of the real number $x 731 732=item C<gsl_complex_arcsech($c)> 733 734Return the complex hyperbolic arcsecant of the complex number $c 735 736=item C<gsl_complex_arccsch($c)> 737 738Return the complex hyperbolic arccosecant of the complex number $c 739 740=item C<gsl_complex_arctanh($c)> 741 742Return the complex hyperbolic arctangent of the complex number $c 743 744=item C<gsl_complex_arctanh_real($x)> 745 746Return the complex hyperbolic arctangent of the real number $x 747 748=item C<gsl_complex_arccoth($c)> 749 750Return the complex hyperbolic arccotangent of the complex number $c 751 752=item C<gsl_real($z)> 753 754Return the real part of $z 755 756=item C<gsl_imag($z)> 757 758Return the imaginary part of $z 759 760=item C<gsl_parts($z)> 761 762Return a list of the real and imaginary parts of $z 763 764=item C<gsl_set_real($z, $x)> 765 766Sets the real part of $z to $x 767 768=item C<gsl_set_imag($z, $y)> 769 770Sets the imaginary part of $z to $y 771 772=item C<gsl_set_complex($z, $x, $h)> 773 774Sets the real part of $z to $x and the imaginary part to $y 775 776=back 777 778=head1 EXAMPLES 779 780This code defines $z as 6 + 4*i, takes the complex conjugate of that number, then prints it out. 781 782=over 1 783 784 my $z = gsl_complex_rect(6,4); 785 my $y = gsl_complex_conjugate($z); 786 my ($real, $imag) = gsl_parts($y); 787 print "z = $real + $imag*i\n"; 788 789=back 790 791This code defines $z as 5 + 3*i, multiplies it by 2 and then prints it out. 792 793=over 1 794 795 my $x = gsl_complex_rect(5,3); 796 my $z = gsl_complex_mul_real($x, 2); 797 my $real = gsl_real($z); 798 my $imag = gsl_imag($z); 799 print "Re(\$z) = $real\n"; 800 801=back 802 803=head1 AUTHORS 804 805Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> 806 807=head1 COPYRIGHT AND LICENSE 808 809Copyright (C) 2008-2021 Jonathan "Duke" Leto and Thierry Moisan 810 811This program is free software; you can redistribute it and/or modify it 812under the same terms as Perl itself. 813 814=cut 8151; 816