📄 vector.3.man
字号:
VECTOR(base) C++ UITILITY CLASSES VECTOR(base) Nov 20 10:05NAME Vector class templateSYNOPSIS #include <defs.hh> class Vector \fIPublic members\fP Vector(); Vector(int m); Vector(const Vector<Type>& v); Vector( int m, Type* v); ~Vector(); int size() const; Type elem(int i) const; Type CircElem(int i) const; Type* toPointer() const; Vector<Type>& setPointer(Type* p); Type& operator[](int i); Vector<Type>& chaSize(int); Vector<Type>& linear(Type init, Type slope); int indexMax() const; int indexMin() const; Type max() const; Type min() const; Type sum() const; Type norm(int p) const; Type norm2S()const ; Vector<Type>& normalize(); Vector<Type> operator-(); Vector<Type>* copy(int ibeg, int iend); Vector<Type>* copy(int ilength); int in(Type c) const; Vector<Type>& operator=(const Vector<Type>& v); Vector<Type>& operator=(Type c); Vector<Type>& operator=(Type *p); Vector<Type>& operator+=(const Vector<Type>& v); Vector<Type>& operator+=(Type c); Vector<Type>& operator+=(Type *p); Vector<Type>& operator-=(const Vector<Type>& v); Vector<Type>& operator-=(Type c); Vector<Type>& operator-=(Type *p); Vector<Type>& operator*=(Type c); Vector<Type>& operator/=(Type c); Vector<Type>& addVal(Type); Vector<Type>& addVal(const Vector<Type>&); Vector<Type>& addVal(Type, int); size_t bfread(FILE *ifp); size_t bfwrite(FILE *ofp); operator Vector<int>() const; operator Vector<long>() const; operator Vector<float>() const; operator Vector<double>() const; \fIFriends\fP ostream& operator<<(ostream&, const Vector<Type>&); istream& operator>>(istream&, Vector<Type>&); \fIPrivate members\fP int n; Type *a;DESCRIPTION Vector<Type> is a simple template class for Vectors. It manages to do algebraic operations of one-dimensional arrays DESCRIPTION Constructors: Vector(): default constructor of length 1; Vector(n): constructor of a vector with length n; Vector(v): construct a new Vector as a copy of Vector v; Vector(n, Type* p): construct a Vector with n elements of the array *p; Fetching the Vector information: int size(): returns the size of the Vector as a constant; Type elem(i): returns the ith element as a constant; Type max(): returns the largest elements of the Vector; Type min(): returns the smallest elements of the Vector; int indexMax(): returns the index of the largest elements; int indexMin(): returns the index of the smallest elements; Type sum(): returns the sum of all elements; Type norm(p): returns the p norm of the Vector; Type norm2S(): returns the square sum of the Vector; Type* toPointer(): copy the Vector to an array, returns the pointer; Vector<Type>* copy(i, n): copy to a Vector of length n starting from the ith element, returns a pointer to the new Vector; Vector<Type>* copy(i): copy to a new Vector from the ith elemement to the last one, returns a pointer to the new Vector; Modifying the Vector; Type& operator[i]: access the ith elemet of the Vector; Vector<Type>& linear(a, b): assign linear values to the Vector, i.e. the ith element has the value of a+b*i; Vector<Type>& chaSize(nlen): change the size to nlen; Vector<Type>& addVal(a): append value a to the end; Vector<Type>& addVal(v): append Vector v to the end; Vector<Type>& addVal(a, i): insert a to the ith element; Vector<Type>& normalize(): normalize the Vector; Arithmatics: Operators -, =, +=, -=, *= /=, +, -, *, /, arithmatics with other Vectors, Arrays, a single number; Vector<Type> saxpy(a, u, v): u, v are Vectors of the same length and Type, returns a Vector a*u+v; I/O operators: <<, >> CAVEATS The implicit type conversion is very stable, so the operation needs EXACTLY the same type as defined. Other derived vectors should be created later.DEFINED MACROS VECTOR_HHINCLUDED FILES "defs.hh" <stdio.h>SOURCE FILES Vector.hh
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -