Package complex
Record Class Complex
java.lang.Object
java.lang.Record
complex.Complex
- All Implemented Interfaces:
ComplexInterface
Implementation of the ComplexInterface interface
- Since:
- March 2025
- Version:
- 1.0
- Author:
- Saptarshi Dey
-
Constructor Summary
ConstructorsConstructorDescriptionComplex(double real, double imaginary) Creates an instance of aComplexrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoublearg()cos()final booleanIndicates whether some other object is "equal to" this one.exp()final inthashCode()Returns a hash code value for this object.doubleReturns the value of theimaginaryrecord component.log(double base) doublemod()multiply(double number) pow(double power) doublereal()Returns the value of therealrecord component.sin()toString()Returns a string representation of this record class.toString(int precision)
-
Constructor Details
-
Complex
public Complex(double real, double imaginary) Creates an instance of aComplexrecord class.- Parameters:
real- the value for therealrecord componentimaginary- the value for theimaginaryrecord component
-
-
Method Details
-
add
- Specified by:
addin interfaceComplexInterface- Parameters:
other- Complex number that needs to be added to the current Complex object- Returns:
- Sum of 2 Complex numbers
-
subtract
- Specified by:
subtractin interfaceComplexInterface- Parameters:
other- Complex number that needs to be subtracted to the current Complex object- Returns:
- Difference between 2 Complex numbers
-
multiply
- Specified by:
multiplyin interfaceComplexInterface- Parameters:
other- Complex number that needs to be multiplied to the current Complex object- Returns:
- Dot product of 2 Complex numbers
-
divide
- Specified by:
dividein interfaceComplexInterface- Parameters:
other- Complex number by which the current Complex object needs to be divided- Returns:
- Quotient after division of 2 Complex numbers
-
mod
public double mod()- Specified by:
modin interfaceComplexInterface- Returns:
- Distance from the radius of the Complex number in an Euclidean complex plane
-
arg
public double arg()- Specified by:
argin interfaceComplexInterface- Returns:
- Argument of the Complex number
-
conjugate
- Specified by:
conjugatein interfaceComplexInterface- Returns:
- Conjugate of the Complex number
-
pow
- Specified by:
powin interfaceComplexInterface- Returns:
- Complex number raised to a real power
-
pow
- Specified by:
powin interfaceComplexInterface- Returns:
- Complex number raised to a Complex power
-
reciprocal
- Specified by:
reciprocalin interfaceComplexInterface- Returns:
- Reciprocal of the Complex number
-
exp
- Specified by:
expin interfaceComplexInterface- Returns:
- Exponent raised to the power of the Complex number
-
sin
- Specified by:
sinin interfaceComplexInterface- Returns:
- Sine of the Complex number
-
cos
- Specified by:
cosin interfaceComplexInterface- Returns:
- Cosine of the Complex number
-
log
- Specified by:
login interfaceComplexInterface- Parameters:
base- Base in which the Log will be computed- Returns:
- Log of the Complex number
-
multiply
- Specified by:
multiplyin interfaceComplexInterface- Parameters:
number- Scalar multiplicand- Returns:
- Scalar product of a number and a Complex number
-
toString
- Parameters:
precision- Precision of fractional part of the real and imaginary values- Returns:
- String representation of the Complex number
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
real
public double real()Returns the value of therealrecord component.- Returns:
- the value of the
realrecord component
-
imaginary
public double imaginary()Returns the value of theimaginaryrecord component.- Returns:
- the value of the
imaginaryrecord component
-