M5.1314 COMPLEX

A richiesta, ecco di seguito l’interfaccia pubblica della classe COMPLEX: una classe per tutti e per nessuno.

In sostanza di seguito elenco tutti i metodi associati alla classe COMPLEX: (liberamente adattato dalla STL Standard C++ Library)

Costruttori e assegnazioni:

complex c

Creates a complex number with 0 as the real part and 0 as the imaginary part (0 + 0i)

complex c(1.3)

Creates a complex number with 1.3 as the real part and 0 as the imaginary part (1.3 + 0i)

complex
c(1.3,4.2)

Creates a complex number with 1.3 as the real part and 4.2 as the imaginary part (1.3 + 4.2i)

complex c1(c2)

Creates c1 as a copy of c2

c1 = c2

Assigns the values of c2 to c1

c1+=c2

Adds the value of c2 to c1

c1-=c2

Subtracts the value of c2 from c1

c1*=c2

Multiplies the value of c2 by c1

c1/=c2

Divides the value of c2 into c1

Metodi di ACCESSO ai valori parte reale e immaginario:

c.real() – Returns the value of the real part (as a member function)

c.imag() – Returns the value of the imaginary part (as a member function)

abs(c) – Returns the absolute value of c

arg(c)- Returns the angle of the polar representation of c

Operatori di confronto:

c1 == c2

Returns whether c1 is equal to c2

c1 != c2

page468image4160 page468image4744

Returns whether c1 differs from c2

Operazioni aritmetiche:

c1 + c2

Returns the sum of c1 and c2

page468image47056 page468image47648 page468image47968 page468image48392 page468image48816

c + 1.7

page468image50144 page468image50736 page468image51056 page468image51480 page468image51904

Returns the sum of c and 1.7

1.7 + c

Returns the sum of 1.7 and c

page468image58240 page468image58832 page468image59152 page468image59576 page468image60000

c1 – c2

Returns the difference between c1 and c2

page468image63904 page468image64496 page468image64816 page468image65240 page468image65664

c – 1.7

page468image66992 page468image67584 page468image67904 page468image68328 page468image68752

Returns the difference between c and 1.7

1.7 – c

Returns the difference between 1. 7 and c

page468image75152 page468image75744 page468image76064 page468image76488 page468image76912 page468image77072

c1 * c2

page468image78856 page468image79176 page468image79600 page468image80024

Returns the product of c1 and c2

c * 1.7

Returns the product of c and 1.7

page468image86352 page468image86944 page468image87264 page468image87688 page468image88112 page468image88272

1.7 * c

page468image90224

Returns the product of 1.7 and c

c1 / c2 Returns the quotient of c1 and c2

page469image5680 page469image6584 page469image7328

c / 1.7 Returns the quotient of c and 1.7

page469image10216

1.7 / c Returns the quotient of 1.7 and c

page469image13272 page469image14176

– c Returns the negated value of c

page469image17072 page469image17976 page469image18720

+ c Returns c

page469image21368

c1 += c2 Equivalent toc1 = c1 + c2

page469image24440 page469image25344 page469image26088

c1 -= c2 Equivalent toc1 = c1 – c2

page469image28936

c1 *= c2 Equivalent toc1 = c1 * c2

page469image31984 page469image32888 page469image34224

c1 /= c2 Equivalent to c1 = c1 / c2

Questa voce è stata pubblicata in Algoritmi, Generale, Informatica, M5, M5.1314, Numeri complessi, Programmazione e contrassegnata con , , . Contrassegna il permalink.

Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...