⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tinyvector.texi

📁 c++经典教材 Blitz++ v0.8
💻 TEXI
字号:
@findex TinyVector@cindex TinyVectorThe @code{TinyVector} class provides a small, lightweight vector objectwhose size is known at compile time.  It is included via the header@code{<blitz/tinyvec.h>}.  Note that @code{TinyVector} lives in the @code{blitz} namespace, so you willneed to refer to it as @code{blitz::TinyVector}, or use the directive@code{using namespace blitz;}.The Blitz++ @code{Array} object uses @code{TinyVector} internally, so if youinclude @code{<blitz/array.h>}, the @code{TinyVector} header is automaticallyincluded.  However, to use @code{TinyVector} expressions, you willneed to include @code{<blitz/tinyvec-et.h>}.@section Template parameters and typesThe @code{TinyVector<T,N>} class has two template parameters:@table @code@item Tis the numeric type of the vector (float, double, int,@code{complex<float>}, etc.;@item N is the number of elements in the vector.@end tableInside the @code{TinyVector} class, these types are declared:@table @code@item T_numtypeis the numeric type stored in the vector (the template parameter @code{T})@item T_vectoris the vector type @code{TinyVector<T,N>}.@item iteratoris an STL-style iterator.@item constIteratoris an STL-style const iterator.@end table@section Constructors@exampleTinyVector();@end exampleThe elements of the vector are left uninitialized.@exampleTinyVector(const TinyVector<T,N>& x);@end exampleThe elements of vector @code{x} are copied.@exampleTinyVector(T value);@end exampleAll elements are initialized to @code{value}.@exampleTinyVector(T value1, T value2, ...);@end exampleThe vector is initialized with the list of values given.These constructors are provided for up to N=11.@section Member functions@exampleTinyVector<T,N>::iterator                   begin();TinyVector<T,N>::const_iterator             begin() const;@end exampleReturns an STL-style iterator for the vector, positionedat the beginning of the data.@exampleTinyVector<T,N>::iterator                   end();TinyVector<T,N>::const_iterator             end() const;@end exampleReturns an STL-style iterator for the vector, positionedat the end of the data.@exampleT_numtype* [restrict]                       data();const T_numtype* [restrict]                 data() const;@end exampleReturns a pointer to the first element in the vector.@exampleint                                         length() const;@end exampleReturns the length of the vector (the template parameter @code{N}).@exampleT_numtype                                   operator()(int i) const;T_numtype&                                  operator()(int i);T_numtype                                   operator[](int i) const;T_numtype&                                  operator[](int i);@end exampleReturns the @code{i}th element of the vector.  If the code is compiled withdebugging enabled (@code{-DBZ_DEBUG}), bounds checking is performed.@section Assignment operatorsThe assignment operators =, +=, -=, *=, /=, %=, ^=, &=, |=, >>= and <<= areall provided.  The right hand side of an assignment may be a scalar of type@code{T_numtype}, a @code{TinyVector} of any type but the same size, or avector expression.@section ExpressionsExpressions involving tiny vectors may contain any combinationof the operators@example+ - * / % ^ & | >> <<@end examplewith operands of type TinyVector, scalar, or vector expressions.The usual math functions (see the Array documentation) are supportedon TinyVector.@section Global functions@exampledot(TinyVector, TinyVector);dot(vector-expr, TinyVector);dot(TinyVector, vector-expr);dot(vector-expr, vector-expr);@end exampleThese functions calculate a dot product between @code{TinyVector}s(or vector expressions).  The result is a scalar; the typeof the scalar follows the usual type promotion rules.@exampleproduct(TinyVector);@end exampleReturns the product of all the elements in the vector.@examplesum(TinyVector);@end exampleReturns the sum of the elements in the vector.@exampleTinyVector<T,3> cross(TinyVector<T,3> x, TinyVector<T,3> y);@end exampleReturns the cross product of @code{x} and @code{y}.@section Arrays of @code{TinyVector}@section Input/output@exampleostream& operator<<(ostream&, const TinyVector<T,N>& x);@end exampleThis function outputs a @code{TinyVector} onto a stream.  Here'san illustration of the format for a length 3 vector:@example[        0.5       0.2       0.9 ]@end example

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -