Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:48:23

0001 /*
0002  * MatrixComplexD.h
0003  *
0004  *  Created on: Jan 16, 2016
0005  *      Author: Pawel Sznajder (IPNO)
0006  */
0007 
0008 #ifndef MATRIXCOMPLEXD_H_
0009 #define MATRIXCOMPLEXD_H_
0010 
0011 #include <complex>
0012 #include <vector>
0013 
0014 namespace NumA {
0015 
0016 /**
0017  * @class MatrixComplexD
0018  *
0019  * @brief Matrix of complex numbers of undefined size.
0020  *
0021  * This class represents a matrix of complex double precision numbers. The size of this matrix should be defined by the user.
0022  */
0023 class MatrixComplexD {
0024 
0025 public:
0026 
0027     /**
0028      * Default constructor.
0029      */
0030     MatrixComplexD();
0031 
0032     /**
0033      * Assignemnt constructor.
0034      * Elements will be initialized with `std::complex<double>(0., 0.).`
0035      * @param n Size of x dim. to be set.
0036      * @param m Size of y dim. to be set.
0037      */
0038     MatrixComplexD(const unsigned int n, const unsigned int m);
0039 
0040     /**
0041      * Copy constructor
0042      * @param v Object to be copied.
0043      */
0044     MatrixComplexD(const MatrixComplexD& v);
0045 
0046     /**
0047      * Destructor.
0048      */
0049     virtual ~MatrixComplexD();
0050 
0051     /**
0052      * Dimension index.
0053      */
0054     enum Dim {
0055         X = 1,  ///< Dim. x.
0056         Y = 2   ///< Dim. y.
0057     };
0058 
0059     /**
0060      * Get conjunction of matrix.
0061      * Return: \f$M^{*}\f$.
0062      */
0063     MatrixComplexD Conjunct() const;
0064 
0065     /**
0066      * Multiply this with other matrix.
0067      * Return: \f$M N\f$.
0068      * @param v Other matrix,
0069      */
0070     MatrixComplexD Mult(const MatrixComplexD& v) const;
0071 
0072     /**
0073      * Clear vector (set `std::complex<double>(0., 0.)` to all elements).
0074      */
0075     void Clear();
0076 
0077     /**
0078      * Make unit (set `std::complex<double>(1., 0.)` to diagonal elements).
0079      */
0080     void MakeUnit();
0081 
0082     /**
0083      * Operator =.
0084      */
0085     void operator=(const MatrixComplexD& rhs);
0086 
0087     /**
0088      * Operator +.
0089      */
0090     MatrixComplexD operator+(const MatrixComplexD& rhs);
0091 
0092     /**
0093      * Operator -.
0094      */
0095     MatrixComplexD operator-(const MatrixComplexD& rhs);
0096 
0097     /**
0098      * Operator * by real number (rhs).
0099      */
0100     MatrixComplexD operator*(const double& rhs);
0101 
0102     /**
0103      * Operator * by real number (lhs).
0104      */
0105     friend MatrixComplexD operator*(const double& lhs, MatrixComplexD& rhs);
0106 
0107     /**
0108      * Operator * by complex number (rhs).
0109      */
0110     MatrixComplexD operator*(const std::complex<double>& rhs);
0111 
0112     /**
0113      * Operator * by complex number (lhs).
0114      */
0115     friend MatrixComplexD operator*(const std::complex<double>& lhs,
0116             MatrixComplexD& rhs);
0117 
0118     /**
0119      * Get dim. size for given dimension.
0120      * @param v Dimension.
0121      */
0122     unsigned int GetNElements(const Dim v) const;
0123 
0124     /**
0125      * Set element
0126      * @param i Index of x element to be set.
0127      * @param j Index of y element to be set.
0128      * @param value Value to be set.
0129      */
0130     void SetElement(const unsigned int i, const unsigned int j,
0131             const std::complex<double> value);
0132 
0133     /**
0134      * Get element.
0135      * @param i Index of x element to be retrieved.
0136      * @param j Index of y element to be retrieved.
0137      */
0138     std::complex<double> GetElement(const unsigned int i,
0139             const unsigned int j) const;
0140 
0141 private:
0142 
0143     /**
0144      * Compare number of elements of this and other vector.
0145      * @param v Other matrix.
0146      */
0147     void CompareNElements(const MatrixComplexD& v) const;
0148 
0149     /**
0150      * Size of x dim.
0151      */
0152     unsigned int m_n;
0153 
0154     /**
0155      * Size of y dim.
0156      */
0157     unsigned int m_m;
0158 
0159     /**
0160      * Elements
0161      */
0162     std::vector<std::vector<std::complex<double> > > m_elements;
0163 };
0164 
0165 } /* namespace NumA */
0166 
0167 #endif /* MATRIXCOMPLEXD_H_ */