📄 gmc.h
字号:
* this with care! * * This function releases any previously referenced memory of * this object. */ LaGenMatComplex& ref(const LaGenMatComplex& s); //@} /** @name Expensive access functions */ //@{ /** Returns a newly allocated large matrix that consists of * \c M-by-N copies of the given matrix. (New in * lapackpp-2.4.5.) */ LaGenMatComplex repmat (int M, int N) const; /** Returns the trace, i.e. the sum of all diagonal elements * of the matrix. (New in lapackpp-2.4.5) */ value_type trace () const; /** Returns a newly allocated column vector of dimension \c * Nx1 that contains the diagonal of the given matrix. (New * in lapackpp-2.4.5) */ LaGenMatComplex diag () const; /** Returns a newly allocated matrix with the real part of * this matrix as a double (floating-point double precision) * matrix. An alias for real_to_LaGenMatDouble(). (New in * lapackpp-2.4.5) */ LaGenMatDouble real() const; /** Returns a newly allocated matrix with the imaginary part * of this matrix as a double (floating-point double * precision) matrix. An alias for * imag_to_LaGenMatDouble(). (New in lapackpp-2.4.5) */ LaGenMatDouble imag() const; //@} /** @name Debugging information */ //@{ /** Returns global shallow flag */ inline int shallow() const // read global shallow flag { return shallow_;} /** Returns global debug flag */ inline int debug() const; // read global debug flag /** Set global debug flag */ inline int debug(int d); // set global debug flag /** // use as in // // std::cout << B.info() << std::endl; // // this *info_ member is unique in that it really isn't // part of the matrix info, just a flag as to how // to print it. We've included in this beta release // as part of our testing, but we do not expect it // to be user accessable. */ inline const LaGenMatComplex& info() const { *(const_cast<LaGenMatComplex*>(this)->info_) = 1; return *this; }; /** Print the matrix info (not the actual elements) to the * given ostream. */ inline std::ostream& Info(std::ostream& s) const { s << "Size: (" << size(0) << "x" << size(1) << ") " ; s << "Indeces: " << ii[0] << " " << ii[1]; s << "#ref: " << ref_count() << "addr: " << addr() << std::endl; return s; }; //@} /** Print the matrix to the given output stream. If the matrix * info flag is set, then this prints only the matrix info, * see LaGenMatComplex::info(). Otherwise all matrix elements * are printed. * * @see LaPreferences::setPrintFormat() */ friend DLLIMPORT std::ostream& operator<<(std::ostream&, const LaGenMatComplex&); /** @name Matrix type conversions */ //@{ /** Convert the real part of this matrix to a double (floating-point double precision) matrix. */ LaGenMatDouble real_to_LaGenMatDouble() const; /** Convert the real part of this matrix to a float (floating-point single precision) matrix. */ LaGenMatFloat real_to_LaGenMatFloat() const; /** Convert the real part of this matrix to an int matrix. */ LaGenMatInt real_to_LaGenMatInt() const; /** Convert the real part of this matrix to a long int matrix. */ LaGenMatLongInt real_to_LaGenMatLongInt() const; /** Convert the imaginary part of this matrix to a double (floating-point double precision) matrix. */ LaGenMatDouble imag_to_LaGenMatDouble() const; /** Convert the imaginary part of this matrix to a float (floating-point single precision) matrix. */ LaGenMatFloat imag_to_LaGenMatFloat() const; /** Convert the imaginary part of this matrix to an int matrix. */ LaGenMatInt imag_to_LaGenMatInt() const; /** Convert the imaginary part of this matrix to a long int matrix. */ LaGenMatLongInt imag_to_LaGenMatLongInt() const; //@} /** @name Constructors for elementary matrices */ //@{ /** Returns a newly allocated all-zero matrix of dimension * \c NxN, if \c M is not given, or \c NxM if \c M is given. * (New in lapackpp-2.4.5) */ static LaGenMatComplex zeros (int N, int M=0); /** Returns a newly allocated all-one matrix of dimension \c * NxN, if \c M is not given, or \c NxM if \c M is given. * (New in lapackpp-2.4.5) */ static LaGenMatComplex ones (int N, int M=0); /** Returns a newly allocated identity matrix of dimension * \c NxN, if \c M is not given, or a rectangular matrix \c * NxM if \c M is given. (New in lapackpp-2.4.5) */ static LaGenMatComplex eye (int N, int M=0); /** Returns a newly allocated matrix of dimension \c NxM * with pseudo-random values. Both real part and imaginary * part values are uniformly distributed in the interval \c * (0,1) or, if specified, \c (low,high). (New in * lapackpp-2.4.5) * * Note: Since this uses the system's \c rand() call, the * randomness of the values might be questionable -- don't * use this if you need really strong random numbers. */ static LaGenMatComplex rand (int N, int M, double low=0, double high=1); /** Returns a newly allocated diagonal matrix of dimension * \c NxN that has the vector \c vect of length \c N on the * diagonal. (New in lapackpp-2.4.5) */ static LaGenMatComplex from_diag (const LaGenMatComplex &vect); /** Returns a newly allocated linarly spaced column vector * with \c nr_points elements, between and including \c * start and \c end. (New in lapackpp-2.4.5.) */ static LaGenMatComplex linspace (value_type start, value_type end, int nr_points); //@}}; //* End of LaGenMatComplex Class *//namespace la { /** The matrix data type containing complex values of type \c * doublecomplex. */ typedef LaGenMatComplex cmat;} // namespace/** Print the matrix to the given output stream. If the matrix * info flag is set, then this prints only the matrix info, * see LaGenMatDouble::info(). Otherwise all matrix elements * are printed. * * \see LaPreferences::setPrintFormat() */DLLIMPORTstd::ostream& operator<<(std::ostream&, const LaGenMatComplex&); //* Member Functions *// inline int LaGenMatComplex::size(int d) const{ if (d==0) return size0; else return size1; //return sz[d];}inline int LaGenMatComplex::inc(int d) const{ return ii[d].inc();}inline int LaGenMatComplex::gdim(int d) const{ return dim[d];}inline int LaGenMatComplex::start(int d) const{ return ii[d].start();}inline int LaGenMatComplex::end(int d) const{ return ii[d].end();}inline int LaGenMatComplex::ref_count() const{ return v.ref_count();}inline LaIndex LaGenMatComplex::index(int d) const{ return ii[d];}inline COMPLEX* LaGenMatComplex::addr() const{ return v.addr();}inline int LaGenMatComplex::debug() const{ return debug_;}inline int LaGenMatComplex::debug(int d){ return debug_ = d;}inline COMPLEX& LaGenMatComplex::operator()(int i, int j){#ifdef LA_BOUNDS_CHECK assert(i>=0); assert(i<size(0)); assert(j>=0); assert(j<size(1));#endif return v( dim[0]*(ii[1].start() + j*ii[1].inc()) + ii[0].start() + i*ii[0].inc());}inline COMPLEX& LaGenMatComplex::operator()(int i, int j) const{#ifdef LA_BOUNDS_CHECK assert(i>=0); assert(i<size(0)); assert(j>=0); assert(j<size(1));#endif return v( dim[0]*(ii[1].start() + j*ii[1].inc()) + ii[0].start() + i*ii[0].inc());}inline LaGenMatComplex& LaGenMatComplex::shallow_assign(){ shallow_ = 1; return *this;}#ifndef LA_COMPLEX_SUPPORT// Repeat this warning again# error "The macro LA_COMPLEX_SUPPORT needs to be defined if you want to use complex-valued matrices."#endif#endif // _LA_GEN_MAT_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -