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 * @author tjgurwara99
* @file * @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. * overloaded to accommodate (mathematical) field operations.
*/ */
@ -14,7 +15,7 @@
#include <stdexcept> #include <stdexcept>
/** /**
* Class Complex to represent complex numbers as a field. * \brief Class Complex to represent complex numbers as a field.
*/ */
class Complex { class Complex {
// The real value of the complex number // The real value of the complex number
@ -24,8 +25,10 @@ class Complex {
public: public:
/** /**
* Complex Constructor which initialises the complex number which takes two * \brief Complex Constructor which initialises our complex number.
* arguments. * \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 * @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 * value of the complex number, if the third parameter is 'false' then this
* x is the real value of the complex number (optional). * 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. * @param other The other number to equate our number to.
*/ */
Complex(const Complex &other) : re(other.real()), im(other.imag()) {} 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. * Member function (getter) to access the class' re value.
*/ */
double real() const { return this->re; } 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. * Member function (getter) to access the class' im value.
*/ */
double imag() const { return this->im; } 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 * Member function to which gives the absolute value (modulus) of our
* complex number * 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. * number.
*/ */
double abs() const { 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. * @return Argument of our Complex number in radians.
*/ */
double arg() const { return std::atan2(this->im, this->re); } 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. * Operator overload to be able to add two complex numbers.
* @param other The other number that is added to the current number. * @param other The other number that is added to the current number.
* @return result current number plus other 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. * Operator overload to be able to subtract two complex numbers.
* @param other The other number being subtracted from the current number. * @param other The other number being subtracted from the current number.
* @return result current number subtract other 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. * Operator overload to be able to multiple two complex numbers.
* @param other The other number to multiply the current number to. * @param other The other number to multiply the current number to.
* @return result current number times other number. * @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 * Operator overload of the BITWISE NOT which gives us the conjugate of our
* complex number. NOTE: This is overloading the BITWISE operator but its * complex number. NOTE: This is overloading the BITWISE operator but its
* not a BITWISE operation in this definition. * 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 * Operator overload to be able to divide two complex numbers. This function
* would throw an exception if the other number is zero. * would throw an exception if the other number is zero.
* @param other The other number we divide our number by. * @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 * Operator overload to be able to copy RHS instance of Complex to LHS
* instance of Complex * instance of Complex
*/ */
@ -153,6 +165,7 @@ class Complex {
}; };
/** /**
* \brief Operator overload of '==' on Complex class.
* Logical Equal overload for our Complex class. * Logical Equal overload for our Complex class.
* @param a Left hand side of our expression * @param a Left hand side of our expression
* @param b Right 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 * Overloaded insersion operator to accommodate the printing of our complex
* number in their standard form. * number in their standard form.
* @param os The console stream * @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; } double get_rand() { return (std::rand() % 100 - 50) / 100.f; }