📄 gmd.h
字号:
* b_{0,4} & b_{4,4} * \end{array}\right) \f] */ LaGenMatDouble operator()(const LaIndex& I, const LaIndex& J) const; /** Returns a submatrix view for the specified row \c k of * this matrix. * * The returned object references still the same memory as * this object, so if you modify elements, they will appear * modified in both objects. (New in lapackpp-2.4.6) */ LaGenMatDouble row(int k); /** Returns a submatrix view for the specified row \c k of * this matrix. * * The returned object references still the same memory as * this object, so if you modify elements, they will appear * modified in both objects. (New in lapackpp-2.4.6) */ LaGenMatDouble row(int k) const; /** Returns a submatrix view for the specified column \c k * of this matrix. * * The returned object references still the same memory as * this object, so if you modify elements, they will appear * modified in both objects. (New in lapackpp-2.4.6) */ LaGenMatDouble col(int k); /** Returns a submatrix view for the specified column \c k * of this matrix. * * The returned object references still the same memory as * this object, so if you modify elements, they will appear * modified in both objects. (New in lapackpp-2.4.6) */ LaGenMatDouble col(int k) const; //@} /** @name Assignments */ //@{ /** Set elements of left-hand side to the scalar value s. No * new matrix is created, so that if there are other matrices * that reference this memory space, they will also be * affected. */ LaGenMatDouble& operator=(double s); /** Release left-hand side (reclaiming memory space if * possible) and copy elements of elements of \c s. Unline \c * inject(), it does not require conformity, and previous * references of left-hand side are unaffected. * * This is an alias for copy(). * * Watch out! Due to the C++ "named return value optimization" * you cannot use this as an alias for copy() when declaring a * variable if the right-side is a return value of * operator(). More precisely, you cannot write the following: * \verbatim LaGenMatDouble x = y(LaIndex(),LaIndex()); // erroneous reference copy! \endverbatim * * Instead, if the initialization should create a new copy of * the right-side matrix, you have to write it this way: * \verbatim LaGenMatDouble x = y(LaIndex(),LaIndex()).copy(); // correct deep-copy \endverbatim * * Or this way: * \verbatim LaGenMatDouble x; x = y(LaIndex(),LaIndex()); // correct deep-copy \endverbatim * * Note: The manual for lapack++-1.1 claimed that this * operator would be an alias for ref(), not for copy(), * i.e. this operator creates a reference instead of a deep * copy. However, since that confused many people, the * behaviour was changed so that B=A will now create B as a * deep copy instead of a reference. If you want a * reference, please write B.ref(A) explicitly. */ LaGenMatDouble& operator=(const LaGenMatDouble& s); /** Add the scalar value s to elements of left-hand side. No * new matrix is created, so that if there are other matrices * that reference this memory space, they will also be * affected. * * @note This method is rather slow. In many cases, it can * be much faster to use Blas_Mat_Mult() with a Ones-Matrix * instead. */ LaGenMatDouble& operator+=(double s); /** Add the scalar value s to elements of left-hand side. No * new matrix is created, so that if there are other matrices * that reference this memory space, they will also be * affected. (New in lapackpp-2.4.7.) */ LaGenMatDouble& add(double s); /** Scale the left-hand side matrix by the given scalar * value. No new matrix is created, so that if there are * other matrices that reference this memory space, they * will also be affected. (New in lapackpp-2.4.7.) */ LaGenMatDouble& operator*=(double s); /** Scale the left-hand side matrix by the given scalar * value. No new matrix is created, so that if there are * other matrices that reference this memory space, they * will also be affected. (New in lapackpp-2.4.7.) */ LaGenMatDouble& scale(double s); /** Copy elements of s into the memory space referenced by the * left-hand side, without first releasing it. The effect is * that if other matrices share memory with left-hand side, * they too will be affected. Note that the size of s must be * the same as that of the left-hand side matrix. * * @note If you rather wanted to create a new copy of \c s, * you should use \c copy() instead. */ LaGenMatDouble& inject(const LaGenMatDouble& s); /** Release left-hand side (reclaiming memory space if * possible) and copy elements of elements of \c s. Unline \c * inject(), it does not require conformity, and previous * references of left-hand side are unaffected. */ LaGenMatDouble& copy(const LaGenMatDouble& s); /** Returns a newly allocated matrix that is an * element-by-element copy of this matrix. * * New in lapackpp-2.5.2 */ LaGenMatDouble copy() const; /** This is an optimization for returning temporary matrices * from functions, without copying. The shallow_assign() * function essentially sets an internal flag which instructs * the \c X::X(&X) copy constructor to avoid the copying. */ inline LaGenMatDouble& shallow_assign(); /** Let this matrix reference the given matrix s, so that the * given matrix memory s is now referenced by multiple objects * (by the given object s and now also by this object). Handle * this with care! * * This function releases any previously referenced memory of * this object. */ LaGenMatDouble& ref(const LaGenMatDouble& 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.) */ LaGenMatDouble 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) */ LaGenMatDouble diag () 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 LaGenMatDouble& info() const { *(const_cast<LaGenMatDouble*>(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() << " shallow:" << shallow_ << 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 LaGenMatDouble::info(). Otherwise all matrix elements * are printed. * * @see LaPreferences::setPrintFormat() */ friend DLLIMPORT std::ostream& operator<<(std::ostream&, const LaGenMatDouble&); /** @name Matrix type conversions */ //@{ /** Convert this matrix to a complex matrix with imaginary part zero. */ LaGenMatComplex to_LaGenMatComplex() const; /** Convert this matrix to a float (floating-point single precision) matrix. */ LaGenMatFloat to_LaGenMatFloat() const; /** Convert this matrix to an int matrix. */ LaGenMatInt to_LaGenMatInt() const; /** Convert this matrix to a long int matrix. */ LaGenMatLongInt 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 LaGenMatDouble 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 LaGenMatDouble 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 LaGenMatDouble eye (int N, int M=0); /** Returns a newly allocated matrix of dimension \c NxM * with pseudo-random values. The 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 LaGenMatDouble rand (int N, int M, value_type low=0, value_type 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 LaGenMatDouble from_diag (const LaGenMatDouble &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 LaGenMatDouble linspace (value_type start, value_type end, int nr_points); //@}}; //* End of LaGenMatDouble Class *//namespace la { /** The basic matrix data type containing double values. */ typedef LaGenMatDouble mat;} // 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 LaGenMatDouble&); //* Member Functions *// inline int LaGenMatDouble::size(int d) const{ return sz[d];}inline int LaGenMatDouble::inc(int d) const{ return ii[d].inc();}inline int LaGenMatDouble::gdim(int d) const{ return dim[d];}inline int LaGenMatDouble::start(int d) const{ return ii[d].start();}inline int LaGenMatDouble::end(int d) const{ return ii[d].end();}inline int LaGenMatDouble::ref_count() const{ return v.ref_count();}inline LaIndex LaGenMatDouble::index(int d) const{ return ii[d];}inline double* LaGenMatDouble::addr() const{ return v.addr();}inline int LaGenMatDouble::debug() const{ return debug_;}inline int LaGenMatDouble::debug(int d){ return debug_ = d;}inline double& LaGenMatDouble::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 double& LaGenMatDouble::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 LaGenMatDouble& LaGenMatDouble::shallow_assign(){ shallow_ = 1; return *this;}#endif // _LA_GEN_MAT_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -