Merge pull request #927 from tjgurwara99/master

docs: fixed some documentation issues
This commit is contained in:
Krishna Vedala 2020-07-02 08:47:57 -04:00 committed by GitHub
commit 247301c5b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,8 @@
* @author tjgurwara99
* @file
*
* A basic implementation of Complex Number field as a class with operators
* \brief An implementation of Complex Number as Objects
* \details A basic implementation of Complex Number field as a class with operators
* overloaded to accommodate (mathematical) field operations.
*/
@ -14,7 +15,7 @@
#include <stdexcept>
/**
* Class Complex to represent complex numbers as a field.
* \brief Class Complex to represent complex numbers as a field.
*/
class Complex {
// The real value of the complex number
@ -24,8 +25,10 @@ class Complex {
public:
/**
* Complex Constructor which initialises the complex number which takes two
* arguments.
* \brief Complex Constructor which initialises our complex number.
* \details
* Complex Constructor which initialises the complex number which takes
* three arguments.
* @param x If the third parameter is 'true' then this x is the absolute
* value of the complex number, if the third parameter is 'false' then this
* x is the real value of the complex number (optional).
@ -49,25 +52,28 @@ class Complex {
}
/**
* Copy Constructor
* \brief Copy Constructor
* @param other The other number to equate our number to.
*/
Complex(const Complex &other) : re(other.real()), im(other.imag()) {}
/**
* \brief Member function to get real value of our complex number.
* Member function (getter) to access the class' re value.
*/
double real() const { return this->re; }
/**
* \brief Member function to get imaginary value of our complex number.
* Member function (getter) to access the class' im value.
*/
double imag() const { return this->im; }
/**
* \brief Member function to give the modulus of our complex number.
* Member function to which gives the absolute value (modulus) of our
* complex number
* @return \f$ \sqrt{z \dot \bar{z}} \f$ where \f$ z \f$ is our complex
* @return \f$ \sqrt{z \bar{z}} \f$ where \f$ z \f$ is our complex
* number.
*/
double abs() const {
@ -75,12 +81,13 @@ class Complex {
}
/**
* Member function which gives the argument of our complex number.
* \brief Member function to give the argument of our complex number.
* @return Argument of our Complex number in radians.
*/
double arg() const { return std::atan2(this->im, this->re); }
/**
* \brief Operator overload of '+' on Complex class.
* Operator overload to be able to add two complex numbers.
* @param other The other number that is added to the current number.
* @return result current number plus other number
@ -91,6 +98,7 @@ class Complex {
}
/**
* \brief Operator overload of '-' on Complex class.
* Operator overload to be able to subtract two complex numbers.
* @param other The other number being subtracted from the current number.
* @return result current number subtract other number
@ -101,6 +109,7 @@ class Complex {
}
/**
* \brief Operator overload of '*' on Complex class.
* Operator overload to be able to multiple two complex numbers.
* @param other The other number to multiply the current number to.
* @return result current number times other number.
@ -112,6 +121,7 @@ class Complex {
}
/**
* \brief Operator overload of '~' on Complex class.
* Operator overload of the BITWISE NOT which gives us the conjugate of our
* complex number. NOTE: This is overloading the BITWISE operator but its
* not a BITWISE operation in this definition.
@ -123,6 +133,7 @@ class Complex {
}
/**
* \brief Operator overload of '/' on Complex class.
* Operator overload to be able to divide two complex numbers. This function
* would throw an exception if the other number is zero.
* @param other The other number we divide our number by.
@ -142,6 +153,7 @@ class Complex {
}
/**
* \brief Operator overload of '=' on Complex class.
* Operator overload to be able to copy RHS instance of Complex to LHS
* instance of Complex
*/
@ -153,6 +165,7 @@ class Complex {
};
/**
* \brief Operator overload of '==' on Complex class.
* Logical Equal overload for our Complex class.
* @param a Left hand side of our expression
* @param b Right hand side of our expression
@ -164,6 +177,7 @@ bool operator==(const Complex &a, const Complex &b) {
}
/**
* \brief Operator overload of '<<' of ostream for Complex class.
* Overloaded insersion operator to accommodate the printing of our complex
* number in their standard form.
* @param os The console stream
@ -181,7 +195,7 @@ std::ostream &operator<<(std::ostream &os, const Complex &num) {
}
/**
* Function to get random numbers to generate our complex numbers for test
* \brief Function to get random numbers to generate our complex numbers for test
*/
double get_rand() { return (std::rand() % 100 - 50) / 100.f; }